arm64/cpufeature: Support optionally disable MTE
Subsystems (3)
v4 cover arm64/cpufeature: Support optionally disable MTE
From: Yee Lee <[email protected]>
An option in runtime to disable MTE support is necessary for some scenarios such as HW issue workaround, FW tests and some evaluation works in performance and resoruce costs.
This patch supoorts to override id-reg on the shadow capability via comandline and suppress MTE feature.
SCTLR_EL1.ATA/ATA0 setting is moved to cpu_enable_mte() since they are not allowed to be cache TLB.
All works in this patch turn off related software support, but not fully disable MTE in HW side.
=== Test ===
QEMU5.2 + MTE
(1) normal boot
MTE feature is enabled and HW-tags KASAN works.
(2) passed "arm64.nomte" in cmdline
boot log:
..(skip)
[ 0.000000] CPU features: SYS_ID_AA64PFR1_EL1[11:8]: forced to 0
====
Changed since v4:
- Move ATA/ATA0 setting to cpu_enable_mte()
Changed since v3:
- Add documentation text
Changed since v2:
- Use id-reg override machanism to suppress feature.
Yee Lee (1):
arm64/cpufeature: Optionally disable MTE via command-line
Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/arm64/include/asm/sysreg.h | 3 +-- arch/arm64/kernel/cpufeature.c | 3 +++ arch/arm64/kernel/idreg-override.c | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.18.0
PATCH v4 1/1 arm64/cpufeature: Optionally disable MTE via command-line
From: Yee Lee <[email protected]>
MTE support needs to be optionally disabled in runtime for HW issue workaround, FW development and some evaluation works on system resource and performance.
This patch makes two changes:
(1) moves init of tag-allocation bits(ATA/ATA0) to cpu_enable_mte() as not cached in TLB.
(2) allows ID_AA64PFR1_EL1.MTE to be overridden on its shadow value by giving "arm64.nomte" on cmdline.
When the feature value is off, ATA and TCF will not set and the related functionalities are accordingly suppressed.
--- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/arm64/include/asm/sysreg.h | 3 +-- arch/arm64/kernel/cpufeature.c | 3 +++ arch/arm64/kernel/idreg-override.c | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -380,6 +380,9 @@ arm64.nopauth [ARM64] Unconditionally disable Pointer Authentication support + arm64.nomte [ARM64] Unconditionally disable Memory Tagging Extension + support + ataflop= [HW,M68k] atarimouse= [HW,MOUSE] Atari Mouse
arch/arm64/include/asm/sysreg.h +1 -2
@@ -698,8 +698,7 @@ (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA |SCTLR_EL1_SA0 | \SCTLR_EL1_SED | SCTLR_ELx_I |SCTLR_EL1_DZE |SCTLR_EL1_UCT | \SCTLR_EL1_NTWE | SCTLR_ELx_IESB |SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \ - SCTLR_ELx_ATA |SCTLR_EL1_ATA0 |ENDIAN_SET_EL1 |SCTLR_EL1_UCI | \ -SCTLR_EL1_EPAN |SCTLR_EL1_RES1 ) +ENDIAN_SET_EL1 |SCTLR_EL1_UCI |SCTLR_EL1_EPAN |SCTLR_EL1_RES1 ) /* MAIR_ELx memory attributes (used by Linux) */#define MAIR_ATTR_DEVICE_nGnRnE UL(0x00)
arch/arm64/kernel/cpufeature.c +3 -0
@@ -1843,6 +1843,9 @@ static void bti_enable(const struct arm64_cpu_capabilities *__unused)#ifdef CONFIG_ARM64_MTE static void cpu_enable_mte (struct arm64_cpu_capabilities const *cap) { +sysreg_clear_set (sctlr_el1,0 , SCTLR_ELx_ATA |SCTLR_EL1_ATA0 ); +isb (); +/* * Clear the tags in the zero page. This needs to be done via the * linear map which has the Tagged attribute.
arch/arm64/kernel/idreg-override.c +2 -0
@@ -54,6 +54,7 @@ static const struct ftr_set_desc pfr1 __initconst = { .override = &id_aa64pfr1_override, .fields = { { "bt", ID_AA64PFR1_BT_SHIFT }, + { "mte", ID_AA64PFR1_MTE_SHIFT}, {} }, };
@@ -100,6 +101,7 @@ static const struct { {"arm64.nopauth" ,"id_aa64isar1.gpi=0 id_aa64isar1.gpa=0 " "id_aa64isar1.api=0 id_aa64isar1.apa=0" }, + { "arm64.nomte", "id_aa64pfr1.mte=0" }, { "nokaslr", "kaslr.disabled=1" }, };
Signature · 1 line
2.18.0
Re: [PATCH v4 1/1] arm64/cpufeature: Optionally disable MTE via command-line
Quoted 9 lines · On Tue, 3 Aug 2021 15:08:22 +0800, [email protected] wrote:
MTE support needs to be optionally disabled in runtime for HW issue workaround, FW development and some evaluation works on system resource and performance.
This patch makes two changes:
(1) moves init of tag-allocation bits(ATA/ATA0) tocpu_enable_mte()as not cached in TLB.[...]
Applied to arm64 (for-next/mte), thanks!
[1/1] arm64/cpufeature: Optionally disable MTE via command-line
https://git.kernel.org/arm64/c/7a062ce31807
Signature · 1 line
Catalin