Trusted Firmware-A · source analysis

BL33 선택과 Non-secure world 진입

BL32 초기화를 마친 BL31이 BL33 entry와 SPSR를 non-secure context에 넣고 마지막 ERET으로 U-Boot 또는 Linux에 제어권을 넘기는 경로를 읽습니다.

표의 버전은 소스 분석 기준이며 최신 보안 버전 권고가 아닙니다. TF-A LTS 2.14.3 이후에는 보안 수정이 있습니다. 제품 적용 시 공식 변경 기록과 사용 플랫폼의 errata를 확인하세요.

Series
12 / 12
Baseline
LTS 2.14.3
Commit
f5e765a3443f
Source
bl31/bl31_main.c:271-354 (발췌 범위)

BL31은 어떤 값으로 마지막 Non-secure ERET 대상을 고르는가?

next_image_type은 기본값이 NON_SECURE다. BL32 init hook은 SPD가 등록했을 때만 실행된다. 그 hook 또는 다른 서비스가 다음 image type을 바꿀 수 있으므로 bl31_prepare_next_image_entry()은 type을 다시 읽고 플랫폼의 entry_point_info_t를 요청한다.

함수는 pointer와 security-state 속성을 assert한 다음 cm_init_my_context()로 entry PC, SPSR, SCR 및 x0–x7 인자를 CPU context에 만든다. Non-secure라면 cm_prepare_el3_exit_ns()를 사용한다. 이후 bl31_main()이 runtime setup을 마치고 복귀하면 assembly가 BL31 data/cache clean을 거쳐 el3_exit으로 분기한다. 실제 ERET은 그 뒤 context의 레지스터를 복원해 수행한다.

기본 type · main 복귀 전 · 선택·준비 · entrypoint 복귀 뒤 · ERET

플랫폼 entry descriptor와 PE별 CPU context

그림 1. BL33의 PC·SPSR·args가 ERET 레지스터로 이동하는 경계

플랫폼이 제공한 entry 정보

bl31_plat_get_next_image_ep_info(type)선택한 security state의 entry_point_info_t pointer를 반환한다.
ep->h.attr · ep->pc · ep->spsr · ep->argsstate 일치 assert 후 PC/SPSR와 x0–x7 초기값의 원천이 된다.

BL31의 현재 PE context

cm_init_my_context(ep)state별 context를 골라 초기화한다. Non-secure setup은 저장된 SCR에 NS bit를 세운다.
cm_prepare_el3_exit_ns() → el3_exit다음 context를 지정하고, assembly가 SCR/SPSR/ELR·GP register를 복원해 ERET한다.

이 경로의 두 assert는 descriptor pointer와 security-state 일치를 본다. BL33 PC의 실제 memory range·BL31과의 overlap을 여기서 별도로 검사한다고 주장하지 않는다.

선택 · context fields · 현재 PE · exit

선택적 BL32 hook과 실제 마지막 분기

그림 2. cold boot에서 BL31 C 함수가 돌아온 뒤 ERET까지
1 · 선택적 initSPD가 bl32_init을 등록했을 때만 실행. RME의 RMM hook도 조건부다.
2 · next image 준비next_image_type → platform ep → context init → NS 또는 generic exit 준비.
3 · BL31 main 복귀platform runtime setup·console 처리 후 C 함수 반환. assembly가 data/BSS/per-CPU cache clean.
4 · el3_exit선택한 context의 SCR/SPSR/ELR 및 GP register 복원 → exception_return.

기존 “BL32 init complete → BL33 → init mappings disable” 직선은 고정 소스의 필수 호출 관계가 아니다. 이 부분에는 init mapping을 끄는 단계가 나타나지 않는다.

BL31 main · assembly tail · exit

각 단계가 실제로 생산하는 값

