From 5f852449e8fde09a84703e2bf75eb8de4c142c08 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Thu, 14 Apr 2022 09:01:42 +0000 Subject: [PATCH] ANDROID: arm64: Wrap MPAM setup with a config option As it turns out, there are broken firmwares out there, and an apparent need to turn MPAM off until the firmware can be fixed. Introduce the ARM64_MPAM config option, wrap the MPAM setup with it, and set it as default for GKI. Non-GKI uses with broken firmwares can have their own config fragments to deal with it. The config option text is lifted from James Morse's git tree. Bug: 228613614 Signed-off-by: Marc Zyngier Change-Id: Ib782aab89c826ea96dbf9ae26c16d1a4a61c41fb --- arch/arm64/Kconfig | 15 +++++++++++++++ arch/arm64/configs/gki_defconfig | 1 + arch/arm64/include/asm/el2_setup.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index e821280972e1..617ab2c45526 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1688,6 +1688,21 @@ config ARM64_TLB_RANGE The feature introduces new assembly instructions, and they were support when binutils >= 2.30. +config ARM64_MPAM + bool "Enable support for MPAM" + help + Memory Partitioning and Monitoring is an optional extension + that allows the CPUs to mark load and store transactions with + labels for partition-id and performance-monitoring-group. + System components, such as the caches, can use the partition-id + to apply a performance policy. MPAM monitors can use the + partition-id and performance-monitoring-group to measure the + cache occupancy or data throughput. + + Use of this extension requires CPU support, support in the + memory system components (MSC), and a description from firmware + of where the MSC are in the address space. + endmenu menu "ARMv8.5 architectural features" diff --git a/arch/arm64/configs/gki_defconfig b/arch/arm64/configs/gki_defconfig index 4189c9e88235..363bda5001a3 100644 --- a/arch/arm64/configs/gki_defconfig +++ b/arch/arm64/configs/gki_defconfig @@ -60,6 +60,7 @@ CONFIG_ARMV8_DEPRECATED=y CONFIG_SWP_EMULATION=y CONFIG_CP15_BARRIER_EMULATION=y CONFIG_SETEND_EMULATION=y +CONFIG_ARM64_MPAM=y CONFIG_RANDOMIZE_BASE=y # CONFIG_RANDOMIZE_MODULE_REGION_FULL is not set CONFIG_CMDLINE="stack_depot_disable=on kasan.stacktrace=off kvm-arm.mode=protected cgroup_disable=pressure" diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index 017d24711571..0c1a6fb93bf0 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -178,6 +178,7 @@ .endm .macro __init_el2_mpam +#ifdef CONFIG_ARM64_MPAM /* Memory Partioning And Monitoring: disable EL2 traps */ mrs x1, id_aa64pfr0_el1 ubfx x0, x1, #ID_AA64PFR0_MPAM_SHIFT, #4 @@ -189,6 +190,7 @@ tbz x0, #17, .Lskip_mpam_\@ // skip if no MPAMHCR reg msr_s SYS_MPAMHCR_EL2, xzr // clear TRAP_MPAMIDR_EL1 -> EL2 .Lskip_mpam_\@: +#endif /* CONFIG_ARM64_MPAM */ .endm /**