Revert "FROMLIST: KVM: arm64: Pass pointer to __pkvm_init_switch_pgd"

Revert submission 3081516

Reason for revert: Cherry-picking corresponding FROMGIT commit

Reverted changes: /q/submissionid:3081516

Change-Id: Ide6c60bf1c43d4ad4f76e1e6a073df283dbc8323
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
This commit is contained in:
Pierre-Clément Tosi 2024-06-28 20:03:34 +00:00 committed by Will Deacon
parent 386f51645f
commit 16b7f3f996
3 changed files with 7 additions and 12 deletions

View File

@ -130,8 +130,7 @@ void __noreturn __hyp_do_panic(struct kvm_cpu_context *host_ctxt, u64 spsr,
#endif #endif
#ifdef __KVM_NVHE_HYPERVISOR__ #ifdef __KVM_NVHE_HYPERVISOR__
void __pkvm_init_switch_pgd(struct kvm_nvhe_init_params *params, void __pkvm_init_switch_pgd(phys_addr_t params, void (*finalize_fn)(void));
void (*finalize_fn)(void));
int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long nr_cpus, int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long nr_cpus,
unsigned long *per_cpu_base, u32 hyp_va_bits); unsigned long *per_cpu_base, u32 hyp_va_bits);
void __noreturn __host_enter(struct kvm_cpu_context *host_ctxt); void __noreturn __host_enter(struct kvm_cpu_context *host_ctxt);

View File

@ -276,15 +276,7 @@ alternative_else_nop_endif
SYM_CODE_END(__kvm_handle_stub_hvc) SYM_CODE_END(__kvm_handle_stub_hvc)
/*
* void __pkvm_init_switch_pgd(struct kvm_nvhe_init_params *params,
* void (*finalize_fn)(void));
*/
SYM_FUNC_START(__pkvm_init_switch_pgd) SYM_FUNC_START(__pkvm_init_switch_pgd)
/* Load the inputs from the VA pointer before turning the MMU off */
ldr x5, [x0, #NVHE_INIT_PGD_PA]
ldr x0, [x0, #NVHE_INIT_STACK_HYP_VA]
/* Turn the MMU off */ /* Turn the MMU off */
pre_disable_mmu_workaround pre_disable_mmu_workaround
mrs x2, sctlr_el2 mrs x2, sctlr_el2
@ -295,13 +287,15 @@ SYM_FUNC_START(__pkvm_init_switch_pgd)
tlbi alle2 tlbi alle2
/* Install the new pgtables */ /* Install the new pgtables */
phys_to_ttbr x4, x5 ldr x3, [x0, #NVHE_INIT_PGD_PA]
phys_to_ttbr x4, x3
alternative_if ARM64_HAS_CNP alternative_if ARM64_HAS_CNP
orr x4, x4, #TTBR_CNP_BIT orr x4, x4, #TTBR_CNP_BIT
alternative_else_nop_endif alternative_else_nop_endif
msr ttbr0_el2, x4 msr ttbr0_el2, x4
/* Set the new stack pointer */ /* Set the new stack pointer */
ldr x0, [x0, #NVHE_INIT_STACK_HYP_VA]
mov sp, x0 mov sp, x0
/* And turn the MMU back on! */ /* And turn the MMU back on! */

View File

@ -400,6 +400,7 @@ out:
int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long nr_cpus, int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long nr_cpus,
unsigned long *per_cpu_base, u32 hyp_va_bits) unsigned long *per_cpu_base, u32 hyp_va_bits)
{ {
struct kvm_nvhe_init_params *params;
void *virt = hyp_phys_to_virt(phys); void *virt = hyp_phys_to_virt(phys);
typeof(__pkvm_init_switch_pgd) *fn; typeof(__pkvm_init_switch_pgd) *fn;
int ret; int ret;
@ -427,8 +428,9 @@ int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long nr_cpus,
update_nvhe_init_params(); update_nvhe_init_params();
/* Jump in the idmap page to switch to the new page-tables */ /* Jump in the idmap page to switch to the new page-tables */
params = this_cpu_ptr(&kvm_init_params);
fn = (typeof(fn))__hyp_pa(__pkvm_init_switch_pgd); fn = (typeof(fn))__hyp_pa(__pkvm_init_switch_pgd);
fn(this_cpu_ptr(&kvm_init_params), __pkvm_init_finalise); fn(__hyp_pa(params), __pkvm_init_finalise);
unreachable(); unreachable();
} }