Skip to content

Commit b6bcdc9

Browse files
Ryan RobertsMarc Zyngier
authored andcommitted
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: ea7fc1b ("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]
1 parent 6853a71 commit b6bcdc9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/arm64/kvm/hyp/exception.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <hyp/adjust_pc.h>
1414
#include <linux/kvm_host.h>
1515
#include <asm/kvm_emulate.h>
16+
#include <asm/kvm_mmu.h>
1617

1718
#if !defined (__KVM_NVHE_HYPERVISOR__) && !defined (__KVM_VHE_HYPERVISOR__)
1819
#error Hypervisor code only!
@@ -115,7 +116,7 @@ static void enter_exception64(struct kvm_vcpu *vcpu, unsigned long target_mode,
115116
new |= (old & PSR_C_BIT);
116117
new |= (old & PSR_V_BIT);
117118

118-
if (kvm_has_mte(vcpu->kvm))
119+
if (kvm_has_mte(kern_hyp_va(vcpu->kvm)))
119120
new |= PSR_TCO_BIT;
120121

121122
new |= (old & PSR_DIT_BIT);

0 commit comments

Comments
 (0)