From 74ab599fa2d254376cb14e29af2084ecaf2eae9c Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 7 Jul 2022 15:51:19 +0100 Subject: [PATCH] Revert "ANDROID: KVM: arm64: pkvm: Introduce entry/exit handlers for non-protected guests" This reverts commit 20204f79dee37315ff7fc0db6c05264f78148e34. Bug: 233587962 Signed-off-by: Will Deacon Change-Id: I7baad7e1eac9ecb599c6d523fd63be35eae90d60 --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 49 +++--------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index 96940095fa07..1cacfb92cae9 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -351,32 +351,7 @@ static void handle_pvm_exit_dabt(struct kvm_vcpu *host_vcpu, struct kvm_vcpu *sh __vcpu_sys_reg(shadow_vcpu, SCTLR_EL1) & (SCTLR_ELx_EE | SCTLR_EL1_E0E)); } -static void handle_vm_entry_generic(struct kvm_vcpu *host_vcpu, struct kvm_vcpu *shadow_vcpu) -{ - unsigned long host_flags = READ_ONCE(host_vcpu->arch.flags); - - shadow_vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | - KVM_ARM64_EXCEPT_MASK); - - if (host_flags & KVM_ARM64_PENDING_EXCEPTION) { - shadow_vcpu->arch.flags |= KVM_ARM64_PENDING_EXCEPTION; - shadow_vcpu->arch.flags |= host_flags & KVM_ARM64_EXCEPT_MASK; - } else if (host_flags & KVM_ARM64_INCREMENT_PC) { - shadow_vcpu->arch.flags |= KVM_ARM64_INCREMENT_PC; - } -} - -static void handle_vm_exit_generic(struct kvm_vcpu *host_vcpu, struct kvm_vcpu *shadow_vcpu) -{ - host_vcpu->arch.fault.esr_el2 = shadow_vcpu->arch.fault.esr_el2; -} - -static void handle_vm_exit_abt(struct kvm_vcpu *host_vcpu, struct kvm_vcpu *shadow_vcpu) -{ - host_vcpu->arch.fault = shadow_vcpu->arch.fault; -} - -static const shadow_entry_exit_handler_fn entry_pvm_shadow_handlers[] = { +static const shadow_entry_exit_handler_fn entry_shadow_handlers[] = { [0 ... ESR_ELx_EC_MAX] = NULL, [ESR_ELx_EC_WFx] = handle_pvm_entry_wfx, [ESR_ELx_EC_HVC64] = handle_pvm_entry_hvc64, @@ -385,7 +360,7 @@ static const shadow_entry_exit_handler_fn entry_pvm_shadow_handlers[] = { [ESR_ELx_EC_DABT_LOW] = handle_pvm_entry_dabt, }; -static const shadow_entry_exit_handler_fn exit_pvm_shadow_handlers[] = { +static const shadow_entry_exit_handler_fn exit_shadow_handlers[] = { [0 ... ESR_ELx_EC_MAX] = NULL, [ESR_ELx_EC_WFx] = handle_pvm_exit_wfx, [ESR_ELx_EC_HVC64] = handle_pvm_exit_hvc64, @@ -394,16 +369,6 @@ static const shadow_entry_exit_handler_fn exit_pvm_shadow_handlers[] = { [ESR_ELx_EC_DABT_LOW] = handle_pvm_exit_dabt, }; -static const shadow_entry_exit_handler_fn entry_vm_shadow_handlers[] = { - [0 ... ESR_ELx_EC_MAX] = handle_vm_entry_generic, -}; - -static const shadow_entry_exit_handler_fn exit_vm_shadow_handlers[] = { - [0 ... ESR_ELx_EC_MAX] = handle_vm_exit_generic, - [ESR_ELx_EC_IABT_LOW] = handle_vm_exit_abt, - [ESR_ELx_EC_DABT_LOW] = handle_vm_exit_abt, -}; - static void flush_vgic_state(struct kvm_vcpu *host_vcpu, struct kvm_vcpu *shadow_vcpu) { @@ -495,10 +460,7 @@ static void flush_shadow_state(struct pkvm_loaded_state *state) break; case ARM_EXCEPTION_TRAP: esr_ec = ESR_ELx_EC(kvm_vcpu_get_esr(shadow_vcpu)); - if (state->is_protected) - ec_handler = entry_pvm_shadow_handlers[esr_ec]; - else - ec_handler = entry_vm_shadow_handlers[esr_ec]; + ec_handler = entry_shadow_handlers[esr_ec]; if (ec_handler) ec_handler(host_vcpu, shadow_vcpu); @@ -526,10 +488,7 @@ static void sync_shadow_state(struct pkvm_loaded_state *state, u32 exit_reason) break; case ARM_EXCEPTION_TRAP: esr_ec = ESR_ELx_EC(kvm_vcpu_get_esr(shadow_vcpu)); - if (state->is_protected) - ec_handler = exit_pvm_shadow_handlers[esr_ec]; - else - ec_handler = exit_vm_shadow_handlers[esr_ec]; + ec_handler = exit_shadow_handlers[esr_ec]; if (ec_handler) ec_handler(host_vcpu, shadow_vcpu);