Skip to contentSkip to conversation

KVM: arm64: Fix FEAT_MTE in pKVM

PATCH Applied Vladimir Murzin 4 participants 4 messages Jan 6, 2025 – Jan 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm64: Fix FEAT_MTE in pKVM

Make sure we do not trap access to Allocation Tags.

Fixes b56680de9c64 ("KVM: arm64: Initialize trap register values in hyp in pKVM")
---
 arch/arm64/kvm/hyp/nvhe/pkvm.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/kvm/hyp/nvhe/pkvm.c +6 -0
index 071993c16d..dd55bff6a6 100644
@@ -229,6 +229,9 @@ static void pkvm_vcpu_reset_hcr(struct kvm_vcpu *vcpu)
 
 	if (vcpu_has_ptrauth(vcpu))
 		vcpu->arch.hcr_el2 |= (HCR_API | HCR_APK);
+
+	if (kvm_has_mte(vcpu->kvm))
+		vcpu->arch.hcr_el2 |= HCR_ATA;
 }
 
 /*
@@ -332,6 +335,9 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc
 	struct kvm *kvm = &hyp_vm->kvm;
 	DECLARE_BITMAP(allowed_features, KVM_VCPU_MAX_FEATURES);
 
+	if (test_bit(KVM_ARCH_FLAG_MTE_ENABLED, &host_kvm->arch.flags))
+		set_bit(KVM_ARCH_FLAG_MTE_ENABLED, &kvm->arch.flags);
+
 	/* No restrictions for non-protected VMs. */
 	if (!kvm_vm_is_protected(kvm)) {
 		bitmap_copy(kvm->arch.vcpu_features,
Signature · 1 line
2.24.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Vladimir,

Quoted 5 lines · Vladimir Murzin

Make sure we do not trap access to Allocation Tags.

Fixes b56680de9c64 ("KVM: arm64: Initialize trap register values in hyp in pKVM")

Cheers,
/fuad

Quoted 31 lines
---
 arch/arm64/kvm/hyp/nvhe/pkvm.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/kvm/hyp/nvhe/pkvm.c +6 -1
index 071993c16d..dd55bff6a6 100644
@@ -229,6 +229,9 @@ static void pkvm_vcpu_reset_hcr(struct kvm_vcpu *vcpu)
 
        if (vcpu_has_ptrauth(vcpu))
                vcpu->arch.hcr_el2 |= (HCR_API | HCR_APK);
+
+       if (kvm_has_mte(vcpu->kvm))
+               vcpu->arch.hcr_el2 |= HCR_ATA;
 }
 
 /*
@@ -332,6 +335,9 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc
        struct kvm *kvm = &hyp_vm->kvm;
        DECLARE_BITMAP(allowed_features, KVM_VCPU_MAX_FEATURES);
 
+       if (test_bit(KVM_ARCH_FLAG_MTE_ENABLED, &host_kvm->arch.flags))
+               set_bit(KVM_ARCH_FLAG_MTE_ENABLED, &kvm->arch.flags);
+
        /* No restrictions for non-protected VMs. */
        if (!kvm_vm_is_protected(kvm)) {
                bitmap_copy(kvm->arch.vcpu_features,
--

2.24.0

maintainer Applied
#3 lore raw
In reply to Vladimir Murzin
Quoted 3 lines · Vladimir Murzin

Make sure we do not trap access to Allocation Tags.

Applied to next, thanks!

[1/1] KVM: arm64: Fix FEAT_MTE in pKVM

      commit: b7f345fbc32afab0f0b03c71c7eaf48b9a0ad7ed

Cheers,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.