KVM: arm64: pkvm: Pass vpcu instead of kvm to kvm_get_exit_handler_array()
authorMarc Zyngier <maz@kernel.org>
Wed, 13 Oct 2021 12:03:45 +0000 (13:03 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 18 Oct 2021 15:57:09 +0000 (16:57 +0100)
Passing a VM pointer around is odd, and results in extra work on
VHE. Follow the rest of the design that uses the vcpu instead, and
let the nVHE code look into the struct kvm as required.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20211013120346.2926621-11-maz@kernel.org
arch/arm64/kvm/hyp/include/hyp/switch.h
arch/arm64/kvm/hyp/nvhe/switch.c
arch/arm64/kvm/hyp/vhe/switch.c

index 4126926c3e06be8176b26758e6ce4e57f0ce5068..c6e98c7e918b198db8f708c8222257a76b36f9bc 100644 (file)
@@ -397,7 +397,7 @@ static bool kvm_hyp_handle_dabt_low(struct kvm_vcpu *vcpu, u64 *exit_code)
 
 typedef bool (*exit_handler_fn)(struct kvm_vcpu *, u64 *);
 
-static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm *kvm);
+static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu);
 
 /*
  * Allow the hypervisor to handle the exit with an exit handler if it has one.
@@ -407,7 +407,7 @@ static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm *kvm);
  */
 static inline bool kvm_hyp_handle_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
 {
-       const exit_handler_fn *handlers = kvm_get_exit_handler_array(kern_hyp_va(vcpu->kvm));
+       const exit_handler_fn *handlers = kvm_get_exit_handler_array(vcpu);
        exit_handler_fn fn;
 
        fn = handlers[kvm_vcpu_trap_get_class(vcpu)];
index be6889e33b2b668b3cfcdaa9cb2cc59c863f350f..50c7d48e0fa0bf0276a6b2a159f9e207ccc54210 100644 (file)
@@ -211,9 +211,9 @@ static const exit_handler_fn pvm_exit_handlers[] = {
        [ESR_ELx_EC_PAC]                = kvm_hyp_handle_ptrauth,
 };
 
-static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm *kvm)
+static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu)
 {
-       if (unlikely(kvm_vm_is_protected(kvm)))
+       if (unlikely(kvm_vm_is_protected(kern_hyp_va(vcpu->kvm))))
                return pvm_exit_handlers;
 
        return hyp_exit_handlers;
index f6fb97accf659191569ad450fd2f0f2e6c5e5a2d..5a2cb5d9bc4b22a55e7afb591962b741619c8446 100644 (file)
@@ -107,7 +107,7 @@ static const exit_handler_fn hyp_exit_handlers[] = {
        [ESR_ELx_EC_PAC]                = kvm_hyp_handle_ptrauth,
 };
 
-static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm *kvm)
+static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu)
 {
        return hyp_exit_handlers;
 }