Commit f74e1e21 authored by David Brazdil's avatar David Brazdil Committed by Marc Zyngier

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: default avatarDavid Brazdil <dbrazdil@google.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201202184122.26046-20-dbrazdil@google.com
parent 1fd12b7e
...@@ -68,17 +68,36 @@ __do_hyp_init: ...@@ -68,17 +68,36 @@ __do_hyp_init:
mov x0, #SMCCC_RET_NOT_SUPPORTED mov x0, #SMCCC_RET_NOT_SUPPORTED
eret eret
1: ldr x0, [x1, #NVHE_INIT_TPIDR_EL2] 1: mov x0, x1
msr tpidr_el2, x0 mov x4, lr
bl ___kvm_hyp_init
mov lr, x4
ldr x0, [x1, #NVHE_INIT_MAIR_EL2] /* Hello, World! */
msr mair_el2, x0 mov x0, #SMCCC_RET_SUCCESS
eret
SYM_CODE_END(__kvm_hyp_init)
/*
* 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 x1, [x0, #NVHE_INIT_STACK_HYP_VA]
mov sp, x1
ldr x0, [x1, #NVHE_INIT_STACK_HYP_VA] ldr x1, [x0, #NVHE_INIT_MAIR_EL2]
mov sp, x0 msr mair_el2, x1
ldr x0, [x1, #NVHE_INIT_PGD_PA] ldr x1, [x0, #NVHE_INIT_PGD_PA]
phys_to_ttbr x2, x0 phys_to_ttbr x2, x1
alternative_if ARM64_HAS_CNP alternative_if ARM64_HAS_CNP
orr x2, x2, #TTBR_CNP_BIT orr x2, x2, #TTBR_CNP_BIT
alternative_else_nop_endif alternative_else_nop_endif
...@@ -87,9 +106,9 @@ alternative_else_nop_endif ...@@ -87,9 +106,9 @@ alternative_else_nop_endif
/* /*
* Set the PS bits in TCR_EL2. * Set the PS bits in TCR_EL2.
*/ */
ldr x0, [x1, #NVHE_INIT_TCR_EL2] ldr x1, [x0, #NVHE_INIT_TCR_EL2]
tcr_compute_pa_size x0, #TCR_EL2_PS_SHIFT, x1, x2 tcr_compute_pa_size x1, #TCR_EL2_PS_SHIFT, x2, x3
msr tcr_el2, x0 msr tcr_el2, x1
isb isb
...@@ -117,10 +136,8 @@ alternative_else_nop_endif ...@@ -117,10 +136,8 @@ alternative_else_nop_endif
kimg_hyp_va x0, x1 kimg_hyp_va x0, x1
msr vbar_el2, x0 msr vbar_el2, x0
/* Hello, World! */ ret
mov x0, #SMCCC_RET_SUCCESS SYM_CODE_END(___kvm_hyp_init)
eret
SYM_CODE_END(__kvm_hyp_init)
SYM_CODE_START(__kvm_handle_stub_hvc) SYM_CODE_START(__kvm_handle_stub_hvc)
cmp x0, #HVC_SOFT_RESTART cmp x0, #HVC_SOFT_RESTART
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment