@@ -1848,6 +1848,8 @@ static int __init parse_kpti(char *str)
1848
1848
early_param ("kpti" , parse_kpti );
1849
1849
1850
1850
#ifdef CONFIG_ARM64_HW_AFDBM
1851
+ static struct cpumask dbm_cpus __read_mostly ;
1852
+
1851
1853
static inline void __cpu_enable_hw_dbm (void )
1852
1854
{
1853
1855
u64 tcr = read_sysreg (tcr_el1 ) | TCR_HD ;
@@ -1883,35 +1885,22 @@ static bool cpu_can_use_dbm(const struct arm64_cpu_capabilities *cap)
1883
1885
1884
1886
static void cpu_enable_hw_dbm (struct arm64_cpu_capabilities const * cap )
1885
1887
{
1886
- if (cpu_can_use_dbm (cap ))
1888
+ if (cpu_can_use_dbm (cap )) {
1887
1889
__cpu_enable_hw_dbm ();
1890
+ cpumask_set_cpu (smp_processor_id (), & dbm_cpus );
1891
+ }
1888
1892
}
1889
1893
1890
1894
static bool has_hw_dbm (const struct arm64_cpu_capabilities * cap ,
1891
1895
int __unused )
1892
1896
{
1893
- static bool detected = false;
1894
1897
/*
1895
1898
* DBM is a non-conflicting feature. i.e, the kernel can safely
1896
1899
* run a mix of CPUs with and without the feature. So, we
1897
1900
* unconditionally enable the capability to allow any late CPU
1898
1901
* to use the feature. We only enable the control bits on the
1899
- * CPU, if it actually supports.
1900
- *
1901
- * We have to make sure we print the "feature" detection only
1902
- * when at least one CPU actually uses it. So check if this CPU
1903
- * can actually use it and print the message exactly once.
1904
- *
1905
- * This is safe as all CPUs (including secondary CPUs - due to the
1906
- * LOCAL_CPU scope - and the hotplugged CPUs - via verification)
1907
- * goes through the "matches" check exactly once. Also if a CPU
1908
- * matches the criteria, it is guaranteed that the CPU will turn
1909
- * the DBM on, as the capability is unconditionally enabled.
1902
+ * CPU, if it is supported.
1910
1903
*/
1911
- if (!detected && cpu_can_use_dbm (cap )) {
1912
- detected = true;
1913
- pr_info ("detected: Hardware dirty bit management\n" );
1914
- }
1915
1904
1916
1905
return true;
1917
1906
}
@@ -2448,18 +2437,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
2448
2437
},
2449
2438
#ifdef CONFIG_ARM64_HW_AFDBM
2450
2439
{
2451
- /*
2452
- * Since we turn this on always, we don't want the user to
2453
- * think that the feature is available when it may not be.
2454
- * So hide the description.
2455
- *
2456
- * .desc = "Hardware pagetable Dirty Bit Management",
2457
- *
2458
- */
2440
+ .desc = "Hardware dirty bit management" ,
2459
2441
.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE ,
2460
2442
.capability = ARM64_HW_DBM ,
2461
2443
.matches = has_hw_dbm ,
2462
2444
.cpu_enable = cpu_enable_hw_dbm ,
2445
+ .cpus = & dbm_cpus ,
2463
2446
ARM64_CPUID_FIELDS (ID_AA64MMFR1_EL1 , HAFDBS , DBM )
2464
2447
},
2465
2448
#endif
0 commit comments