@@ -1081,25 +1081,6 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
10811081
10821082 if (id_aa64pfr1_mte (info -> reg_id_aa64pfr1 ))
10831083 init_cpu_ftr_reg (SYS_GMID_EL1 , info -> reg_gmid );
1084-
1085- /*
1086- * Initialize the indirect array of CPU capabilities pointers before we
1087- * handle the boot CPU below.
1088- */
1089- init_cpucap_indirect_list ();
1090-
1091- /*
1092- * Detect broken pseudo-NMI. Must be called _before_ the call to
1093- * setup_boot_cpu_capabilities() since it interacts with
1094- * can_use_gic_priorities().
1095- */
1096- detect_system_supports_pseudo_nmi ();
1097-
1098- /*
1099- * Detect and enable early CPU capabilities based on the boot CPU,
1100- * after we have initialised the CPU feature infrastructure.
1101- */
1102- setup_boot_cpu_capabilities ();
11031084}
11041085
11051086static void update_cpu_ftr_reg (struct arm64_ftr_reg * reg , u64 new )
@@ -1584,16 +1565,6 @@ static bool has_useable_gicv3_cpuif(const struct arm64_cpu_capabilities *entry,
15841565 return has_sre ;
15851566}
15861567
1587- static bool has_no_hw_prefetch (const struct arm64_cpu_capabilities * entry , int __unused )
1588- {
1589- u32 midr = read_cpuid_id ();
1590-
1591- /* Cavium ThunderX pass 1.x and 2.x */
1592- return midr_is_cpu_model_range (midr , MIDR_THUNDERX ,
1593- MIDR_CPU_VAR_REV (0 , 0 ),
1594- MIDR_CPU_VAR_REV (1 , MIDR_REVISION_MASK ));
1595- }
1596-
15971568static bool has_cache_idc (const struct arm64_cpu_capabilities * entry ,
15981569 int scope )
15991570{
@@ -2321,12 +2292,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
23212292 ARM64_CPUID_FIELDS (ID_AA64ISAR0_EL1 , ATOMIC , IMP )
23222293 },
23232294#endif /* CONFIG_ARM64_LSE_ATOMICS */
2324- {
2325- .desc = "Software prefetching using PRFM" ,
2326- .capability = ARM64_HAS_NO_HW_PREFETCH ,
2327- .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE ,
2328- .matches = has_no_hw_prefetch ,
2329- },
23302295 {
23312296 .desc = "Virtualization Host Extensions" ,
23322297 .capability = ARM64_HAS_VIRT_HOST_EXTN ,
@@ -3271,14 +3236,6 @@ void check_local_cpu_capabilities(void)
32713236 verify_local_cpu_capabilities ();
32723237}
32733238
3274- static void __init setup_boot_cpu_capabilities (void )
3275- {
3276- /* Detect capabilities with either SCOPE_BOOT_CPU or SCOPE_LOCAL_CPU */
3277- update_cpu_capabilities (SCOPE_BOOT_CPU | SCOPE_LOCAL_CPU );
3278- /* Enable the SCOPE_BOOT_CPU capabilities alone right away */
3279- enable_cpu_capabilities (SCOPE_BOOT_CPU );
3280- }
3281-
32823239bool this_cpu_has_cap (unsigned int n )
32833240{
32843241 if (!WARN_ON (preemptible ()) && n < ARM64_NCAPS ) {
@@ -3334,44 +3291,82 @@ unsigned long cpu_get_elf_hwcap2(void)
33343291 return elf_hwcap [1 ];
33353292}
33363293
3337- void __init setup_system_features (void )
3294+ static void __init setup_boot_cpu_capabilities (void )
33383295{
3339- int i ;
33403296 /*
3341- * The system-wide safe feature feature register values have been
3342- * finalized. Finalize and log the available system capabilities.
3297+ * The boot CPU's feature register values have been recorded. Detect
3298+ * boot cpucaps and local cpucaps for the boot CPU, then enable and
3299+ * patch alternatives for the available boot cpucaps.
33433300 */
3344- update_cpu_capabilities (SCOPE_SYSTEM );
3345- if ( IS_ENABLED ( CONFIG_ARM64_SW_TTBR0_PAN ) &&
3346- ! cpus_have_cap ( ARM64_HAS_PAN ))
3347- pr_info ( "emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n" );
3301+ update_cpu_capabilities (SCOPE_BOOT_CPU | SCOPE_LOCAL_CPU );
3302+ enable_cpu_capabilities ( SCOPE_BOOT_CPU );
3303+ apply_boot_alternatives ();
3304+ }
33483305
3306+ void __init setup_boot_cpu_features (void )
3307+ {
33493308 /*
3350- * Enable all the available capabilities which have not been enabled
3351- * already .
3309+ * Initialize the indirect array of CPU capabilities pointers before we
3310+ * handle the boot CPU .
33523311 */
3353- enable_cpu_capabilities ( SCOPE_ALL & ~ SCOPE_BOOT_CPU );
3312+ init_cpucap_indirect_list ( );
33543313
3355- kpti_install_ng_mappings ();
3314+ /*
3315+ * Detect broken pseudo-NMI. Must be called _before_ the call to
3316+ * setup_boot_cpu_capabilities() since it interacts with
3317+ * can_use_gic_priorities().
3318+ */
3319+ detect_system_supports_pseudo_nmi ();
33563320
3357- sve_setup ();
3358- sme_setup ();
3321+ setup_boot_cpu_capabilities ();
3322+ }
33593323
3324+ static void __init setup_system_capabilities (void )
3325+ {
33603326 /*
3361- * Check for sane CTR_EL0.CWG value.
3327+ * The system-wide safe feature register values have been finalized.
3328+ * Detect, enable, and patch alternatives for the available system
3329+ * cpucaps.
33623330 */
3363- if (! cache_type_cwg ())
3364- pr_warn ( "No Cache Writeback Granule information, assuming %d\n" ,
3365- ARCH_DMA_MINALIGN );
3331+ update_cpu_capabilities ( SCOPE_SYSTEM );
3332+ enable_cpu_capabilities ( SCOPE_ALL & ~ SCOPE_BOOT_CPU );
3333+ apply_alternatives_all ( );
33663334
3367- for (i = 0 ; i < ARM64_NCAPS ; i ++ ) {
3335+ /*
3336+ * Log any cpucaps with a cpumask as these aren't logged by
3337+ * update_cpu_capabilities().
3338+ */
3339+ for (int i = 0 ; i < ARM64_NCAPS ; i ++ ) {
33683340 const struct arm64_cpu_capabilities * caps = cpucap_ptrs [i ];
33693341
33703342 if (caps && caps -> cpus && caps -> desc &&
33713343 cpumask_any (caps -> cpus ) < nr_cpu_ids )
33723344 pr_info ("detected: %s on CPU%*pbl\n" ,
33733345 caps -> desc , cpumask_pr_args (caps -> cpus ));
33743346 }
3347+
3348+ /*
3349+ * TTBR0 PAN doesn't have its own cpucap, so log it manually.
3350+ */
3351+ if (system_uses_ttbr0_pan ())
3352+ pr_info ("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n" );
3353+ }
3354+
3355+ void __init setup_system_features (void )
3356+ {
3357+ setup_system_capabilities ();
3358+
3359+ kpti_install_ng_mappings ();
3360+
3361+ sve_setup ();
3362+ sme_setup ();
3363+
3364+ /*
3365+ * Check for sane CTR_EL0.CWG value.
3366+ */
3367+ if (!cache_type_cwg ())
3368+ pr_warn ("No Cache Writeback Granule information, assuming %d\n" ,
3369+ ARCH_DMA_MINALIGN );
33753370}
33763371
33773372void __init setup_user_features (void )
0 commit comments