mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
UPSTREAM: KVM: arm64: Extract __do_hyp_init into a helper function
In preparation for adding a CPU entry point in nVHE hyp code, extract
most of __do_hyp_init hypervisor initialization code into a common
helper function. This will be invoked by the entry point to install KVM
on the newly booted CPU.
Signed-off-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201202184122.26046-20-dbrazdil@google.com
(cherry picked from commit f74e1e2128)
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I9c295736ba41cb5bfba2760a53bc9b06940e4f87
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
This commit is contained in:
committed by
Will Deacon
parent
43d3471491
commit
3d976ad764
@@ -68,17 +68,36 @@ __do_hyp_init:
|
||||
mov x0, #SMCCC_RET_NOT_SUPPORTED
|
||||
eret
|
||||
|
||||
1: ldr x0, [x1, #NVHE_INIT_TPIDR_EL2]
|
||||
msr tpidr_el2, x0
|
||||
1: mov x0, x1
|
||||
mov x4, lr
|
||||
bl ___kvm_hyp_init
|
||||
mov lr, x4
|
||||
|
||||
ldr x0, [x1, #NVHE_INIT_MAIR_EL2]
|
||||
msr mair_el2, x0
|
||||
/* Hello, World! */
|
||||
mov x0, #SMCCC_RET_SUCCESS
|
||||
eret
|
||||
SYM_CODE_END(__kvm_hyp_init)
|
||||
|
||||
ldr x0, [x1, #NVHE_INIT_STACK_HYP_VA]
|
||||
mov sp, x0
|
||||
/*
|
||||
* Initialize the hypervisor in EL2.
|
||||
*
|
||||
* Only uses x0..x3 so as to not clobber callee-saved SMCCC registers
|
||||
* and leave x4 for the caller.
|
||||
*
|
||||
* x0: struct kvm_nvhe_init_params PA
|
||||
*/
|
||||
SYM_CODE_START_LOCAL(___kvm_hyp_init)
|
||||
ldr x1, [x0, #NVHE_INIT_TPIDR_EL2]
|
||||
msr tpidr_el2, x1
|
||||
|
||||
ldr x0, [x1, #NVHE_INIT_PGD_PA]
|
||||
phys_to_ttbr x2, x0
|
||||
ldr x1, [x0, #NVHE_INIT_STACK_HYP_VA]
|
||||
mov sp, x1
|
||||
|
||||
ldr x1, [x0, #NVHE_INIT_MAIR_EL2]
|
||||
msr mair_el2, x1
|
||||
|
||||
ldr x1, [x0, #NVHE_INIT_PGD_PA]
|
||||
phys_to_ttbr x2, x1
|
||||
alternative_if ARM64_HAS_CNP
|
||||
orr x2, x2, #TTBR_CNP_BIT
|
||||
alternative_else_nop_endif
|
||||
@@ -87,9 +106,9 @@ alternative_else_nop_endif
|
||||
/*
|
||||
* Set the PS bits in TCR_EL2.
|
||||
*/
|
||||
ldr x0, [x1, #NVHE_INIT_TCR_EL2]
|
||||
tcr_compute_pa_size x0, #TCR_EL2_PS_SHIFT, x1, x2
|
||||
msr tcr_el2, x0
|
||||
ldr x1, [x0, #NVHE_INIT_TCR_EL2]
|
||||
tcr_compute_pa_size x1, #TCR_EL2_PS_SHIFT, x2, x3
|
||||
msr tcr_el2, x1
|
||||
|
||||
isb
|
||||
|
||||
@@ -117,10 +136,8 @@ alternative_else_nop_endif
|
||||
kimg_hyp_va x0, x1
|
||||
msr vbar_el2, x0
|
||||
|
||||
/* Hello, World! */
|
||||
mov x0, #SMCCC_RET_SUCCESS
|
||||
eret
|
||||
SYM_CODE_END(__kvm_hyp_init)
|
||||
ret
|
||||
SYM_CODE_END(___kvm_hyp_init)
|
||||
|
||||
SYM_CODE_START(__kvm_handle_stub_hvc)
|
||||
cmp x0, #HVC_SOFT_RESTART
|
||||
|
||||
Reference in New Issue
Block a user