단계읽는 값성공 뒤 남는 상태다음 소비자
선택적 BL32/RMM init등록된 hook pointerhook이 없으면 호출 생략; 있는 경우 서비스가 next image type을 바꿀 수 있음bl31_prepare_next_image_entry
image type 선택기본 NON_SECURE 또는 bl31_set_next_image_type()로 갱신한 값현재 선택된 security stateplatform ep 조회
platform ep 조회image typenon-NULL pointer와 같은 security-state attr를 assertcm_init_my_context
context initep attr, PC, SPSR, args해당 PE의 state별 SCR/ELR/SPSR, GP x0–x7 등exit 준비
exit 준비·실행security state와 CPU context다음 ERET context 선택; assembly 복원 후 ERETBL33 또는 다른 선택 image

분석 범위에 포함된 이 두 assert 외의 PC 범위·메모리 격리 검증은 플랫폼 로더와 memory map을 별도로 확인한다.

context 사본과 build 조건부 exit 경로

그림 3. entry_point_info_t에서 ERET 직전 레지스터까지

descriptor

h.attrNon-secure state와 endianness 등
pc / spsr / argstarget PC·PSTATE와 x0–x7 입력

CPU context 사본

CTX_SCR_EL3Non-secure setup이 SCR_NS 설정
CTX_ELR_EL3 / CTX_SPSR_EL3ep PC/SPSR 복사; GP context에 args 복사

EL3 exit

next context현재 PE의 Non-secure context를 ERET 대상으로 지정
hardware registersSCR/SPSR/ELR·GP 복원 후 exception_return

SCR NS · PC/SPSR/x0–x7 · register restore

그림 4. cm_prepare_el3_exit_ns()의 두 compile-time 경로

CTX_INCLUDE_EL2_REGS && IMAGE_BL31

assertions가 켜졌다면NS context 존재, 저장된 SCR.HCE, EL2 구현을 확인한다.
EL2 restore → next contextcm_el2_sysregs_context_restore(NON_SECURE) 후 cm_set_next_eret_context.

그 외 빌드

cm_prepare_el3_exit(NON_SECURE)EL2가 구현됐으면 사용 여부에 따라 초기화·비활성화 경로를 거친다.
EL1 restore → next contextcompile 조건에 따라 EL1 sysregs를 복원하고 동일한 next-context API로 끝난다.

“모든 빌드가 동일한 EL1/EL2 복원 코드를 실행한다”는 해석은 틀리다. 실제 분기는 compile flag와 image type에 달려 있다.

generic · NS helper

원본 코드

아래 코드는 Trusted Firmware-A LTS 2.14.3의 bl31/bl31_main.c에서 271-354줄을 그대로 가져온 것이다.

commitf5e765a3443fe21154aa908228e75ee2600085f6anchor · L295void __init bl31_prepare_next_image_entry(void)
271
272/*******************************************************************************
273 * Accessor functions to help runtime services decide which image should be
274 * executed after BL31. This is BL33 or the non-secure bootloader image by
275 * default but the Secure payload dispatcher could override this by requesting
276 * an entry into BL32 (Secure payload) first. If it does so then it should use
277 * the same API to program an entry into BL33 once BL32 initialisation is
278 * complete.
279 ******************************************************************************/
280void bl31_set_next_image_type(uint32_t security_state)
281{
282	assert(sec_state_is_valid(security_state));
283	next_image_type = security_state;
284}
285
286static uint32_t bl31_get_next_image_type(void)
287{
288	return next_image_type;
289}
290
291/*******************************************************************************
292 * This function programs EL3 registers and performs other setup to enable entry
293 * into the next image after BL31 at the next ERET.
294 ******************************************************************************/
295void __init bl31_prepare_next_image_entry(void)
296{
297	const entry_point_info_t *next_image_info;
298	uint32_t image_type;
299
300#if CTX_INCLUDE_AARCH32_REGS
301	/*
302	 * Ensure that the build flag to save AArch32 system registers in CPU
303	 * context is not set for AArch64-only platforms.
304	 */
305	if (el_implemented(1) == EL_IMPL_A64ONLY) {
306		ERROR("EL1 supports AArch64-only. Please set build flag "
307				"CTX_INCLUDE_AARCH32_REGS = 0\n");
308		panic();
309	}
310#endif
311
312	/* Determine which image to execute next */
313	image_type = bl31_get_next_image_type();
314
315	/* Program EL3 registers to enable entry into the next EL */
316	next_image_info = bl31_plat_get_next_image_ep_info(image_type);
317	assert(next_image_info != NULL);
318	assert(image_type == GET_SECURITY_STATE(next_image_info->h.attr));
319
320	INFO("BL31: Preparing for EL3 exit to %s world\n",
321		(image_type == SECURE) ? "secure" : "normal");
322	print_entry_point_info(next_image_info);
323	cm_init_my_context(next_image_info);
324
325	/*
326	* If we are entering the Non-secure world, use
327	* 'cm_prepare_el3_exit_ns' to exit.
328	*/
329	if (image_type == NON_SECURE) {
330		cm_prepare_el3_exit_ns();
331	} else {
332		cm_prepare_el3_exit(image_type);
333	}
334}
335
336/*******************************************************************************
337 * This function initializes the pointer to BL32 init function. This is expected
338 * to be called by the SPD after it finishes all its initialization
339 ******************************************************************************/
340void bl31_register_bl32_init(int32_t (*func)(void))
341{
342	bl32_init = func;
343}
344
345#if ENABLE_RME
346/*******************************************************************************
347 * This function initializes the pointer to RMM init function. This is expected
348 * to be called by the RMMD after it finishes all its initialization
349 ******************************************************************************/
350void bl31_register_rmm_init(int32_t (*func)(void))
351{
352	rmm_init = func;
353}
354#endif

