]> xenbits.xensource.com Git - people/julieng/linux-arm.git/commitdiff
arch/arm64: Introduce a capability to tell whether 16-bit VMID is available
authorJulien Grall <julien.grall@arm.com>
Tue, 23 Jul 2019 15:58:48 +0000 (16:58 +0100)
committerJulien Grall <julien.grall@arm.com>
Wed, 24 Jul 2019 16:18:26 +0000 (17:18 +0100)
At the moment, the function kvm_get_vmid_bits() is looking up for the
sanitized value of ID_AA64MMFR1_EL1 and extract the information
regarding the number of VMID bits supported.

This is fine as the function is mainly used during VMID roll-over. New
use in a follow-up patch will require the function to be called a every
context switch so we want the function to be more efficient.

A new capability is introduced to tell whether 16-bit VMID is
available.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
    Changes in v3:
        - Patch added

arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/kvm_mmu.h
arch/arm64/kernel/cpufeature.c

index f19fe4b9acc4d148c6e9ebb535be0b03e6f9b352..af8ab758b252b43bfb6f22c8e0742be794e8b0dd 100644 (file)
@@ -52,7 +52,8 @@
 #define ARM64_HAS_IRQ_PRIO_MASKING             42
 #define ARM64_HAS_DCPODP                       43
 #define ARM64_WORKAROUND_1463225               44
+#define ARM64_HAS_16BIT_VMID                   45
 
-#define ARM64_NCAPS                            45
+#define ARM64_NCAPS                            46
 
 #endif /* __ASM_CPUCAPS_H */
index befe37d4bc0e5c3990fa76042236671e20040567..2ce8055a84b8a18ec813d047186270937c416369 100644 (file)
@@ -413,9 +413,7 @@ static inline void __kvm_extend_hypmap(pgd_t *boot_hyp_pgd,
 
 static inline unsigned int kvm_get_vmid_bits(void)
 {
-       int reg = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1);
-
-       return (cpuid_feature_extract_unsigned_field(reg, ID_AA64MMFR1_VMIDBITS_SHIFT) == 2) ? 16 : 8;
+       return cpus_have_const_cap(ARM64_HAS_16BIT_VMID) ? 16 : 8;
 }
 
 /*
index f29f36a65175c2f0f318710d2909d7635c1f848b..b401e56af35a495d5c23697c630b1559f27213df 100644 (file)
@@ -1548,6 +1548,15 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .min_field_value = 1,
        },
 #endif
+       {
+               .capability = ARM64_HAS_16BIT_VMID,
+               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
+               .sys_reg = SYS_ID_AA64MMFR1_EL1,
+               .field_pos = ID_AA64MMFR1_VMIDBITS_SHIFT,
+               .sign = FTR_UNSIGNED,
+               .min_field_value = ID_AA64MMFR1_VMIDBITS_16,
+               .matches = has_cpuid_feature,
+       },
        {},
 };