]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: arm64: Fix FEAT_MTE in pKVM
authorVladimir Murzin <vladimir.murzin@arm.com>
Mon, 6 Jan 2025 11:24:21 +0000 (11:24 +0000)
committerMarc Zyngier <maz@kernel.org>
Wed, 8 Jan 2025 10:24:32 +0000 (10:24 +0000)
Make sure we do not trap access to Allocation Tags.

Fixes: b56680de9c64 ("KVM: arm64: Initialize trap register values in hyp in pKVM")
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Reviewed-by: Fuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20250106112421.65355-1-vladimir.murzin@arm.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/nvhe/pkvm.c

index 4b2622f8e250c3a2d0a76edc094430c6e1c5bca9..f76adddc52de849914ad814036331b757ce1e16a 100644 (file)
@@ -47,6 +47,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;
 }
 
 static void pvm_init_traps_hcr(struct kvm_vcpu *vcpu)
@@ -251,6 +254,9 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc
        unsigned long host_arch_flags = READ_ONCE(host_kvm->arch.flags);
        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)) {
                hyp_vm->kvm.arch.flags = host_arch_flags;