Skip to content

Commit 23b33d1

Browse files
James Morseoupton
authored andcommitted
arm64: head.S: Initialise MPAM EL2 registers and disable traps
Add code to head.S's el2_setup to detect MPAM and disable any EL2 traps. This register resets to an unknown value, setting it to the default parititons/pmg before we enable the MMU is the best thing to do. Kexec/kdump will depend on this if the previous kernel left the CPU configured with a restrictive configuration. If linux is booted at the highest implemented exception level el2_setup will clear the enable bit, disabling MPAM. This code can't be enabled until a subsequent patch adds the Kconfig and cpufeature boiler plate. Signed-off-by: James Morse <[email protected]> Signed-off-by: Joey Gouly <[email protected]> Reviewed-by: Gavin Shan <[email protected]> Tested-by: Shameer Kolothum <[email protected]> Acked-by: Catalin Marinas <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 83732ce commit 23b33d1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/arm64/include/asm/el2_setup.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,19 @@
220220
msr spsr_el2, x0
221221
.endm
222222

223+
.macro __init_el2_mpam
224+
/* Memory Partitioning And Monitoring: disable EL2 traps */
225+
mrs x1, id_aa64pfr0_el1
226+
ubfx x0, x1, #ID_AA64PFR0_EL1_MPAM_SHIFT, #4
227+
cbz x0, .Lskip_mpam_\@ // skip if no MPAM
228+
msr_s SYS_MPAM2_EL2, xzr // use the default partition
229+
// and disable lower traps
230+
mrs_s x0, SYS_MPAMIDR_EL1
231+
tbz x0, #MPAMIDR_EL1_HAS_HCR_SHIFT, .Lskip_mpam_\@ // skip if no MPAMHCR reg
232+
msr_s SYS_MPAMHCR_EL2, xzr // clear TRAP_MPAMIDR_EL1 -> EL2
233+
.Lskip_mpam_\@:
234+
.endm
235+
223236
/**
224237
* Initialize EL2 registers to sane values. This should be called early on all
225238
* cores that were booted in EL2. Note that everything gets initialised as
@@ -237,6 +250,7 @@
237250
__init_el2_stage2
238251
__init_el2_gicv3
239252
__init_el2_hstr
253+
__init_el2_mpam
240254
__init_el2_nvhe_idregs
241255
__init_el2_cptr
242256
__init_el2_fgt

0 commit comments

Comments
 (0)