arm64: Delay initialisation of cpuinfo_arm64::reg_{zcr,smcr}
authorMarc Zyngier <maz@kernel.org>
Wed, 20 Jul 2022 10:52:19 +0000 (11:52 +0100)
committerWill Deacon <will@kernel.org>
Mon, 25 Jul 2022 10:02:11 +0000 (11:02 +0100)
commit892f7237b3ffb090f1b1f1e55fe7c50664405aed
treea354a336824ac06f7aa9f78ef1ad7aaa484ffe5a
parentf96d67a8af7a39f7ffaac464d8bccc4c720e52c2
arm64: Delay initialisation of cpuinfo_arm64::reg_{zcr,smcr}

Even if we are now able to tell the kernel to avoid exposing SVE/SME
from the command line, we still have a couple of places where we
unconditionally access the ZCR_EL1 (resp. SMCR_EL1) registers.

On systems with broken firmwares, this results in a crash even if
arm64.nosve (resp. arm64.nosme) was passed on the command-line.

To avoid this, only update cpuinfo_arm64::reg_{zcr,smcr} once
we have computed the sanitised version for the corresponding
feature registers (ID_AA64PFR0 for SVE, and ID_AA64PFR1 for
SME). This results in some minor refactoring.

Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Peter Collingbourne <pcc@google.com>
Tested-by: Peter Collingbourne <pcc@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220720105219.1755096-1-maz@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/cpuinfo.c