Skip to content

Commit d3c7c48

Browse files
brooniewilldeacon
authored andcommitted
arm64/sme: Move storage of reg_smidr to __cpuinfo_store_cpu()
In commit 892f723 ("arm64: Delay initialisation of cpuinfo_arm64::reg_{zcr,smcr}") we moved access to ZCR, SMCR and SMIDR later in the boot process in order to ensure that we don't attempt to interact with them if SVE or SME is disabled on the command line. Unfortunately when initialising the boot CPU in init_cpu_features() we work on a copy of the struct cpuinfo_arm64 for the boot CPU used only during boot, not the percpu copy used by the sysfs code. The expectation of the feature identification code was that the ID registers would be read in __cpuinfo_store_cpu() and the values not modified by init_cpu_features(). The main reason for the original change was to avoid early accesses to ZCR on practical systems that were seen shipping with SVE reported in ID registers but traps enabled at EL3 and handled as fatal errors, SME was rolled in due to the similarity with SVE. Since then we have removed the early accesses to ZCR and SMCR in commits: abef069 ("arm64/sve: Remove ZCR pseudo register from cpufeature code") 3912084 ("arm64/sve: Remove SMCR pseudo register from cpufeature code") so only the SMIDR_EL1 part of the change remains. Since SMIDR_EL1 is only trapped via FEAT_IDST and not the SME trap it is less likely to be affected by similar issues, and the factors that lead to issues with SVE are less likely to apply to SME. Since we have not yet seen practical SME systems that need to use a command line override (and are only just beginning to see SME systems at all) and the ID register read is much more likely to be safe let's just store SMIDR_EL1 along with all the other ID register reads in __cpuinfo_store_cpu(). This issue wasn't apparent when testing on emulated platforms that do not report values in SMIDR_EL1. Fixes: 892f723 ("arm64: Delay initialisation of cpuinfo_arm64::reg_{zcr,smcr}") Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20241217-arm64-fix-boot-cpu-smidr-v3-1-7be278a85623@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent d66e21d commit d3c7c48

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,12 +1166,6 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
11661166
id_aa64pfr1_sme(read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1))) {
11671167
unsigned long cpacr = cpacr_save_enable_kernel_sme();
11681168

1169-
/*
1170-
* We mask out SMPS since even if the hardware
1171-
* supports priorities the kernel does not at present
1172-
* and we block access to them.
1173-
*/
1174-
info->reg_smidr = read_cpuid(SMIDR_EL1) & ~SMIDR_EL1_SMPS;
11751169
vec_init_vq_map(ARM64_VEC_SME);
11761170

11771171
cpacr_restore(cpacr);
@@ -1422,13 +1416,6 @@ void update_cpu_features(int cpu,
14221416
id_aa64pfr1_sme(read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1))) {
14231417
unsigned long cpacr = cpacr_save_enable_kernel_sme();
14241418

1425-
/*
1426-
* We mask out SMPS since even if the hardware
1427-
* supports priorities the kernel does not at present
1428-
* and we block access to them.
1429-
*/
1430-
info->reg_smidr = read_cpuid(SMIDR_EL1) & ~SMIDR_EL1_SMPS;
1431-
14321419
/* Probe vector lengths */
14331420
if (!system_capabilities_finalized())
14341421
vec_update_vq_map(ARM64_VEC_SME);

arch/arm64/kernel/cpuinfo.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,16 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info)
482482
if (id_aa64pfr0_mpam(info->reg_id_aa64pfr0))
483483
info->reg_mpamidr = read_cpuid(MPAMIDR_EL1);
484484

485+
if (IS_ENABLED(CONFIG_ARM64_SME) &&
486+
id_aa64pfr1_sme(info->reg_id_aa64pfr1)) {
487+
/*
488+
* We mask out SMPS since even if the hardware
489+
* supports priorities the kernel does not at present
490+
* and we block access to them.
491+
*/
492+
info->reg_smidr = read_cpuid(SMIDR_EL1) & ~SMIDR_EL1_SMPS;
493+
}
494+
485495
cpuinfo_detect_icache_policy(info);
486496
}
487497

0 commit comments

Comments
 (0)