Skip to content

Commit 37fe0f9

Browse files
benhor01James Morse
authored andcommitted
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
The MPAMSM_EL1 sets the MPAM labels, PMG and PARTID, for loads and stores generated by a shared SMCU. Disable the traps so the kernel can use it and set it to the same configuration as the per-EL cpu MPAM configuration. If an SMCU is not shared with other cpus then it is implementation defined whether the configuration from MPAMSM_EL1 is used or that from the appropriate MPAMy_ELx. As we set the same, PMG_D and PARTID_D, configuration for MPAM0_EL1, MPAM1_EL1 and MPAMSM_EL1 the resulting configuration is the same regardless. The range of valid configurations for the PARTID and PMG in MPAMSM_EL1 is not currently specified in Arm Architectural Reference Manual but the architect has confirmed that it is intended to be the same as that for the cpu configuration in the MPAMy_ELx registers. Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.com> Tested-by: Jesse Chick <jessechick@os.amperecomputing.com> Reviewed-by: Zeng Heng <zengheng4@huawei.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: James Morse <james.morse@arm.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent 735dad9 commit 37fe0f9

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

arch/arm64/include/asm/el2_setup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@
513513
check_override id_aa64pfr0, ID_AA64PFR0_EL1_MPAM_SHIFT, .Linit_mpam_\@, .Lskip_mpam_\@, x1, x2
514514

515515
.Linit_mpam_\@:
516-
msr_s SYS_MPAM2_EL2, xzr // use the default partition
516+
mov x0, #MPAM2_EL2_EnMPAMSM_MASK
517+
msr_s SYS_MPAM2_EL2, x0 // use the default partition,
517518
// and disable lower traps
518519
mrs_s x0, SYS_MPAMIDR_EL1
519520
tbz x0, #MPAMIDR_EL1_HAS_HCR_SHIFT, .Lskip_mpam_\@ // skip if no MPAMHCR reg

arch/arm64/include/asm/mpam.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ static inline void mpam_thread_switch(struct task_struct *tsk)
5353
return;
5454

5555
write_sysreg_s(regval | MPAM1_EL1_MPAMEN, SYS_MPAM1_EL1);
56+
if (system_supports_sme())
57+
write_sysreg_s(regval & (MPAMSM_EL1_PARTID_D | MPAMSM_EL1_PMG_D), SYS_MPAMSM_EL1);
5658
isb();
5759

5860
/* Synchronising the EL0 write is left until the ERET to EL0 */

arch/arm64/kernel/cpufeature.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,6 +2500,8 @@ cpu_enable_mpam(const struct arm64_cpu_capabilities *entry)
25002500
regval = READ_ONCE(per_cpu(arm64_mpam_current, cpu));
25012501

25022502
write_sysreg_s(regval | MPAM1_EL1_MPAMEN, SYS_MPAM1_EL1);
2503+
if (cpus_have_cap(ARM64_SME))
2504+
write_sysreg_s(regval & (MPAMSM_EL1_PARTID_D | MPAMSM_EL1_PMG_D), SYS_MPAMSM_EL1);
25032505
isb();
25042506

25052507
/* Synchronising the EL0 write is left until the ERET to EL0 */

arch/arm64/kernel/mpam.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ static int mpam_pm_notifier(struct notifier_block *self,
2828
*/
2929
regval = READ_ONCE(per_cpu(arm64_mpam_current, cpu));
3030
write_sysreg_s(regval | MPAM1_EL1_MPAMEN, SYS_MPAM1_EL1);
31+
if (system_supports_sme()) {
32+
write_sysreg_s(regval & (MPAMSM_EL1_PARTID_D | MPAMSM_EL1_PMG_D),
33+
SYS_MPAMSM_EL1);
34+
}
3135
isb();
3236

3337
write_sysreg_s(regval, SYS_MPAM0_EL1);

0 commit comments

Comments
 (0)