1.前言
kernel版本:5.10
平台:arm64
本专题主要基于《arm64_linux head.S的执行流程》系列文章,前者是基于3.18,本专题针对的是内核5.10。主要分析head.S的执行过程。本文主要记录head.S的set_cpu_boot_mode_flag执行过程。
2.set_cpu_boot_mode_flag
/*
* Sets the __boot_cpu_mode flag depending on the CPU boot mode passed
* in w0. See arch/arm64/include/asm/virt.h for more info.
*/
SYM_FUNC_START_LOCAL(set_cpu_boot_mode_flag)
adr_l x1, __boot_cpu_mode
cmp w0, #BOOT_CPU_MODE_EL2
b.ne 1f
add x1, x1, #4
1: str w0, [x1] // This CPU has booted in EL1
dmb sy
dc ivac, x1 // Invalidate potentially stale cache line
ret
SYM_FUNC_END(set_cpu_boot_mode_flag)
__boot_cpu_mode保存了启动时的特权级别,定义如下:
/*
* __boot_cpu_mode records what mode CPUs were booted in.
* A correctly-implemented bootloader must start all CPUs in the same mode:
* In this case, both 32bit halves of __boot_cpu_mode will contain the
* same value (either 0 if booted in EL1, BOOT_CPU_MODE_EL2 if booted in EL2).
*
* Should the bootloader fail to do this, the two values will be different.
* This allows the kernel to flag an error when the secondaries have come up.
*/
extern u32 __boot_cpu_mode[2];
CPU的启动模式在el2_setup时保存到了w0中,此处将启动模式保存到__boot_cpu_mode中,如果启动模式为EL1则保存到__boot_cpu_mode[0],如果启动模式为EL2,则保存到__boot_cpu_mode[1]
本专题基于《arm64_linux head.S的执行流程》系列文章,针对内核5.10,分析head.S的执行过程。重点记录了head.S的set_cpu_boot_mode_flag执行过程,包括__boot_cpu_mode的定义,以及根据CPU启动模式将其保存到相应位置。

449

被折叠的 条评论
为什么被折叠?



