From 0856645276b8c9b60b2a4435691f1fe2df6160f5 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 7 Jul 2022 15:49:23 +0100 Subject: [PATCH] Revert "ANDROID: KVM: arm64: pkvm: Force injection of a data abort on NISV MMIO exit" This reverts commit 4132be368b1e07699040897e741df630458528bd. Bug: 233587962 Signed-off-by: Will Deacon Change-Id: Ia078dc3315657144a417a97d4d60c3e5fb507271 --- Documentation/virt/kvm/api.rst | 7 ------- arch/arm64/kvm/arm.c | 14 ++++---------- arch/arm64/kvm/mmio.c | 9 --------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 17057eef5573..a6729c8cf063 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -5782,13 +5782,6 @@ Note that KVM does not skip the faulting instruction as it does for KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state if it decides to decode and emulate the instruction. -This feature isn't available to protected VMs, as userspace does not -have access to the state that is required to perform the emulation. -Instead, a data abort exception is directly injected in the guest. -Note that although KVM_CAP_ARM_NISV_TO_USER will be reported if -queried outside of a protected VM context, the feature will not be -exposed if queried on a protected VM file descriptor. - :: /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 25fc104375b0..29dda78faf3e 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -100,13 +100,9 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, /* Capabilities without flags */ switch (cap->cap) { case KVM_CAP_ARM_NISV_TO_USER: - if (kvm_vm_is_protected(kvm)) { - r = -EINVAL; - } else { - r = 0; - set_bit(KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER, - &kvm->arch.flags); - } + r = 0; + set_bit(KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER, + &kvm->arch.flags); break; case KVM_CAP_ARM_MTE: mutex_lock(&kvm->lock); @@ -265,15 +261,13 @@ static int kvm_check_extension(struct kvm *kvm, long ext) case KVM_CAP_IMMEDIATE_EXIT: case KVM_CAP_VCPU_EVENTS: case KVM_CAP_ARM_IRQ_LINE_LAYOUT_2: + case KVM_CAP_ARM_NISV_TO_USER: case KVM_CAP_ARM_INJECT_EXT_DABT: case KVM_CAP_SET_GUEST_DEBUG: case KVM_CAP_VCPU_ATTRIBUTES: case KVM_CAP_PTP_KVM: r = 1; break; - case KVM_CAP_ARM_NISV_TO_USER: - r = !kvm || !kvm_vm_is_protected(kvm); - break; case KVM_CAP_SET_GUEST_DEBUG2: return KVM_GUESTDBG_VALID_MASK; case KVM_CAP_ARM_SET_DEVICE_ADDR: diff --git a/arch/arm64/kvm/mmio.c b/arch/arm64/kvm/mmio.c index db6630c70f8b..3dd38a151d2a 100644 --- a/arch/arm64/kvm/mmio.c +++ b/arch/arm64/kvm/mmio.c @@ -133,17 +133,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) /* * No valid syndrome? Ask userspace for help if it has * volunteered to do so, and bail out otherwise. - * - * In the protected VM case, there isn't much userspace can do - * though, so directly deliver an exception to the guest. */ if (!kvm_vcpu_dabt_isvalid(vcpu)) { - if (is_protected_kvm_enabled() && - kvm_vm_is_protected(vcpu->kvm)) { - kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu)); - return 1; - } - if (test_bit(KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER, &vcpu->kvm->arch.flags)) { run->exit_reason = KVM_EXIT_ARM_NISV;