발췌와 마지막 ERET의 위치

위 bl31_main.c 271–354행은 다음 image type과 context 준비를 담지만, bl31_main()에서 hook을 조건부로 호출하는 175–238행과 기본 type 선언 60–63행은 없다. 두 관련 코드 발췌는 context 관리만 보여준다. C 함수가 돌아온 뒤 data/BSS/per-CPU clean과 el3_exit 호출은 bl31_entrypoint.S 84–124, 실제 register 복원과 exception return은 context.S 630–658에서 확인한다.

함께 읽어야 하는 원본 코드

두 발췌는 같은 기준 commit의 context management다. 실제 BL31 main의 선택적 init hook과 C 함수 복귀 후 ERET assembly는 고정 원문 링크에서 별도로 확인한다.

01. Non-secure context를 마지막 ERET 대상으로 준비

lib/el3_runtime/aarch64/context_mgmt.c 1705-1755줄이다.

filelib/el3_runtime/aarch64/context_mgmt.canchor · L1715void cm_prepare_el3_exit_ns(void)
1705	}
1706}
1707#endif /* (CTX_INCLUDE_EL2_REGS && IMAGE_BL31) */
1708
1709/*******************************************************************************
1710 * This function is used to exit to Non-secure world. If CTX_INCLUDE_EL2_REGS
1711 * is enabled, it restores EL1 and EL2 sysreg contexts instead of directly
1712 * updating EL1 and EL2 registers. Otherwise, it calls the generic
1713 * cm_prepare_el3_exit function.
1714 ******************************************************************************/
1715void cm_prepare_el3_exit_ns(void)
1716{
1717#if (CTX_INCLUDE_EL2_REGS && IMAGE_BL31)
1718#if ENABLE_ASSERTIONS
1719	cpu_context_t *ctx = cm_get_context(NON_SECURE);
1720	assert(ctx != NULL);
1721
1722	/* Assert that EL2 is used. */
1723	u_register_t scr_el3 = read_ctx_reg(get_el3state_ctx(ctx), CTX_SCR_EL3);
1724	assert(((scr_el3 & SCR_HCE_BIT) != 0UL) &&
1725			(el_implemented(2U) != EL_IMPL_NONE));
1726#endif /* ENABLE_ASSERTIONS */
1727
1728	/* Restore EL2 sysreg contexts */
1729	cm_el2_sysregs_context_restore(NON_SECURE);
1730	cm_set_next_eret_context(NON_SECURE);
1731#else
1732	cm_prepare_el3_exit(NON_SECURE);
1733#endif /* (CTX_INCLUDE_EL2_REGS && IMAGE_BL31) */
1734}
1735
1736#if ((IMAGE_BL1) || (IMAGE_BL31 && (!CTX_INCLUDE_EL2_REGS)))
1737/*******************************************************************************
1738 * The next set of six functions are used by runtime services to save and restore
1739 * EL1 context on the 'cpu_context' structure for the specified security state.
1740 ******************************************************************************/
1741static void el1_sysregs_context_save(el1_sysregs_t *ctx)
1742{
1743	write_el1_ctx_common(ctx, spsr_el1, read_spsr_el1());
1744	write_el1_ctx_common(ctx, elr_el1, read_elr_el1());
1745
1746#if (!ERRATA_SPECULATIVE_AT)
1747	write_el1_ctx_common(ctx, sctlr_el1, read_sctlr_el1());
1748	write_el1_ctx_common(ctx, tcr_el1, read_tcr_el1());
1749#endif /* (!ERRATA_SPECULATIVE_AT) */
1750
1751	write_el1_ctx_common(ctx, cpacr_el1, read_cpacr_el1());
1752	write_el1_ctx_common(ctx, csselr_el1, read_csselr_el1());
1753	write_el1_ctx_common(ctx, sp_el1, read_sp_el1());
1754	write_el1_ctx_common(ctx, esr_el1, read_esr_el1());
1755	write_el1_ctx_common(ctx, mair_el1, read_mair_el1());

02. BL33 ep_info로 Non-secure EL1/EL2 context 구성

lib/el3_runtime/aarch64/context_mgmt.c 222-376줄이다.

filelib/el3_runtime/aarch64/context_mgmt.canchor · L232static void setup_ns_context
222	if (is_feat_trbe_supported()) {
223		trbe_disable_realm(ctx);
224	}
225}
226#endif /* ENABLE_RME && IMAGE_BL31 */
227
228/******************************************************************************
229 * This function performs initializations that are specific to NON-SECURE state
230 * and updates the cpu context specified by 'ctx'.
231 *****************************************************************************/
232static void setup_ns_context(cpu_context_t *ctx, const struct entry_point_info *ep)
233{
234	u_register_t scr_el3;
235	el3_state_t *state;
236
237	state = get_el3state_ctx(ctx);
238	scr_el3 = read_ctx_reg(state, CTX_SCR_EL3);
239
240	/* SCR_NS: Set the NS bit */
241	scr_el3 |= SCR_NS_BIT;
242
243	/* Allow access to Allocation Tags when FEAT_MTE2 is implemented and enabled. */
244	if (is_feat_mte2_supported()) {
245		scr_el3 |= SCR_ATA_BIT;
246	}
247
248	/*
249	 * Pointer Authentication feature, if present, is always enabled by
250	 * default for Non secure lower exception levels. We do not have an
251	 * explicit flag to set it. To prevent the leakage between the worlds
252	 * during world switch, we enable it only for the non-secure world.
253	 *
254	 * CTX_INCLUDE_PAUTH_REGS flag, is explicitly used to enable for lower
255	 * exception levels of secure and realm worlds.
256	 *
257	 * If the Secure/realm world wants to use pointer authentication,
258	 * CTX_INCLUDE_PAUTH_REGS must be explicitly set to 1, in which case
259	 * it will be enabled globally for all the contexts.
260	 *
261	 * SCR_EL3.API: Set to one to not trap any PAuth instructions at ELs
262	 *  other than EL3
263	 *
264	 * SCR_EL3.APK: Set to one to not trap any PAuth key values at ELs other
265	 *  than EL3
266	 */
267	if (!is_ctx_pauth_supported()) {
268		scr_el3 |= SCR_API_BIT | SCR_APK_BIT;
269	}
270
271#if HANDLE_EA_EL3_FIRST_NS
272	/* SCR_EL3.EA: Route External Abort and SError Interrupt to EL3. */
273	scr_el3 |= SCR_EA_BIT;
274#endif
275
276#if RAS_TRAP_NS_ERR_REC_ACCESS
277	/*
278	 * SCR_EL3.TERR: Trap Error record accesses. Accesses to the RAS ERR
279	 * and RAS ERX registers from EL1 and EL2(from any security state)
280	 * are trapped to EL3.
281	 * Set here to trap only for NS EL1/EL2
282	 */
283	scr_el3 |= SCR_TERR_BIT;
284#endif
285
286	/* CSV2 version 2 and above */
287	if (is_feat_csv2_2_supported()) {
288		/* Enable access to the SCXTNUM_ELx registers. */
289		scr_el3 |= SCR_EnSCXT_BIT;
290	}
291
292#ifdef IMAGE_BL31
293	/*
294	 * SCR_EL3.IRQ, SCR_EL3.FIQ: Enable the physical FIQ and IRQ routing as
295	 *  indicated by the interrupt routing model for BL31.
296	 */
297	scr_el3 |= get_scr_el3_from_routing_model(NON_SECURE);
298#endif
299
300	if (is_feat_the_supported()) {
301		/* Set the RCWMASKEn bit in SCR_EL3 to enable access to
302		 * RCWMASK_EL1 and RCWSMASK_EL1 registers.
303		 */
304		scr_el3 |= SCR_RCWMASKEn_BIT;
305	}
306
307	if (is_feat_sctlr2_supported()) {
308		/* Set the SCTLR2En bit in SCR_EL3 to enable access to
309		 * SCTLR2_ELx registers.
310		 */
311		scr_el3 |= SCR_SCTLR2En_BIT;
312	}
313
314	if (is_feat_d128_supported()) {
315		/* Set the D128En bit in SCR_EL3 to enable access to 128-bit
316		 * versions of TTBR0_EL1, TTBR1_EL1, RCWMASK_EL1, RCWSMASK_EL1,
317		 * PAR_EL1 and TTBR1_EL2, TTBR0_EL2 and VTTBR_EL2 registers.
318		 */
319		scr_el3 |= SCR_D128En_BIT;
320	}
321
322	if (is_feat_fpmr_supported()) {
323		/* Set the EnFPM bit in SCR_EL3 to enable access to FPMR
324		 * register.
325		 */
326		scr_el3 |= SCR_EnFPM_BIT;
327	}
328
329	if (is_feat_aie_supported()) {
330		/* Set the AIEn bit in SCR_EL3 to enable access to (A)MAIR2
331		 * system registers from NS world.
332		 */
333		scr_el3 |= SCR_AIEn_BIT;
334	}
335
336	if (is_feat_pfar_supported()) {
337		/* Set the PFAREn bit in SCR_EL3 to enable access to the PFAR
338		 * system registers from NS world.
339		 */
340		scr_el3 |= SCR_PFAREn_BIT;
341	}
342
343	write_ctx_reg(state, CTX_SCR_EL3, scr_el3);
344
345	/* Initialize EL2 context registers */
346#if (CTX_INCLUDE_EL2_REGS && IMAGE_BL31)
347	if (is_feat_hcx_supported()) {
348		/*
349		 * Initialize register HCRX_EL2 with its init value.
350		 * As the value of HCRX_EL2 is UNKNOWN on reset, there is a
351		 * chance that this can lead to unexpected behavior in lower
352		 * ELs that have not been updated since the introduction of
353		 * this feature if not properly initialized, especially when
354		 * it comes to those bits that enable/disable traps.
355		 */
356		write_el2_ctx_hcx(get_el2_sysregs_ctx(ctx), hcrx_el2,
357			HCRX_EL2_INIT_VAL);
358	}
359
360	if (is_feat_fgt_supported()) {
361		/*
362		 * Initialize HFG*_EL2 registers with a default value so legacy
363		 * systems unaware of FEAT_FGT do not get trapped due to their lack
364		 * of initialization for this feature.
365		 */
366		write_el2_ctx_fgt(get_el2_sysregs_ctx(ctx), hfgitr_el2,
367			HFGITR_EL2_INIT_VAL);
368		write_el2_ctx_fgt(get_el2_sysregs_ctx(ctx), hfgrtr_el2,
369			HFGRTR_EL2_INIT_VAL);
370		write_el2_ctx_fgt(get_el2_sysregs_ctx(ctx), hfgwtr_el2,
371			HFGWTR_EL2_INIT_VAL);
372	}
373#else
374	/* Initialize EL1 context registers */
375	setup_el1_context(ctx, ep);
376#endif /* (CTX_INCLUDE_EL2_REGS && IMAGE_BL31) */

source에서 직접 확인되는 네 경계

01

BL32 완료가 항상 전제는 아니다

bl32_init은 SPD가 등록해야만 호출된다. 호출했더라도 반환값 0은 경고 로그로 처리하고 다음 image 준비가 이어진다. 따라서 이 지점만으로 BL32의 정상 초기화를 증명할 수 없다.

02

platform descriptor의 attr를 검사한다

bl31_prepare_next_image_entry()는 선택한 type의 ep pointer가 NULL이 아니고 ep의 security-state attr가 type과 같은지 assert한다. PC가 executable 영역인지 또는 BL31과 겹치는지는 이 함수의 검사 항목이 아니다.

03

args는 x0–x3만이 아니다

setup_context_common()은 ep->args의 aapcs64_params_t를 GP context로 복사한다. 주석은 x0–x7을 명시한다. 인자의 구체적인 의미는 플랫폼의 BL33 descriptor와 그 image의 부팅 계약에서 정한다.

04

exit는 C 함수의 return 뒤에 있다

BL31은 runtime setup과 console 전환 뒤 C 함수에서 돌아온다. entrypoint assembly는 data/BSS/per-CPU 영역을 clean하고 el3_exit에 진입한다. ERET는 저장된 SCR/SPSR/ELR와 GP register가 복원된 뒤 실행된다.

main tail · args · cache clean · ERET

선택, 검증, 복원은 서로 다른 책임

01

default는 NS지만 SPD가 override할 수 있다

next_image_type은 NON_SECURE로 초기화된다. bl31_set_next_image_type()은 유효한 security state인지 assert하고 값을 바꾼다. 따라서 진짜 첫 ERET 목적지는 bl31_prepare_next_image_entry()가 호출되는 시점의 값으로 판정한다. Secure image를 먼저 선택한 경우 generic exit 준비 경로를 쓴다.

02

CPU context는 ep를 복사한다

cm_init_my_context()는 ep attr로 현재 PE의 security-state context를 고르고 cm_setup_context()가 이를 초기화한다. common setup은 저장된 ELR/SPSR와 GP 인자를 채우고, NS 전용 setup이 SCR.NS를 설정한다. 플랫폼 descriptor 자체가 EL3 exit register인 것은 아니다.

03

memory map은 다른 계약이다

이 경로는 platform ep pointer와 security-state attr를 assert한다. BL33의 물리 메모리 배치와 BL31/BL32 carveout 충돌은 여기서 판단하지 않는다. 대상 플랫폼의 image loader·MMU map·보호 메커니즘·BL33 부팅 인자를 같이 검증해야 한다.

실제 조건과 잘못된 추론

조건고정 소스에서 관찰되는 결과이 결과만으로 말할 수 없는 것
BL32 hook 미등록if (bl32_init != NULL) 블록 생략BL32가 항상 존재·초기화됐다는 주장
hook 반환값 0BL31 경고 로그 후 코드 진행BL33 진입을 차단하는 실패 반환
next ep pointer NULL 또는 attr/type 불일치bl31_prepare_next_image_entry() assert모든 메모리 범위·권한 검사 완료
CTX_INCLUDE_EL2_REGS && IMAGE_BL31NS helper가 EL2 context restore와 next-context 설정; assertions 시 HCE/EL2 확인모든 빌드에서 동일한 EL1/EL2 준비
bl31_main() 복귀assembly cache clean 후 el3_exitinit mapping disable 또는 BL31 runtime 폐기

bl31_main.c · context_mgmt.c · bl31_entrypoint.S

상태의 저장 위치와 소비 시점

대상저장 위치·생산자소비자
next_image_typeBL31 정적 변수; 기본 NON_SECURE, setter가 변경prepare 함수
entry_point_info_t플랫폼이 제공한 descriptor pointercm_init_my_context가 PC/SPSR/args/attr를 읽음
현재 PE의 NS cpu_context_tcontext management가 초기화한 복사본NS exit prepare와 el3_exit
EL3 runtime stack과 BL31 dataBL31의 resident runtime state첫 ERET 뒤에도 SMC/예외 처리를 위해 남음

증상과 첫 검사 위치

증상먼저 기록할 값해당 경계
예상한 BL33 대신 Secure image로 감prepare 직전 next_image_type과 setter 호출BL31 type 선택
prepare에서 assertep pointer와 GET_SECURITY_STATE(ep->h.attr)platform ep 조회
EL3 exit 직후 첫 exception저장된 PC/SPSR/SCR, target EL과 image 형식context init·ERET
BL33가 BL31/BL32 영역을 손상플랫폼 load map, carveout, BL33 memory descriptionplatform loader·memory policy; 이 prepare 함수 밖

Non-secure 진입의 성공 여부는 대상 플랫폼과 image에 달려 있다. 이 함수에서 모든 PC 범위나 memory ownership을 검증한다는 결론은 피한다.

고정 소스와 대상 플랫폼의 증거

이 검토는 공식 LTS 소스와 브라우저 렌더를 대조했다. TF-A 빌드와 보드 실행은 하지 않았다.

증거확인 항목의미
BL31 maindefault type, 선택적 init hook, ep 조회와 assert고정 소스의 제어 흐름
context managementSCR_NS, PC/SPSR, x0–x7, compile-time exit branch레지스터 context 구성
entrypoint + exitC return 뒤 clean, register restore, ERET실제 마지막 단계
대상 플랫폼의 ep_info·map·ELF·허용된 traceBL33 PC/EL/args와 secure carveout보드별 유효성; 이 검토에서는 미실행

실기기에서 나눠 확인할 세 질문

  1. 01
    첫 ERET의 security state

    BL32 hook 등록 여부, prepare 직전 next_image_type, 반환 ep attr를 같은 부팅 로그로 비교한다.

  2. 02
    entry descriptor와 context의 값

    ep PC/SPSR/x0–x7과 NS context의 ELR/SPSR/GP register 사본을 비교한다. 인자 의미는 대상 BL33의 계약을 따른다.

  3. 03
    target EL과 memory map

    대상 플랫폼의 BL33 load region·BL31/BL32 carveout과 저장된 SCR/SPSR/ELR를 비교한다. 보드의 지원 가능한 추적 수단에서 수행한다.

원문과 다음 글

예약된 DRAM과 하드웨어 격리를 구별합니다

DT의 reserved-memory는 운영체제가 해당 영역을 일반 메모리로 쓰지 않도록 전달하는 정보이지, 적대적인 Non-secure 접근을 막는 방화벽 자체가 아닙니다. TF-A의 Raspberry Pi 3와 Raspberry Pi 4 포트 문서는 Secure/Non-secure DRAM 사이의 하드웨어 보호 부재를 경고합니다. 따라서 그 포트의 EL3 실행이나 carveout을 제품 수준의 TEE 격리 증거로 사용할 수 없습니다.

2026-10-26 확인한 RPi4 latest 문서는 기본 BL31-only 외에 선택적 staged BL1·BL2·BL31 구성을 설명합니다. 그 staged measured-boot 구성에서는 BL33이 FIP 밖에 미리 놓이며 BL2가 BL33을 측정하지 않는다고 명시합니다. 반면 같은 2.15.0 배너의 stable 문서는 BL31-only만 설명하고 해당 staged 절이 없습니다. 이 제한은 확인한 latest 문서 상태에 대한 설명이지 모든 2.15.0 체크아웃의 공통 동작이 아닙니다.

STM32MP1의 Cortex-A7 구성과 STM32MP2의 Cortex-A35 구성 역시 각 MPU·보드의 참조 자료입니다. RPi의 보호 한계를 그 플랫폼에 그대로 적용하거나, 특정 DDR·FIP 명령을 범용 MCU 절차로 바꾸지 않습니다. 실제 보드의 ROM, 키 저장소, 메모리 방화벽과 부팅 경로를 별도로 검증해야 합니다.