Skip to content

Commit 0d1c86b

Browse files
brooniewilldeacon
authored andcommitted
arm64/gcs: Don't try to access GCS registers if arm64.nogcs is enabled
During EL2 setup if GCS is advertised in the ID registers we will reset the GCS control registers GCSCR_EL1 and GCSCRE0_EL1 to known values in order to ensure it is disabled. This is done without taking into account overrides supplied on the command line, meaning that if the user has configured arm64.nogcs we will still access these GCS specific registers. If this was done because EL3 does not enable GCS this results in traps to EL3 and a failed boot which is not what users would expect from having set that parameter. Move the writes to these registers to finalise_el2_state where we can pay attention to the command line overrides. For simplicity we leave the updates to the traps in HCRX_EL2 and the FGT registers in place since these should only be relevant for KVM guests and KVM will manage them itself for guests. This follows the existing practice for other similar traps for overridable features such as those for TPIDR2_EL0 and SMPRI_EL1. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 727c2a5 commit 0d1c86b

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

arch/arm64/include/asm/el2_setup.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,6 @@
287287
.Lskip_fgt2_\@:
288288
.endm
289289

290-
.macro __init_el2_gcs
291-
mrs_s x1, SYS_ID_AA64PFR1_EL1
292-
ubfx x1, x1, #ID_AA64PFR1_EL1_GCS_SHIFT, #4
293-
cbz x1, .Lskip_gcs_\@
294-
295-
/* Ensure GCS is not enabled when we start trying to do BLs */
296-
msr_s SYS_GCSCR_EL1, xzr
297-
msr_s SYS_GCSCRE0_EL1, xzr
298-
.Lskip_gcs_\@:
299-
.endm
300-
301290
/**
302291
* Initialize EL2 registers to sane values. This should be called early on all
303292
* cores that were booted in EL2. Note that everything gets initialised as
@@ -319,7 +308,6 @@
319308
__init_el2_cptr
320309
__init_el2_fgt
321310
__init_el2_fgt2
322-
__init_el2_gcs
323311
.endm
324312

325313
#ifndef __KVM_NVHE_HYPERVISOR__
@@ -371,6 +359,13 @@
371359
msr_s SYS_MPAMHCR_EL2, xzr // clear TRAP_MPAMIDR_EL1 -> EL2
372360

373361
.Lskip_mpam_\@:
362+
check_override id_aa64pfr1, ID_AA64PFR1_EL1_GCS_SHIFT, .Linit_gcs_\@, .Lskip_gcs_\@, x1, x2
363+
364+
.Linit_gcs_\@:
365+
msr_s SYS_GCSCR_EL1, xzr
366+
msr_s SYS_GCSCRE0_EL1, xzr
367+
368+
.Lskip_gcs_\@:
374369
check_override id_aa64pfr0, ID_AA64PFR0_EL1_SVE_SHIFT, .Linit_sve_\@, .Lskip_sve_\@, x1, x2
375370

376371
.Linit_sve_\@: /* SVE register access */

0 commit comments

Comments
 (0)