日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 嵌入式 > 嵌入式教程
[導(dǎo)讀]如何應(yīng)用AndesCore EDM安全訪問機(jī)制

EDM安全存取是AndesCoreTM內(nèi)建的功能(option),應(yīng)用在安全存取的控管。EDM安全存取有二種的控管方式:debug access indication和EDM access restriction。第一種控管方式(debug access indication)提供了一個(gè)sideband signal用于指示從調(diào)試器(Debug host)的請(qǐng)求。第二種控管方式, 控制AndesCoreTM的input port(edm_restrict_access )達(dá)到EDM存取的限制。更詳細(xì)的內(nèi)容在后續(xù)章節(jié)會(huì)有更深入的介紹。

1. EDM功能介紹

一個(gè)debug system包含一個(gè)debug host和一個(gè)target system。EDM主要的功能就是translate debug host發(fā)出的TAP指令來存取系統(tǒng)memory或是CPU。下圖為基本的debug系統(tǒng)方塊圖。

圖表1 基本的debug系統(tǒng)方塊圖

下圖說明TAP 指令的種類

圖表2 TAP 指令的種類

1. 控制EDM存取的限制

使用EDM的訪問方式會(huì)被一個(gè)sideband signal (edm_restrict_access) 所影響。當(dāng)這個(gè)signal值是high,僅僅只能對(duì)EDM MISC registers做讀取的動(dòng)作。而想要存取CPU/System Bus/Local Memory的動(dòng)作將會(huì)被封鎖住并且會(huì)得到下面的結(jié)果:

Ø 讀為零寫忽略

Ø 不正確的JTAG instruction(JTAG ICE debugger會(huì)timeout)

下圖說明EDM限制存取方塊圖。

圖表3 EDM限制存取方塊圖

在啟用存取限制功能后,下圖說明出每個(gè)TAP指令的行為。

圖表4 在啟用存取限制功能后,下圖說明出每個(gè)TAP指令的行為

如何實(shí)現(xiàn)EDM存取限制,在系統(tǒng)設(shè)計(jì)上有很多種實(shí)現(xiàn)方法,以控制edm restrict access的signal。兩種基本的設(shè)計(jì)方案說明如下:

Ø eFUSE方式使用Chip重新編程管理控制

Ø SOC方式使用軟件管理控制

hardware實(shí)現(xiàn)控制edm_restrict_access的示意圖如下:

圖表5 hardware實(shí)現(xiàn)控制edm_restrict_access的示意圖

software實(shí)現(xiàn)控制edm_restrict_access的例子如下:

• sethi $r2,#0x80000

• ori $r2,$r2,#0x8c

• sethi $r3,#0x04030

• ori $r3,$r3,#0x201

