KVM: arm64: Fix bad dereference on MTE-enabled systems.
PATCH 1/1 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 for hyp va, kvm is still a kern va pointer.
Fix this by first converting kvm to a hyp va pointer. If the system does not support MTE, the dereference is avoided in the first place.
--- arch/arm64/kvm/hyp/exception.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/exception.c +2 -1
@@ -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 );
--
2.17.1
Quoted 10 lines · Ryan Roberts
enter_exception64()performs an MTE check, which involves dereferencingvcpu->kvm. While vcpu has already been fixed up for hyp va, kvm is still a kern va pointer.Fix this by first converting kvm to a hyp va pointer. If the system does not support MTE, the dereference is avoided in the first place.
Fixes ea7fc1bb1cd1 ("KVM: arm64: Introduce MTE VM feature")Signed-off-by Ryan Roberts <[email protected]>
It's worth pointing out this only affects non-VHE mode, which is unusual on hardware which supports MTE (and therefore VHE). But, of course, about to get more usual with pKVM.
Quoted 28 lines
--- arch/arm64/kvm/hyp/exception.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm64/kvm/hyp/exception.c +2
-2@@ -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 ); --2.17.1
Quoted 8 lines · Ryan Roberts
enter_exception64()performs an MTE check, which involves dereferencingvcpu->kvm. While vcpu has already been fixed up for hyp va, kvm is still a kern va pointer.Fix this by first converting kvm to a hyp va pointer. If the system does not support MTE, the dereference is avoided in the first place.
[...]
Applied to fixes with minor commit message fixes, thanks!
[1/1] KVM: arm64: Fix bad dereference on MTE-enabled systems.
commit: b6bcdc9f6b8321e4471ff45413b6410e16762a8d
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.