linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/1] arm64/cpufeature: Support optionally disable MTE
@ 2021-08-03  7:08 yee.lee
  2021-08-03  7:08 ` [PATCH v4 1/1] arm64/cpufeature: Optionally disable MTE via command-line yee.lee
  0 siblings, 1 reply; 3+ messages in thread
From: yee.lee @ 2021-08-03  7:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: nicholas.Tang, Kuan-Ying.lee, chinwen.chang, Yee Lee,
	Matthias Brugger, moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support

From: Yee Lee <yee.lee@mediatek.com>

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(-)

-- 
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v4 1/1] arm64/cpufeature: Optionally disable MTE via command-line
  2021-08-03  7:08 [PATCH v4 0/1] arm64/cpufeature: Support optionally disable MTE yee.lee
@ 2021-08-03  7:08 ` yee.lee
  2021-08-03 15:48   ` Catalin Marinas
  0 siblings, 1 reply; 3+ messages in thread
From: yee.lee @ 2021-08-03  7:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: nicholas.Tang, Kuan-Ying.lee, chinwen.chang, Yee Lee,
	Jonathan Corbet, Catalin Marinas, Will Deacon, Matthias Brugger,
	Paul E. McKenney, Randy Dunlap, Andrew Morton, Thomas Gleixner,
	Maciej W. Rozycki, Viresh Kumar, Peter Zijlstra, Vlastimil Babka,
	Marc Zyngier, Mark Rutland, Vincenzo Frascino, Hector Martin,
	Anshuman Khandual, Amit Daniel Kachhap, James Morse,
	Suzuki K Poulose, David Brazdil, Fuad Tabba,
	open list:DOCUMENTATION,
	moderated list:ARM64 PORT (AARCH64 ARCHITECTURE),
	moderated list:ARM/Mediatek SoC support

From: Yee Lee <yee.lee@mediatek.com>

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.

Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Suggested-by: Marc Zyngier <maz@kernel.org>
Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
---
 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(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index bdb22006f713..6f257e39d89e 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -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
diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index 7b9c3acba684..e3e2c93b35f4 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -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)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 0ead8bfedf20..51e6bf4bb7b5 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -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.
diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c
index 53a381a7f65d..d8e606fe3c21 100644
--- a/arch/arm64/kernel/idreg-override.c
+++ b/arch/arm64/kernel/idreg-override.c
@@ -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" },
 };
 
-- 
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 1/1] arm64/cpufeature: Optionally disable MTE via command-line
  2021-08-03  7:08 ` [PATCH v4 1/1] arm64/cpufeature: Optionally disable MTE via command-line yee.lee
@ 2021-08-03 15:48   ` Catalin Marinas
  0 siblings, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2021-08-03 15:48 UTC (permalink / raw)
  To: linux-kernel, yee.lee
  Cc: Will Deacon, moderated list:ARM64 PORT (AARCH64 ARCHITECTURE),
	Peter Zijlstra, Paul E. McKenney, Kuan-Ying.lee, James Morse,
	Vincenzo Frascino, Matthias Brugger, open list:DOCUMENTATION,
	Hector Martin, Jonathan Corbet, Randy Dunlap, chinwen.chang,
	Vlastimil Babka, Amit Daniel Kachhap, Suzuki K Poulose,
	Thomas Gleixner, Mark Rutland, Anshuman Khandual, David Brazdil,
	moderated list:ARM/Mediatek SoC support, Fuad Tabba,
	Marc Zyngier, Maciej W. Rozycki, Andrew Morton, Viresh Kumar,
	nicholas.Tang

On Tue, 3 Aug 2021 15:08:22 +0800, yee.lee@mediatek.com 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) to
> cpu_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

-- 
Catalin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-03 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03  7:08 [PATCH v4 0/1] arm64/cpufeature: Support optionally disable MTE yee.lee
2021-08-03  7:08 ` [PATCH v4 1/1] arm64/cpufeature: Optionally disable MTE via command-line yee.lee
2021-08-03 15:48   ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).