• swi $r3,[$r2+#0]

1. EDM 存取指示

AndesCoreTM增加一個(gè)額外的sideband signal,xdebug_access(active-high),根據(jù)此sideband signal來決定request的host是否為EDM。而device就能根據(jù)此sideband signal決定是否要把request的data內(nèi)容傳回到host。

sideband signal的名稱根據(jù)bus interface的類型而有所不同。對(duì)于AndesCoreTM處理器,基本的信號(hào)名稱如下所示:

• AHB/AHB-Lite => hdebug_access

• APB => pdebug_access

• EILM => eilm_debug_access

• EDLM => edlm_debug_access

3.1.debug存取識(shí)別信號(hào)控制

當(dāng)debug exception發(fā)生后,CPU將進(jìn)入debug mode。然后CPU將會(huì)留在debug access mode直到CPU執(zhí)行到IRET instruction并且trusted_debug_exit 是處于high后CPU將離開debug access mode,反之trusted_debug_exit如果是low,CPU將會(huì)保留在debug access mode。

實(shí)現(xiàn)控制trusted_debug_exit信號(hào),有二種可供選擇的方式如下:

• trusted_debug_exit信號(hào)總是給high

增加一個(gè)權(quán)限管理邏輯去控制trusted_debug_exit信號(hào)是high或是low權(quán)限管理邏輯方塊圖如下所示:

圖表6 權(quán)限管理邏輯方塊圖

如何控制trusted_debug_exit信號(hào)時(shí)序圖如下所示:

圖表7 如何控制trusted_debug_exit信號(hào)時(shí)序圖

如下例子說明了如何產(chǎn)生trusted_debug_exit控制信號(hào)的verilog code:

v The code example (Verilog) of trusted_debug_exit generation is described below:

v //

v //--- Utilize passcode to generate trusted_debug_exit in AHB Bus Controller

v //* assume zero-wait-state AHB access

v …

v parameter AUTH_CODE = 32’h0a0b0c0d;

v ...

v always @(posedge hclk or negedge hreset_n) begin

v if (!hreset_n) begin

v passcode_reg <= 32‘d0;

v end

v else if (passcode_wen) begin //debugger enters passcode through debug access

v passcode_reg <= hwdata[31:0];

v end

v end

v …

v //validate passcode to generate trusted_debug_exit[!--empirenews.page--]

v assign trusted_debug_exit = (passcode_reg == AUTH_CODE);

3.2.debug存取指示應(yīng)用

下圖說明AHB bus如何使用hdebug_access和驗(yàn)證邏輯來防止惡意的debug存取

圖表8 AHB bus如何使用hdebug_access和驗(yàn)證邏輯來防止惡意的debug存取

如下verilog code說明了如何使用hdebug_access信號(hào):

v //--- Use hdebug_access to prevent malicious debug access in AHB Bus Controller

v //* assume zero-wait-state AHB access

v …

v parameter IRRELEVANT_DATA = 32’hcafe0001;

v parameter AUTH_CODE = 32’h01020304;

v …

v always @(posedge hclk or negedge hreset_n) begin

v if (!hreset_n) begin

v dbg_acc_d1 <= 1‘b0;

v end

v else begin // data phase indication of debug access

v dbg_acc_d1 <= hdebug_access;

v end

v end

v ...

v always @(posedge hclk or negedge hreset_n) begin

v if (!hreset_n) begin

v passcode_reg <= 32‘d0;

v end

v else if (passcode_wen) begin //debugger enters passcode through debug access

v passcode_reg <= hwdata[31:0];

v end

v end

v …

v //validate passcode to check authentication

v assign auth_check_fail = (passcode_reg != AUTH_CODE);

v //return irrelevant data if the authentication check of debug access fails

v assign hrdata_out = {32{data_read_en}} &

v ((dbg_acc_d1 & auth_check_fail) ? IRRELEVANT_DATA : normal_data_out);

1. 實(shí)際的應(yīng)用

用戶經(jīng)由上面的介紹完成了權(quán)限管理邏輯后,并且掛在AndesCoreTMAHB bus上,再經(jīng)由仿真器(Cadence)仿真此權(quán)限管理邏輯的行為,如下面幾張圖所示:

• edm_restrict_access信號(hào)控制

下圖說明由sw code把edm_restrict_access signal disable

圖表9 由sw code把edm_restrict_access signal disable

• trusted_debug_exit信號(hào)控制

圖表10 經(jīng)由debug access把trusted_debug_exit signal設(shè)定成high

• debug_access信號(hào)

下圖說明經(jīng)由debug host來做存取時(shí),debug_access signal會(huì)從low變成high

下圖說明經(jīng)由執(zhí)行IRTE instruction時(shí),debug_access signal會(huì)從high變成low

圖表12 經(jīng)由執(zhí)行IRTE instruction時(shí),

debug_access signal會(huì)從high變成low

5. 結(jié)語(yǔ)

EDM安全存取是AndesCoreTM保護(hù)周邊裝置內(nèi)容不被竊取的功能,也因?yàn)樵絹碓蕉嗫蛻羰褂玫酱斯δ?,所以撰寫此技術(shù)文章讓客戶更能進(jìn)一步了解到此功能的用途,讓客戶能夠很快速的上手,并且使用晶心開發(fā)的EDM安全存取是一件愉快與簡(jiǎn)單的工作。

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