From aaa1536fde6f64c2b14364d181558ab95e2747fb Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 7 Jul 2022 15:51:20 +0100 Subject: [PATCH] Revert "ANDROID: KVM: arm64: Introduce vcpu_is_protected() helper" This reverts commit 9c2007f6d5854b8e38b5a2d5b9a9978505c87ac4. Bug: 233587962 Signed-off-by: Will Deacon Change-Id: Iff965ea172cc70be200263b6bb3905e098d43b48 --- arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 8 -------- arch/arm64/kvm/hyp/nvhe/switch.c | 6 ++++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h index ddb64ba46aa4..8024006a32ad 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h +++ b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h @@ -52,14 +52,6 @@ struct kvm_shadow_vm { struct shadow_vcpu_state shadow_vcpus[0]; }; -static inline bool vcpu_is_protected(struct kvm_vcpu *vcpu) -{ - if (!is_protected_kvm_enabled()) - return false; - - return vcpu->arch.pkvm.shadow_vm->arch.pkvm.enabled; -} - extern struct kvm_shadow_vm **shadow_table; extern phys_addr_t pvmfw_base; diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index 87338775288c..8d18560ee015 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -216,7 +216,7 @@ static const exit_handler_fn pvm_exit_handlers[] = { static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu) { - if (unlikely(vcpu_is_protected(vcpu))) + if (unlikely(kvm_vm_is_protected(kern_hyp_va(vcpu->kvm)))) return pvm_exit_handlers; return hyp_exit_handlers; @@ -235,7 +235,9 @@ static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu) */ static void early_exit_filter(struct kvm_vcpu *vcpu, u64 *exit_code) { - if (unlikely(vcpu_is_protected(vcpu) && vcpu_mode_is_32bit(vcpu))) { + struct kvm *kvm = kern_hyp_va(vcpu->kvm); + + if (kvm_vm_is_protected(kvm) && vcpu_mode_is_32bit(vcpu)) { /* * As we have caught the guest red-handed, decide that it isn't * fit for purpose anymore by making the vcpu invalid. The VMM