CPU를 새로 켤 때는 BL31의 warm boot 경로를 봅니다
부팅을 마친 BL31은 EL3에 남아 요청을 처리합니다. CPU_ON으로 새 CPU를 시작할 때에는 각 CPU가 BL31 최초 초기화 전체를 다시 수행하는 것이 아니라 플랫폼의 warm boot 경로를 거칩니다. Linux가 넘긴 비보안 entrypoint와 context_id를 새 CPU의 context로 구성한 뒤 커널로 진입합니다.
QUESTION
BL31이 초기화하고 EL3에 남기는 것은 무엇인가?
TF-A LTS 2.14.3에서 첫 CPU의 cold entry는 assembly bl31_entrypoint를 거쳐 bl31_main()에 들어간다. 플랫폼·context management·runtime service를 초기화한 뒤 다음 이미지의 CPU context를 준비한다. BL31의 resident code/data와 CPU별 EL3 context는 이후 SMC·PSCI 처리를 위해 남는다.
BL32 초기화와 RMM 초기화는 등록된 훅 및 빌드 설정에 따른 분기다. 기본 다음 이미지 유형은 NON_SECURE이며 dispatcher가 BL32를 먼저 선택할 수 있다. 아래 그림은 이 조건을 명시하고, 나중의 CPU_ON warm entry는 별도 레인으로 다룬다.
STRUCTURE
BL31 본체·서비스 표·다음 이미지 문맥
RESET_TO_BL31 설정에 따라 준비 조건이 다르다.entry_point_info_t를 읽어 선택한 security state의 CPU context를 준비한다.가운데는 나중의 EL3 호출을 처리할 resident 상태다. 오른쪽의 entry_point_info_t는 BL31 본체가 아니라 다음 이미지 진입 정보다. 값의 출처와 보존 기간은 플랫폼 구현 및 linker map에서 확인한다.
CALL PATH
cold entry에서 첫 ERET 준비까지
- 1assembly cold entry
bl31_entrypoint가 x0–x3를 보존하고,RESET_TO_BL31에 맞는el3_entrypoint_common설정 뒤 Cbl31_main()을 호출한다. - 2platform → context → runtime services
bl31_early_platform_setup2→ arch/platform setup →bl31_lib_init()안의cm_init()→runtime_svc_init(). GIC·DSU·EHF 단계는 관련 빌드 조건을 따른다. - 3선택적 초기화 훅코드 순서는 BL32 확인 다음 RMM 확인이며, 없는 훅은 건너뛴다.BL32
bl32_init != NULL일 때만 호출RMMENABLE_RME와rmm_init != NULL일 때만 호출 - 4다음 이미지 문맥 준비
bl31_prepare_next_image_entry()가 선택된 security state의entry_point_info_t를 가져와cm_init_my_context()와cm_prepare_el3_exit_*를 호출한다. - 5C 반환 → assembly
el3_exitbl31_main()이 platform runtime setup과 console 전환 뒤 반환한다. assembly가 data/bss/per-CPU 범위를 clean한 다음el3_exit로 분기한다. C 함수 자체가ERET하지 않는다.
STATE LEDGER
단계별 상태와 분기 조건
후속 소비자가 실제로 읽는 값과 선택 조건을 함께 본다.
| 순서 | 단계 | 입력 | 확정되는 상태 | 조건/실패 처리 |
|---|---|---|---|---|
| 1 | cold assembly | x0–x3, reset 구성 | C 인자·EL3 실행 환경 | RESET_TO_BL31별 common-entry 인자가 다름 |
| 2 | platform·cm_init() | platform handoff | 플랫폼 장치 기반, context 관리 준비 | GIC/DSU/EHF는 빌드 조건부 |
| 3 | runtime_svc_init() | linker descriptor | 성공 서비스의 OEN/call-type index | invalid descriptor → panic; init 비0 → 해당 descriptor 건너뜀 |
| 4 | BL32 init | 등록된 hook | 선택적 secure payload 초기화 | hook 없으면 생략; 반환 0이면 경고 후 진행 |
| 5 | RMM init | RME 설정·등록 hook | 선택적 Realm 초기화 | ENABLE_RME와 hook 모두 필요 |
| 6 | next image | image type·platform ep info | 선택된 CPU context·EL3 exit 준비 | 기본은 NON_SECURE, dispatcher가 변경 가능 |
| 7 | assembly exit | C 반환과 준비된 context | 메모리 clean 뒤 el3_exit | 실제 다음 이미지 실행은 assembly exit |
VISUAL WALKTHROUGH
cold 초기화와 CPU_ON warm 진입을 분리해 읽기
첫 CPU: cold
bl31_entrypoint→bl31_main- platform/context/runtime service 초기화
- 조건부 BL32·RMM hook
- next image context → C 반환 →
el3_exit
CPU_ON 이후: warm
bl31_warm_entrypoint진입bl31_warmboot()가 CPU별 확장을 준비psci_warmboot_entrypoint(core_pos)- assembly warm 경로의
el3_exit
warm 경로에서 bl31_main()의 cold 초기화 전체를 되풀이하지 않는다. Linux CPU_ON과 함께 읽기 · bl31_warmboot() · warm assembly
RESET_TO_BL31에 따름.__init 함수는 첫 cold path에서 쓰인다. 재사용·해제 가능 여부는 해당 플랫폼 linker script와 메모리 맵으로 따로 확인한다.entry_point_info_t가 CPU context 준비에 쓰인다. 이것이 BL31 runtime 객체 자체는 아니다.UPSTREAM SOURCE
원본 코드
아래 코드는 Trusted Firmware-A LTS 2.14.3의 bl31/bl31_main.c에서 81-169줄을 그대로 가져온 것이다.
81 DEFINE_STATIC_PSCI_LIB_ARGS_V1(psci_args, bl31_warm_entrypoint);
82
83 /* PSCI is the only ARM Standard Service implemented */
84 assert(svc_mask == PSCI_FID_MASK);
85
86 return (uintptr_t)&psci_args;
87}
88
89/*******************************************************************************
90 * Simple function to initialise all BL31 helper libraries.
91 ******************************************************************************/
92static void __init bl31_lib_init(void)
93{
94 cm_init();
95}
96
97/*******************************************************************************
98 * BL31 is responsible for setting up the runtime services for the primary cpu
99 * before passing control to the bootloader or an Operating System. This
100 * function calls runtime_svc_init() which initializes all registered runtime
101 * services. The run time services would setup enough context for the core to
102 * switch to the next exception level. When this function returns, the core will
103 * switch to the programmed exception level via an ERET.
104 ******************************************************************************/
105void __no_pauth bl31_main(u_register_t arg0, u_register_t arg1, u_register_t arg2,
106 u_register_t arg3)
107{
108 unsigned int core_pos = plat_my_core_pos();
109
110 /* Enable early console if EARLY_CONSOLE flag is enabled */
111 plat_setup_early_console();
112
113 /* Perform early platform-specific setup */
114 bl31_early_platform_setup2(arg0, arg1, arg2, arg3);
115
116 /* Perform late platform-specific setup */
117 bl31_plat_arch_setup();
118
119#if FEATURE_DETECTION
120 /* Detect if features enabled during compilation are supported by PE. */
121 detect_arch_features(core_pos);
122#endif /* FEATURE_DETECTION */
123
124 /* Prints context_memory allocated for all the security states */
125 report_ctx_memory_usage();
126
127 /* Init registers that never change for the lifetime of the core. */
128 cm_manage_extensions_el3(core_pos);
129
130 /* Init per-world context registers */
131 cm_manage_extensions_per_world();
132
133 NOTICE("BL31: %s\n", build_version_string);
134 NOTICE("BL31: %s\n", build_message);
135
136#if ENABLE_RUNTIME_INSTRUMENTATION
137 PMF_CAPTURE_TIMESTAMP(bl_svc, BL31_ENTRY, PMF_CACHE_MAINT);
138#endif
139
140#ifdef SUPPORT_UNKNOWN_MPID
141 if (unsupported_mpid_flag == 0) {
142 NOTICE("Unsupported MPID detected!\n");
143 }
144#endif
145
146 /* Perform platform setup in BL31 */
147 bl31_platform_setup();
148
149#if USE_DSU_DRIVER
150 dsu_driver_init(&plat_dsu_data);
151#endif
152
153#if USE_GIC_DRIVER
154 /*
155 * Initialize the GIC driver as well as per-cpu and global interfaces.
156 * Platform has had an opportunity to initialise specifics.
157 */
158 gic_init(core_pos);
159 gic_pcpu_init(core_pos);
160 gic_cpuif_enable(core_pos);
161#endif /* USE_GIC_DRIVER */
162
163 /* Initialise helper libraries */
164 bl31_lib_init();
165
166#if EL3_EXCEPTION_HANDLING
167 INFO("BL31: Initialising Exception Handling Framework\n");
168 ehf_init();
169#endif
READING CONTRACT
발췌와 실제 실행 범위를 구분하기
위 원본의 81–169행은 bl31_main() 시작 105행을 포함하지만, runtime_svc_init() 호출과 BL32/RMM 분기는 발췌 밖인 170행 이후다. 함수 전체를 위 상자만으로 판단하지 말고 아래 관련 원본과 cold main 후반을 함께 읽는다.
소스에는 bl31_main() 반환 뒤 assembly가 el3_exit으로 분기하는 단계가 별도로 있다. bl31_prepare_next_image_entry()의 이름은 다음 context 준비를 뜻하며 그 자리에서 C 코드가 직접 ERET한다는 뜻이 아니다.
RELATED SOURCE
함께 읽어야 하는 원본 코드
첫 코드 조각만으로 동작이 완성되지 않는 경우 호출 매크로, 객체 정의와 실제 실행 목록을 같은 페이지에 묶었다. 각 조각은 같은 기준 commit에서 가져왔다.
01. linker section의 EL3 runtime service를 초기화
common/runtime_svc.c 78-155줄이다.
78 return -EINVAL;
79 }
80 return 0;
81}
82
83/*******************************************************************************
84 * This function calls the initialisation routine in the descriptor exported by
85 * a runtime service. Once a descriptor has been validated, its start & end
86 * owning entity numbers and the call type are combined to form a unique oen.
87 * The unique oen is used as an index into the 'rt_svc_descs_indices' array.
88 * The index of the runtime service descriptor is stored at this index.
89 ******************************************************************************/
90void __init runtime_svc_init(void)
91{
92 int rc = 0;
93 uint8_t index, start_idx, end_idx;
94 rt_svc_desc_t *rt_svc_descs;
95
96 /* Assert the number of descriptors detected are less than maximum indices */
97 assert((RT_SVC_DESCS_END >= RT_SVC_DESCS_START) &&
98 (RT_SVC_DECS_NUM < MAX_RT_SVCS));
99
100 /* If no runtime services are implemented then simply bail out */
101 if (RT_SVC_DECS_NUM == 0U) {
102 return;
103 }
104 /* Initialise internal variables to invalid state */
105 (void)memset(rt_svc_descs_indices, -1, sizeof(rt_svc_descs_indices));
106
107 rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START;
108 for (index = 0U; index < RT_SVC_DECS_NUM; index++) {
109 rt_svc_desc_t *service = &rt_svc_descs[index];
110
111 /*
112 * An invalid descriptor is an error condition since it is
113 * difficult to predict the system behaviour in the absence
114 * of this service.
115 */
116 rc = validate_rt_svc_desc(service);
117 if (rc != 0) {
118 ERROR("Invalid runtime service descriptor %p\n",
119 (void *) service);
120 panic();
121 }
122
123 /*
124 * The runtime service may have separate rt_svc_desc_t
125 * for its fast smc and yielding smc. Since the service itself
126 * need to be initialized only once, only one of them will have
127 * an initialisation routine defined. Call the initialisation
128 * routine for this runtime service, if it is defined.
129 */
130 if (service->init != NULL) {
131 rc = service->init();
132 if (rc != 0) {
133 ERROR("Error initializing runtime service %s\n",
134 service->name);
135 continue;
136 }
137 }
138
139 /*
140 * Fill the indices corresponding to the start and end
141 * owning entity numbers with the index of the
142 * descriptor which will handle the SMCs for this owning
143 * entity range.
144 */
145 start_idx = (uint8_t)get_unique_oen(service->start_oen,
146 service->call_type);
147 end_idx = (uint8_t)get_unique_oen(service->end_oen,
148 service->call_type);
149 assert(start_idx <= end_idx);
150 assert(end_idx < MAX_RT_SVCS);
151 for (; start_idx <= end_idx; start_idx++) {
152 rt_svc_descs_indices[start_idx] = index;
153 }
154 }
155}
02. BL32 또는 BL33을 다음 ERET 대상으로 선택하는 준비 함수
bl31/bl31_main.c 283-354줄이다.
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
DETAILS
원문 함수에서 확인되는 경계
assembly에서 C로
bl31_entrypoint는 x0–x3를 x20–x23에 보존했다가 다시 C 인자에 놓는다. RESET_TO_BL31 여부에 따라 el3_entrypoint_common의 SCTLR·memory 초기화 인자가 달라진다. 이 페이지가 모든 플랫폼의 BL2 handoff 형태를 하나로 단정하지 않는 이유다. assembly:25–84
context 관리와 서비스 등록
bl31_lib_init() 안의 cm_init()가 runtime_svc_init()보다 먼저 실행된다. 다만 이것이 모든 runtime service의 init 성공을 보증하지는 않는다. descriptor가 유효하지 않으면 panic, init callback이 비0을 돌려주면 해당 descriptor를 건너뛴다. main:90–173 · runtime_svc:90–155
BL32와 RMM은 조건부
bl32_init이 등록됐을 때만 BL32 hook을 실행한다. 그 다음 RME가 켜져 있고 rmm_init이 등록됐을 때만 RMM hook을 실행한다. 각 hook 반환값이 0이면 경고를 남기지만 이 함수는 즉시 중단하지 않고 다음 단계로 간다. main:175–218
next image context는 별도 객체
next_image_type은 기본 NON_SECURE다. dispatcher가 secure image를 먼저 선택할 수 있다. bl31_prepare_next_image_entry()는 플랫폼에서 entry_point_info_t를 얻고 security state를 검사한 뒤 현재 CPU context를 채우고 EL3 exit을 준비한다. main:275–334
반환 뒤의 assembly exit
bl31_main()이 돌아오면 assembly는 data, bss, per-CPU 범위를 main memory로 clean하고 el3_exit으로 분기한다. 이는 다른 CPU가 일관된 초기화 상태를 보게 하기 위한 단계다. entrypoint.S:84–125
DEEP DIVE
서비스 등록과 다음 세계 진입의 판단점
런타임 서비스는 linker descriptor와 init 결과에 달려 있다
runtime_svc_init()는 descriptor 수가 0이면 돌아간다. 그렇지 않으면 index 배열을 invalid 상태로 만들고 각 descriptor의 OEN 범위, call type, 함수 포인터를 검사한다. 유효성 실패는 panic이다. init callback이 실패한 descriptor는 index를 채우지 않고 다음 항목으로 진행한다. 성공한 범위만 OEN/call-type index를 채운다. 따라서 단순히 이미지에 서비스 코드가 들어 있다는 이유만으로 SMC가 처리된다고 말할 수 없다.
BL32와 RMM 초기화와 첫 BL33 진입은 서로 다른 결정이다
BL32 hook은 SPD가 등록할 수 있고, RMM hook은 RME/RMMD 구성에서 별도로 등록된다. 둘 다 bl31_main()의 선택적 초기화 단계다. 다음 ERET의 목표는 next_image_type과 플랫폼이 제공한 entry descriptor로 결정한다. BL32가 존재한다는 사실만으로 모든 빌드의 첫 목적지가 BL32라고 단정하지 않는다.
CPU_ON warm 경로는 cold setup을 재실행하지 않는다
bl31_warm_entrypoint는 bl31_warmboot()를 부르고, 후자는 CPU별 확장을 준비한 뒤 psci_warmboot_entrypoint(core_pos)로 넘긴다. 이 경로의 결과는 Linux CPU_ON 요청의 대상 CPU context와 연관되지만, runtime_svc_init()와 BL32/RMM cold hook을 다시 순회하는 것은 아니다. Linux 쪽 흐름
ADVANCED ANALYSIS
조건부 서비스와 이미지 진입을 소스에서 판정하기
여기서 continue는 BL31 전체 초기화 종료가 아니라 해당 descriptor의 index 등록을 건너뛰는 제어 흐름이다. runtime_svc.c:90–155
버전·플랫폼 경계. RESET_TO_BL31, GIC/DSU/EHF, SPD와 ENABLE_RME는 모두 구성에 따른다. BL32/RMM/BL33 바이너리가 어느 저장 형식에 들어가는지도 플랫폼 빌드 산출물로 확인한다. FIP가 항상 세 이미지를 포함한다고 가정하지 않는다.
| 조건 | 바뀌는 단계 | 고정 원문의 확인점 |
|---|---|---|
RESET_TO_BL31 | cold assembly 공통 진입 설정 | entrypoint.S:36–72 |
| SPD 등록 hook | 선택적 BL32 초기화와 next-image 유형 변경 가능 | main:191–203, 275–289 |
ENABLE_RME + RMMD hook | BL32 분기 뒤 선택적 RMM 초기화 | main:207–218 |
| runtime descriptor init | 각 service index 등록 여부 | runtime_svc:116–152 |
NUMA PER-CPU PLACEMENT
CPU별 자료의 주소 계산과 노드 배치는 다른 책임입니다
이 절은 TF-A LTS v2.14.6의 per-CPU 구현을 추가로 읽습니다. 앞선 v2.14.3 진입·서비스 분석의 버전을 바꾸는 것은 아닙니다. 여러 노드의 CPU별 자료를 한 노드에 모으면 원격 메모리 접근이 늘거나 해당 노드의 저장 용량이 부족할 수 있습니다. NUMA per-CPU 프레임워크는 같은 객체 배치를 노드별 메모리에 둘 수 있게 하지만, 실제 메모리와 주소 매핑은 플랫폼이 제공해야 합니다.
PER_CPU_DEFINE()는 객체를 .per_cpu에 넣습니다. 객체 이름의 링크 주소가 모든 CPU가 공유할 실제 객체 주소라는 뜻은 아닙니다. 객체의 상대 위치를 O(name) = link_address(name) - __PER_CPU_START__로 구하고, CPU별 기준 주소 B(cpu)에 더합니다. 즉 address(cpu, name) = B(cpu) + O(name)입니다. 현재 CPU를 읽는 AArch64 경로는 TPIDR_EL3를 기준으로 사용합니다.
| 단계 | 구현에서 정하는 것 | 그것만으로 보장하지 않는 것 |
|---|---|---|
| 링커 배치 | PER_CPU 매크로가 객체 묶음과 CPU 한 개의 unit 크기를 정하고 노드 내 CPU 수만큼 공간을 예약 | 임의의 런타임 할당이나 모든 전역 변수의 자동 분산 |
| CPU별 기준 주소 | 단일 노드는 시작 주소에 CPU index × unit 크기를 더함. NUMA는 plat_per_cpu_base()에 위임 | 플랫폼 hook이 사용할 메모리와 매핑을 자동으로 생성 |
| 현재 CPU 접근 | per_cpu_init가 기준 주소를 TPIDR_EL3에 설정하고 PER_CPU_CUR()가 객체 offset을 더함 | 다른 CPU의 객체를 읽거나 CPU 간 변경을 자동 동기화 |
| 초기화 | C runtime 준비가 로컬 영역을 0으로 채우고, 다중 노드 구성에서는 유효한 원격 노드 영역도 초기화 | 초깃값 있는 자료를 복제하거나 실행 중 객체를 이동·회수 |
링커의 .per_cpu (NOLOAD)는 section 시작과 CPU unit 끝을 CACHE_WRITEBACK_GRANULE에 맞춥니다. 각 변수에 항상 64바이트를 배정한다는 규칙이 아닙니다. 반면 원격 노드 영역의 시작·크기를 페이지 단위에 맞추라는 문서의 요구는 translation-table 매핑을 위한 것입니다. 캐시 단위의 CPU 간 간격과 매핑 단위의 영역 정렬을 구분합니다. 이것은 Linux 커널 이미지의 2MiB 적재 정렬 조건과도 별개입니다.
PLATFORM_NODE_COUNT의 기본값은 1이며, 2 이상인 NUMA 구성은 AArch64 플랫폼의 배치 지원을 요구합니다. PER_CPU_NODE_CORE_COUNT는 전체 CPU 수를 노드 수로 나눈 값이므로 플랫폼의 실제 노드·CPU 번호 배치가 이 모델과 맞아야 합니다. plat_per_cpu_node_base()가 없는 노드를 UINT64_MAX로 반환하면 초기화 루프는 그 노드를 건너뜁니다. 플랫폼이 제공하는 유효한 영역은 초기화·매핑 대상 크기를 충족해야 합니다.
메모리를 가까이 배치하는 것과 변경 내용이 다른 관찰자에게 보이는 것은 별개입니다. 문서는 플랫폼의 plat_per_cpu_dcache_clean() 책임도 구분합니다. 실제 캐시 유지 동작이 필요한지는 플랫폼의 일관성 조건에 따릅니다. 이 소스 검토는 특정 보드의 매핑, 캐시 일관성 또는 성능 향상을 실측했다는 뜻이 아닙니다. Linux의 NUMA page allocator를 BL31에 그대로 적용한 기능도 아닙니다.
English summary
The LTS v2.14.6 per-CPU framework combines a linker-defined object offset with a CPU-specific base. AArch64 current-CPU access uses TPIDR_EL3; NUMA bases and mapping are platform contracts. Cache-granule padding between CPU units is distinct from page alignment of remote regions. Boot initialization zeroes valid regions and skips absent nodes. This is source analysis, not firmware execution or a performance measurement.
고정 원문: NUMA per-CPU 설계, 객체·offset 매크로, 노드별 CPU 수, C 주소 계산, CPU별 기준 주소, 현재 CPU 초기화, 링커 unit 배치, BL31 section 순서, 로컬·원격 초기화.
OBJECTS
이름이 비슷해도 다른 수명과 소유권
| 객체 | 만들거나 제공하는 곳 | 사용 지점 | 수명 판단 |
|---|---|---|---|
| BL31 image·EL3 runtime | linker·플랫폼 적재 | cold boot 뒤 SMC/PSCI | resident 범위는 다음 세계 실행 중 보존 |
rt_svc_descs_indices | runtime_svc_init() | SMC dispatch | 성공 등록된 OEN/call-type index만 유효 |
| CPU별 context | cm_init() 및 context 준비 | EL3 전환·warm boot | CPU와 security state를 분리해 관리 |
entry_point_info_t | 플랫폼 next-image 조회 | cm_init_my_context() | 다음 이미지 진입 정보, BL31 resident 본체가 아님 |
| BL32/RMM init hook | SPD/RMMD가 조건부 등록 | cold main 선택 분기 | 미등록이면 호출하지 않음 |
__init 코드 | 빌드·linker 배치 | cold 초기화 | 실제 회수 가능 범위는 플랫폼 map으로 검증 |
FAILURE PATH
로그가 비슷해도 서로 다른 실패
| 조건 | 이 소스의 처리 | 먼저 대조할 곳 |
|---|---|---|
| runtime descriptor 형식 오류 | 오류 로그 뒤 panic() | OEN 범위·call type·init/handle 포인터 |
| service init callback 비0 | 오류 로그와 continue; 해당 index 미등록 | 서비스별 init 반환값과 이후 SMC 조회 |
| BL32/RMM init hook 0 반환 | 경고 후 main의 다음 단계 진행 | hook 구현과 후속 next-image 유형 |
| next image 정보 없음/상태 불일치 | assert 조건 위반 | 플랫폼 bl31_plat_get_next_image_ep_info 결과 |
| 첫 CPU는 되나 CPU_ON 실패 | cold path와 다른 warm/PSCI 경로 조사 | bl31_warm_entrypoint·psci_warmboot_entrypoint |
첫 로그의 위치만으로 BL32가 필수였거나 모든 runtime service가 등록됐다고 추론하지 않는다. 조건부 빌드 값과 성공 index를 같이 확인한다.
EVIDENCE
빌드 산출물과 보드 로그에서 확인할 것
아래는 실제 도구·산출물이 있을 때 적용할 읽기 중심 점검 방법이다. 이 검토 작업은 TF-A 빌드나 EL3 실행을 수행하지 않았다. <platform>과 툴체인 접두사는 대상 환경에 맞춘다.
| 자료 | 예시 명령·관찰 | 확인 범위 |
|---|---|---|
| BL31 ELF symbol | ${CROSS_COMPILE}nm -n build/<platform>/debug/bl31/bl31.elf | grep -E ' (bl31_main|bl31_entrypoint|el3_exit)$' | C 선언 문자열 대신 실제 symbol 이름·주소 확인 |
| ELF section/map | ${CROSS_COMPILE}readelf -SW build/<platform>/debug/bl31/bl31.elf와 해당 bl31.map | resident/init section 배치와 플랫폼 메모리 맵 대조 |
| assembly 경계 | ${CROSS_COMPILE}objdump -dr build/<platform>/debug/bl31/bl31.elf | bl31_main 호출과 assembly exit 경로 확인 |
| FIP가 생성된 플랫폼 | tools/fiptool/fiptool info build/<platform>/debug/fip.bin | 실재하는 image 항목만 확인; BL32·RMM·BL33 동봉은 구성 의존 |
| 대상 보드 serial log | BL31 banner, service init 오류, BL32/RMM 초기화, next world 선택 | 빌드 구성과 실제 실행의 차이 확인; 추가 register 계측은 별도 instrumentation 필요 |
LAB
재현 가능한 세 가지 확인
- 01ELF와 map의 resident 경계
nm으로bl31_main·bl31_entrypoint·el3_exitsymbol을 찾고readelf -SW및 플랫폼 map과 대조한다.__init이라는 이름만으로 물리 메모리 재사용을 단정하지 않는다. - 02런타임 서비스의 성공 여부
descriptor 유효성 실패와 init callback 실패를 다른 결과로 기록한다. 오류 로그만으로 panic인지 continue인지 판단하지 말고
runtime_svc.c의 분기 및 실제 활성 index를 확인한다. - 03cold/warm 및 선택적 image
사용한
RESET_TO_BL31, SPD,ENABLE_RME를 먼저 적고 cold serial log와 CPU_ON warm log를 따로 본다. BL32·RMM hook 유무와 마지막 next-image security state를 비교한다.
PRIMARY REFERENCES
원문과 다음 글
EL3 SPMC 구성에서 BL31이 중재하는 범위
아래는 기존 LTS 2.14.3 발췌와 구분한 TF-A v2.15.0 EL3 SPMC 참조 구성입니다. SPMD와 SPMC가 BL31에 포함되고 S-EL2 가상화 없이 단일 S-EL1 Secure Partition을 관리합니다. 문서의 SECURE_PARTITION_COUNT는 1이며, 별도로 지원하는 EL3 Logical Secure Partition을 여러 S-EL1 partition과 혼동하지 않습니다.
BL2는 SPMC manifest를 TOS_FW_CONFIG 이미지로 적재해 주소를 BL31로 넘깁니다. primary core의 SPMD가 초기화하면서 X0에는 manifest 주소, X4에는 현재 core의 linear ID를 전달합니다. 이 준비와 FVP 실행 예제를 다른 SoC에서 검증된 부팅 절차로 옮겨 쓰지는 않습니다.
FF-A 메시지·memory share/lend 요청은 임의의 주소에 대한 접근 허가가 아닙니다. 플랫폼의 plat_spmc_shmem_begin은 최초 공유 요청 완료 전에, plat_spmc_shmem_reclaim은 최종 반환 완료 뒤에 호출됩니다. 플랫폼은 필요한 메모리 접근 제어를 구현하고, transaction descriptor를 추적하는 datastore도 secure memory에 제공해야 합니다. 메시지 전달, 메모리 소유권·수명, 하드웨어 접근 제어를 각각 확인해야 합니다.
일반 OPTEED의 BL32 초기화와 이 FF-A 구성을 같은 호출열로 그리지 않습니다. 보안 인터럽트 전달 역시 이 구성의 문서화된 실행 상태에 한정되며, 모든 interrupt나 partition 조합을 지원한다는 뜻은 아닙니다. 이 절은 구성 경계 설명이며 FVP나 보드 실행 결과는 아닙니다.