]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: arm64: Expose the WFXT feature to guests
authorMarc Zyngier <maz@kernel.org>
Tue, 19 Apr 2022 18:27:52 +0000 (19:27 +0100)
committerMarc Zyngier <maz@kernel.org>
Wed, 20 Apr 2022 12:24:45 +0000 (13:24 +0100)
Plumb in the capability, and expose WFxT to guests when available.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20220419182755.601427-8-maz@kernel.org
arch/arm64/kernel/cpufeature.c
arch/arm64/kvm/sys_regs.c

index a6db8ca04429393d8df9b4d42af68325bb1c0abc..945190ebadd5b9596b173cd5d19f1df670537d98 100644 (file)
@@ -2443,6 +2443,17 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .matches = has_cpuid_feature,
                .min_field_value = 1,
        },
+       {
+               .desc = "WFx with timeout",
+               .capability = ARM64_HAS_WFXT,
+               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
+               .sys_reg = SYS_ID_AA64ISAR2_EL1,
+               .sign = FTR_UNSIGNED,
+               .field_pos = ID_AA64ISAR2_WFXT_SHIFT,
+               .field_width = 4,
+               .matches = has_cpuid_feature,
+               .min_field_value = ID_AA64ISAR2_WFXT_SUPPORTED,
+       },
        {},
 };
 
index 7b45c040cc27f37ab5c21050f5f75c35a52fffae..cc9a77546cc01002b36c2f69256438c45088d2d9 100644 (file)
@@ -1144,6 +1144,8 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,
                if (!vcpu_has_ptrauth(vcpu))
                        val &= ~(ARM64_FEATURE_MASK(ID_AA64ISAR2_APA3) |
                                 ARM64_FEATURE_MASK(ID_AA64ISAR2_GPA3));
+               if (!cpus_have_final_cap(ARM64_HAS_WFXT))
+                       val &= ~ARM64_FEATURE_MASK(ID_AA64ISAR2_WFXT);
                break;
        case SYS_ID_AA64DFR0_EL1:
                /* Limit debug to ARMv8.0 */