aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Roberts <[email protected]>2022-10-27 13:09:45 +0100
committerMarc Zyngier <[email protected]>2022-10-27 19:49:40 +0100
commitb6bcdc9f6b8321e4471ff45413b6410e16762a8d (patch)
treef67bb883abd47c37f7a9d1914395469c043e01ad
parent6853a71726b6f5930b4450889faf02e8f1cfe35c (diff)
KVM: arm64: Fix bad dereference on MTE-enabled systems
enter_exception64() performs an MTE check, which involves dereferencing vcpu->kvm. While vcpu has already been fixed up to be a HYP VA pointer, kvm is still a pointer in the kernel VA space. This only affects nVHE configurations with MTE enabled, as in other cases, the pointer is either valid (VHE) or not dereferenced (!MTE). Fix this by first converting kvm to a HYP VA pointer. Fixes: ea7fc1bb1cd1 ("KVM: arm64: Introduce MTE VM feature") Signed-off-by: Ryan Roberts <[email protected]> Reviewed-by: Steven Price <[email protected]> [maz: commit message tidy-up] Signed-off-by: Marc Zyngier <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
-rw-r--r--arch/arm64/kvm/hyp/exception.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/arm64/kvm/hyp/exception.c b/arch/arm64/kvm/hyp/exception.c
index b7557b25ed56..791d3de76771 100644
--- a/arch/arm64/kvm/hyp/exception.c
+++ b/arch/arm64/kvm/hyp/exception.c
@@ -13,6 +13,7 @@
#include <hyp/adjust_pc.h>
#include <linux/kvm_host.h>
#include <asm/kvm_emulate.h>
+#include <asm/kvm_mmu.h>
#if !defined (__KVM_NVHE_HYPERVISOR__) && !defined (__KVM_VHE_HYPERVISOR__)
#error Hypervisor code only!
@@ -115,7 +116,7 @@ static void enter_exception64(struct kvm_vcpu *vcpu, unsigned long target_mode,
new |= (old & PSR_C_BIT);
new |= (old & PSR_V_BIT);
- if (kvm_has_mte(vcpu->kvm))
+ if (kvm_has_mte(kern_hyp_va(vcpu->kvm)))
new |= PSR_TCO_BIT;
new |= (old & PSR_DIT_BIT);