RK3588基于Linux kernel  L5.10.110

Linux git官方代码:​​Linux Kernel 5.10.110 released​

以上两个进行比较,原厂主要修改head.S和entry.S vmlinux.lds.S

vmlinux.lds.S主要增加KVM相关配置。

再Linux/arch/arm64/kernel/目录下对比查看有以下汇编进行修改:


head.S

RK3588汇编代码_运维

在__primary_switch中fdt传递,VHE

RK3588汇编代码_linux_02

增加了init_kernel_el替换掉el2_setup,并增加了switch_to_vhe

RK3588汇编代码_服务器_03

 __enable_mmu

RK3588汇编代码_git_04

init_kernel_el新增函数

/*
* end early head section, begin head code that is also used for
* hotplug and needs to have the same protections as the text region
*/
.section ".idmap.text","awx"

/*
* Starting from EL2 or EL1, configure the CPU to execute at the highest
* reachable EL supported by the kernel in a chosen default state. If dropping
* from EL2 to EL1, configure EL2 before configuring EL1.
*
* Since we cannot always rely on ERET synchronizing writes to sysregs (e.g. if
* SCTLR_ELx.EOS is clear), we place an ISB prior to ERET.
*
* Returns either BOOT_CPU_MODE_EL1 or BOOT_CPU_MODE_EL2 in w0 if
* booted in EL1 or EL2 respectively.
*/
SYM_FUNC_START(init_kernel_el)
mov_q x0, INIT_SCTLR_EL1_MMU_OFF
msr sctlr_el1, x0

mrs x0, CurrentEL
cmp x0, #CurrentEL_EL2
b.eq init_el2

SYM_INNER_LABEL(init_el1, SYM_L_LOCAL)
isb
mov_q x0, INIT_PSTATE_EL1
msr spsr_el1, x0
msr elr_el1, lr
mov w0, #BOOT_CPU_MODE_EL1
eret

SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
mov_q x0, HCR_HOST_NVHE_FLAGS
msr hcr_el2, x0
isb

init_el2_state

/* Hypervisor stub */
adr_l x0, __hyp_stub_vectors
msr vbar_el2, x0
isb

msr elr_el2, lr
mov w0, #BOOT_CPU_MODE_EL2
eret
SYM_FUNC_END(init_kernel_el)

entry.S