]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Disable fields that KVM doesn't know how to handle in ID_AA64PFR1_EL1
authorShaoqin Huang <shahuang@redhat.com>
Tue, 23 Jul 2024 07:20:00 +0000 (03:20 -0400)
committerMarc Zyngier <maz@kernel.org>
Sun, 25 Aug 2024 16:48:43 +0000 (17:48 +0100)
For some of the fields in the ID_AA64PFR1_EL1 register, KVM doesn't know
how to handle them right now. So explicitly disable them in the register
accessor, then those fields value will be masked to 0 even if on the
hardware the field value is 1. This is safe because from a UAPI point of
view that read_sanitised_ftr_reg() doesn't yet return a nonzero value
for any of those fields.

This will benifit the migration if the host and VM have different values
when restoring a VM.

Those fields include RNDR_trap, NMI, MTE_frac, GCS, THE, MTEX, DF2, PFAR.

Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Link: https://lore.kernel.org/r/20240723072004.1470688-2-shahuang@redhat.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/sys_regs.c

index 5a49e8331fbf587472d53f7adc7448242a254228..0d983c1b859bd6af71106e058d66274d66ec0413 100644 (file)
@@ -1538,6 +1538,14 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu,
                        val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE);
 
                val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_SME);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_RNDR_trap);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_NMI);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE_frac);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_GCS);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_THE);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTEX);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_DF2);
+               val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_PFAR);
                break;
        case SYS_ID_AA64ISAR1_EL1:
                if (!vcpu_has_ptrauth(vcpu))