mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature
@ 2025-04-03 17:46 Yeoreum Yun
  2025-04-03 17:46 ` [PATCH v2 1/4] arm64/feature: add MTE_STORE_ONLY feature Yeoreum Yun
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Yeoreum Yun @ 2025-04-03 17:46 UTC (permalink / raw)
  To: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, david, yang, mbenes, joel.granados
  Cc: linux-arm-kernel, linux-kernel, nd, Yeoreum Yun

The FEAT_MTE_STORE_ONLY feature provides support for
tag check for store operation only. read operation is considered
as unchecked operation so it doesn't raise tag check fault.

NOTE:
  This patches based on https://lore.kernel.org/linux-arm-kernel/20250403172758.67106-1-yeoreum.yun@arm.com/

Since v1:
  - add doc to elf_hwcaps.rst
  - add MTE_STORE_ONLY hwcap test

Yeoreum Yun (4):
  arm64/feature: add MTE_STORE_ONLY feature
  prtcl: introduce PR_MTE_STORE_ONLY
  arm64/kernel: support store-only mte tag check
  tools/kselftest: add MTE_STORE_ONLY feature hwcap test

 Documentation/arch/arm64/elf_hwcaps.rst   |  3 +++
 arch/arm64/include/asm/hwcap.h            |  1 +
 arch/arm64/include/asm/processor.h        |  2 ++
 arch/arm64/include/uapi/asm/hwcap.h       |  1 +
 arch/arm64/kernel/cpufeature.c            |  9 +++++++++
 arch/arm64/kernel/cpuinfo.c               |  1 +
 arch/arm64/kernel/mte.c                   | 11 ++++++++++-
 arch/arm64/kernel/process.c               |  6 +++++-
 arch/arm64/tools/cpucaps                  |  1 +
 include/uapi/linux/prctl.h                |  2 ++
 tools/testing/selftests/arm64/abi/hwcap.c |  6 ++++++
 11 files changed, 41 insertions(+), 2 deletions(-)

--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}


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

* [PATCH v2 1/4] arm64/feature: add MTE_STORE_ONLY feature
  2025-04-03 17:46 [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature Yeoreum Yun
@ 2025-04-03 17:46 ` Yeoreum Yun
  2025-04-03 17:46 ` [PATCH v2 2/4] prtcl: introduce PR_MTE_STORE_ONLY Yeoreum Yun
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Yeoreum Yun @ 2025-04-03 17:46 UTC (permalink / raw)
  To: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, david, yang, mbenes, joel.granados
  Cc: linux-arm-kernel, linux-kernel, nd, Yeoreum Yun

add MTE_STORE_ONLY feature and HWCAP.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
 Documentation/arch/arm64/elf_hwcaps.rst | 3 +++
 arch/arm64/include/asm/hwcap.h          | 1 +
 arch/arm64/include/uapi/asm/hwcap.h     | 1 +
 arch/arm64/kernel/cpufeature.c          | 9 +++++++++
 arch/arm64/kernel/cpuinfo.c             | 1 +
 arch/arm64/tools/cpucaps                | 1 +
 6 files changed, 16 insertions(+)

diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst
index 358f5af035ff..f58ada4d6cb2 100644
--- a/Documentation/arch/arm64/elf_hwcaps.rst
+++ b/Documentation/arch/arm64/elf_hwcaps.rst
@@ -438,6 +438,9 @@ HWCAP2_POE
 HWCAP3_MTE_FAR
     Functionality implied by ID_AA64PFR2_EL1.MTEFAR == 0b0001.
 
+HWCAP3_MTE_STORE_ONLY
+    Functionality implied by ID_AA64PFR2_EL1.MTESTOREONLY == 0b0001.
+
 4. Unused AT_HWCAP bits
 -----------------------
 
diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h
index 28dd1ac29ecc..13f94c8ddfc0 100644
--- a/arch/arm64/include/asm/hwcap.h
+++ b/arch/arm64/include/asm/hwcap.h
@@ -177,6 +177,7 @@
 
 #define __khwcap3_feature(x)		(const_ilog2(HWCAP3_ ## x) + 128)
 #define KERNEL_HWCAP_MTE_FAR		__khwcap3_feature(MTE_FAR)
+#define KERNEL_HWCAP_MTE_STORE_ONLY	__khwcap3_feature(MTE_STORE_ONLY)
 
 /*
  * This yields a mask that user programs can use to figure out what
diff --git a/arch/arm64/include/uapi/asm/hwcap.h b/arch/arm64/include/uapi/asm/hwcap.h
index 7d22527a7975..72c78468b806 100644
--- a/arch/arm64/include/uapi/asm/hwcap.h
+++ b/arch/arm64/include/uapi/asm/hwcap.h
@@ -144,5 +144,6 @@
  * HWCAP3 flags - for AT_HWCAP3
  */
 #define HWCAP3_MTE_FAR		(1UL << 0)
+#define HWCAP3_MTE_STORE_ONLY		(1UL << 1)
 
 #endif /* _UAPI__ASM_HWCAP_H */
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 183b4b7e3074..a2f25a8bed96 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -313,6 +313,7 @@ static const struct arm64_ftr_bits ftr_id_aa64pfr1[] = {
 static const struct arm64_ftr_bits ftr_id_aa64pfr2[] = {
 	ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR2_EL1_FPMR_SHIFT, 4, 0),
 	ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64PFR2_EL1_MTEFAR_SHIFT, 4, ID_AA64PFR2_EL1_MTEFAR_NI),
+	ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64PFR2_EL1_MTESTOREONLY_SHIFT, 4, ID_AA64PFR2_EL1_MTESTOREONLY_NI),
 	ARM64_FTR_END,
 };
 
@@ -2869,6 +2870,13 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.matches = has_cpuid_feature,
 		ARM64_CPUID_FIELDS(ID_AA64PFR2_EL1, MTEFAR, IMP)
 	},
+	{
+		.desc = "Store Only MTE Tag Check",
+		.capability = ARM64_MTE_STORE_ONLY,
+		.type = ARM64_CPUCAP_SYSTEM_FEATURE,
+		.matches = has_cpuid_feature,
+		ARM64_CPUID_FIELDS(ID_AA64PFR2_EL1, MTESTOREONLY, IMP)
+	},
 #endif /* CONFIG_ARM64_MTE */
 	{
 		.desc = "RCpc load-acquire (LDAPR)",
@@ -3200,6 +3208,7 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {
 	HWCAP_CAP(ID_AA64PFR1_EL1, MTE, MTE2, CAP_HWCAP, KERNEL_HWCAP_MTE),
 	HWCAP_CAP(ID_AA64PFR1_EL1, MTE, MTE3, CAP_HWCAP, KERNEL_HWCAP_MTE3),
 	HWCAP_CAP(ID_AA64PFR2_EL1, MTEFAR, IMP, CAP_HWCAP, KERNEL_HWCAP_MTE_FAR),
+	HWCAP_CAP(ID_AA64PFR2_EL1, MTESTOREONLY, IMP, CAP_HWCAP , KERNEL_HWCAP_MTE_STORE_ONLY),
 #endif /* CONFIG_ARM64_MTE */
 	HWCAP_CAP(ID_AA64MMFR0_EL1, ECV, IMP, CAP_HWCAP, KERNEL_HWCAP_ECV),
 	HWCAP_CAP(ID_AA64MMFR1_EL1, AFP, IMP, CAP_HWCAP, KERNEL_HWCAP_AFP),
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index e2b13454e38a..40f85ec01fe4 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -161,6 +161,7 @@ static const char *const hwcap_str[] = {
 	[KERNEL_HWCAP_SME_STMOP]	= "smestmop",
 	[KERNEL_HWCAP_SME_SMOP4]	= "smesmop4",
 	[KERNEL_HWCAP_MTE_FAR]		= "mte_far",
+	[KERNEL_HWCAP_MTE_STORE_ONLY]	= "mte_store_only",
 };
 
 #ifdef CONFIG_COMPAT
diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps
index ef62ea04ba37..282a1dbb8bc9 100644
--- a/arch/arm64/tools/cpucaps
+++ b/arch/arm64/tools/cpucaps
@@ -68,6 +68,7 @@ MPAM_HCR
 MTE
 MTE_ASYMM
 MTE_FAR
+MTE_STORE_ONLY
 SME
 SME_FA64
 SME2
-- 
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}


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

* [PATCH v2 2/4] prtcl: introduce PR_MTE_STORE_ONLY
  2025-04-03 17:46 [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature Yeoreum Yun
  2025-04-03 17:46 ` [PATCH v2 1/4] arm64/feature: add MTE_STORE_ONLY feature Yeoreum Yun
@ 2025-04-03 17:46 ` Yeoreum Yun
  2025-04-03 17:47 ` [PATCH v2 3/4] arm64/kernel: support store-only mte tag check Yeoreum Yun
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Yeoreum Yun @ 2025-04-03 17:46 UTC (permalink / raw)
  To: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, david, yang, mbenes, joel.granados
  Cc: linux-arm-kernel, linux-kernel, nd, Yeoreum Yun

PR_MTE_STORE_ONLY is used to restrict the MTE tag check for store
opeartion only.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
 include/uapi/linux/prctl.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index 15c18ef4eb11..83ac566251d8 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -244,6 +244,8 @@ struct prctl_mm_map {
 # define PR_MTE_TAG_MASK		(0xffffUL << PR_MTE_TAG_SHIFT)
 /* Unused; kept only for source compatibility */
 # define PR_MTE_TCF_SHIFT		1
+/* MTE tag check store only */
+# define PR_MTE_STORE_ONLY		(1UL << 19)
 /* RISC-V pointer masking tag length */
 # define PR_PMLEN_SHIFT			24
 # define PR_PMLEN_MASK			(0x7fUL << PR_PMLEN_SHIFT)
-- 
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}


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

* [PATCH v2 3/4] arm64/kernel: support store-only mte tag check
  2025-04-03 17:46 [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature Yeoreum Yun
  2025-04-03 17:46 ` [PATCH v2 1/4] arm64/feature: add MTE_STORE_ONLY feature Yeoreum Yun
  2025-04-03 17:46 ` [PATCH v2 2/4] prtcl: introduce PR_MTE_STORE_ONLY Yeoreum Yun
@ 2025-04-03 17:47 ` Yeoreum Yun
  2025-04-03 17:47 ` [PATCH v2 4/4] tools/kselftest: add MTE_STORE_ONLY feature hwcap test Yeoreum Yun
  2025-04-04 17:38 ` [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature David Hildenbrand
  4 siblings, 0 replies; 10+ messages in thread
From: Yeoreum Yun @ 2025-04-03 17:47 UTC (permalink / raw)
  To: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, david, yang, mbenes, joel.granados
  Cc: linux-arm-kernel, linux-kernel, nd, Yeoreum Yun

Introduce new flag -- MTE_CTRL_STORE_ONLY used to set store-only tag check.
This flag isn't overrided by prefered tcf flag setting but set together
with prefered setting of way to report tag check fault.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
 arch/arm64/include/asm/processor.h |  2 ++
 arch/arm64/kernel/mte.c            | 11 ++++++++++-
 arch/arm64/kernel/process.c        |  6 +++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 1bf1a3b16e88..61d62bfd5a7b 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -23,6 +23,8 @@
 #define MTE_CTRL_TCF_ASYNC		(1UL << 17)
 #define MTE_CTRL_TCF_ASYMM		(1UL << 18)
 
+#define MTE_CTRL_STORE_ONLY		(1UL << 19)
+
 #ifndef __ASSEMBLY__
 
 #include <linux/build_bug.h>
diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
index 2fbfd27ff5f2..e5e773844889 100644
--- a/arch/arm64/kernel/mte.c
+++ b/arch/arm64/kernel/mte.c
@@ -200,7 +200,7 @@ static void mte_update_sctlr_user(struct task_struct *task)
 	 * program requested values go with what was requested.
 	 */
 	resolved_mte_tcf = (mte_ctrl & pref) ? pref : mte_ctrl;
-	sctlr &= ~SCTLR_EL1_TCF0_MASK;
+	sctlr &= ~(SCTLR_EL1_TCF0_MASK | SCTLR_EL1_TCSO0_MASK);
 	/*
 	 * Pick an actual setting. The order in which we check for
 	 * set bits and map into register values determines our
@@ -212,6 +212,10 @@ static void mte_update_sctlr_user(struct task_struct *task)
 		sctlr |= SYS_FIELD_PREP_ENUM(SCTLR_EL1, TCF0, ASYNC);
 	else if (resolved_mte_tcf & MTE_CTRL_TCF_SYNC)
 		sctlr |= SYS_FIELD_PREP_ENUM(SCTLR_EL1, TCF0, SYNC);
+
+	if (mte_ctrl & MTE_CTRL_STORE_ONLY)
+		sctlr |= SYS_FIELD_PREP(SCTLR_EL1, TCSO0, 1);
+
 	task->thread.sctlr_user = sctlr;
 }
 
@@ -371,6 +375,9 @@ long set_mte_ctrl(struct task_struct *task, unsigned long arg)
 	    (arg & PR_MTE_TCF_SYNC))
 		mte_ctrl |= MTE_CTRL_TCF_ASYMM;
 
+	if (arg & PR_MTE_STORE_ONLY)
+		mte_ctrl |= MTE_CTRL_STORE_ONLY;
+
 	task->thread.mte_ctrl = mte_ctrl;
 	if (task == current) {
 		preempt_disable();
@@ -398,6 +405,8 @@ long get_mte_ctrl(struct task_struct *task)
 		ret |= PR_MTE_TCF_ASYNC;
 	if (mte_ctrl & MTE_CTRL_TCF_SYNC)
 		ret |= PR_MTE_TCF_SYNC;
+	if (mte_ctrl & MTE_CTRL_STORE_ONLY)
+		ret |= PR_MTE_STORE_ONLY;
 
 	return ret;
 }
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 42faebb7b712..cea4a23a15de 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -815,10 +815,14 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
 	if (is_compat_thread(ti))
 		return -EINVAL;
 
-	if (system_supports_mte())
+	if (system_supports_mte()) {
 		valid_mask |= PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC \
 			| PR_MTE_TAG_MASK;
 
+		if (cpus_have_cap(ARM64_MTE_STORE_ONLY))
+			valid_mask |= PR_MTE_STORE_ONLY;
+	}
+
 	if (arg & ~valid_mask)
 		return -EINVAL;
 
-- 
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}


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

* [PATCH v2 4/4] tools/kselftest: add MTE_STORE_ONLY feature hwcap test
  2025-04-03 17:46 [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature Yeoreum Yun
                   ` (2 preceding siblings ...)
  2025-04-03 17:47 ` [PATCH v2 3/4] arm64/kernel: support store-only mte tag check Yeoreum Yun
@ 2025-04-03 17:47 ` Yeoreum Yun
  2025-04-04 15:58   ` Mark Brown
  2025-04-04 17:38 ` [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature David Hildenbrand
  4 siblings, 1 reply; 10+ messages in thread
From: Yeoreum Yun @ 2025-04-03 17:47 UTC (permalink / raw)
  To: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, david, yang, mbenes, joel.granados
  Cc: linux-arm-kernel, linux-kernel, nd, Yeoreum Yun

add MTE_STORE_ONLY feature hwcap test.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
 tools/testing/selftests/arm64/abi/hwcap.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
index a539eeb0bfc0..32385f67498e 100644
--- a/tools/testing/selftests/arm64/abi/hwcap.c
+++ b/tools/testing/selftests/arm64/abi/hwcap.c
@@ -1104,6 +1104,12 @@ static const struct hwcap_data {
 		.hwcap_bit = HWCAP3_MTE_FAR,
 		.cpuinfo = "mte_far",
 	},
+	{
+		.name = "MTE_STOREONLY",
+		.at_hwcap = AT_HWCAP3,
+		.hwcap_bit = HWCAP3_MTE_STORE_ONLY,
+		.cpuinfo = "mte_store_only",
+	},
 };
 
 typedef void (*sighandler_fn)(int, siginfo_t *, void *);
-- 
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}


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

* Re: [PATCH v2 4/4] tools/kselftest: add MTE_STORE_ONLY feature hwcap test
  2025-04-03 17:47 ` [PATCH v2 4/4] tools/kselftest: add MTE_STORE_ONLY feature hwcap test Yeoreum Yun
@ 2025-04-04 15:58   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2025-04-04 15:58 UTC (permalink / raw)
  To: Yeoreum Yun
  Cc: catalin.marinas, will, anshuman.khandual, joey.gouly, maz,
	oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, david, yang, mbenes, joel.granados, linux-arm-kernel,
	linux-kernel, nd

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

On Thu, Apr 03, 2025 at 06:47:01PM +0100, Yeoreum Yun wrote:
> add MTE_STORE_ONLY feature hwcap test.

Reviewed-by: Mark Brown <broonie@kernel.org>

Usually the subject would be kselftest/arm64 BTW.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature
  2025-04-03 17:46 [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature Yeoreum Yun
                   ` (3 preceding siblings ...)
  2025-04-03 17:47 ` [PATCH v2 4/4] tools/kselftest: add MTE_STORE_ONLY feature hwcap test Yeoreum Yun
@ 2025-04-04 17:38 ` David Hildenbrand
  2025-04-04 19:33   ` Yeoreum Yun
  4 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand @ 2025-04-04 17:38 UTC (permalink / raw)
  To: Yeoreum Yun, catalin.marinas, will, broonie, anshuman.khandual,
	joey.gouly, maz, oliver.upton, frederic, james.morse,
	hardevsinh.palaniya, shameerali.kolothum.thodi, huangxiaojia2,
	mark.rutland, samuel.holland, palmer, charlie, thiago.bauermann,
	bgray, tglx, puranjay, yang, mbenes, joel.granados
  Cc: linux-arm-kernel, linux-kernel, nd

On 03.04.25 19:46, Yeoreum Yun wrote:
> The FEAT_MTE_STORE_ONLY feature provides support for
> tag check for store operation only. read operation is considered
> as unchecked operation so it doesn't raise tag check fault.

Can you add/share more details of what the implications are, how it 
would be used, who would set it, etc.

Just from staring at this short paragraph leaves me rather clueless.

-- 
Cheers,

David / dhildenb


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

* Re: [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature
  2025-04-04 17:38 ` [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature David Hildenbrand
@ 2025-04-04 19:33   ` Yeoreum Yun
  2025-04-04 20:18     ` David Hildenbrand
  0 siblings, 1 reply; 10+ messages in thread
From: Yeoreum Yun @ 2025-04-04 19:33 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, yang, mbenes, joel.granados, linux-arm-kernel,
	linux-kernel, nd

Hi David.

> On 03.04.25 19:46, Yeoreum Yun wrote:
> > The FEAT_MTE_STORE_ONLY feature provides support for
> > tag check for store operation only. read operation is considered
> > as unchecked operation so it doesn't raise tag check fault.
>
> Can you add/share more details of what the implications are, how it would be
> used, who would set it, etc.
>
> Just from staring at this short paragraph leaves me rather clueless.
>

Sorry for my bad.

ARMv8.5 based processors introduce the Memory Tagging Extension (MTE) feature.
MTE is built on top of the ARMv8.0 virtual address tagging TBI
(Top Byte Ignore) feature and allows software to access a 4-bit
allocation tag for each 16-byte granule in the physical address space.
A logical tag is derived from bits 59-56 of the virtual
address used for the memory access. A CPU with MTE enabled will compare
the logical tag against the allocation tag and potentially raise an
tag check fault on mismatch, subject to system registers configuration.

Since ARMv8.9, FEAT_MTE_STORE_ONLY can be used to restrict raise of tag
check fault on store operation only.
For this, application can use PR_MTE_STORE_ONLY flag
when it sets the MTE setting with prctl().

This would be useful for debugging purpose
i.e) finding memory courruption point, use-after-free and etc.

--
Sincerely,
Yeoreum Yun

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

* Re: [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature
  2025-04-04 19:33   ` Yeoreum Yun
@ 2025-04-04 20:18     ` David Hildenbrand
  2025-04-04 21:08       ` Yeoreum Yun
  0 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand @ 2025-04-04 20:18 UTC (permalink / raw)
  To: Yeoreum Yun
  Cc: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, yang, mbenes, joel.granados, linux-arm-kernel,
	linux-kernel, nd

On 04.04.25 21:33, Yeoreum Yun wrote:
> Hi David.
> 
>> On 03.04.25 19:46, Yeoreum Yun wrote:
>>> The FEAT_MTE_STORE_ONLY feature provides support for
>>> tag check for store operation only. read operation is considered
>>> as unchecked operation so it doesn't raise tag check fault.
>>
>> Can you add/share more details of what the implications are, how it would be
>> used, who would set it, etc.
>>
>> Just from staring at this short paragraph leaves me rather clueless.
>>
> 
> Sorry for my bad.
> 
> ARMv8.5 based processors introduce the Memory Tagging Extension (MTE) feature.
> MTE is built on top of the ARMv8.0 virtual address tagging TBI
> (Top Byte Ignore) feature and allows software to access a 4-bit
> allocation tag for each 16-byte granule in the physical address space.
> A logical tag is derived from bits 59-56 of the virtual
> address used for the memory access. A CPU with MTE enabled will compare
> the logical tag against the allocation tag and potentially raise an
> tag check fault on mismatch, subject to system registers configuration.
> 
> Since ARMv8.9, FEAT_MTE_STORE_ONLY can be used to restrict raise of tag
> check fault on store operation only.

Oh, so other operations (read/fetch) will not check the tag.

> For this, application can use PR_MTE_STORE_ONLY flag
> when it sets the MTE setting with prctl().
> 
> This would be useful for debugging purpose
> i.e) finding memory courruption point, use-after-free and etc.

So what's the benefit of this relaxation? I assume it's faster because 
less memory access has to perform tag checks, and the issues you mention 
here can still be mostly caught (not all cases of use-after-free, but at 
least the destructive ones).

-- 
Cheers,

David / dhildenb


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

* Re: [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature
  2025-04-04 20:18     ` David Hildenbrand
@ 2025-04-04 21:08       ` Yeoreum Yun
  0 siblings, 0 replies; 10+ messages in thread
From: Yeoreum Yun @ 2025-04-04 21:08 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: catalin.marinas, will, broonie, anshuman.khandual, joey.gouly,
	maz, oliver.upton, frederic, james.morse, hardevsinh.palaniya,
	shameerali.kolothum.thodi, huangxiaojia2, mark.rutland,
	samuel.holland, palmer, charlie, thiago.bauermann, bgray, tglx,
	puranjay, yang, mbenes, joel.granados, linux-arm-kernel,
	linux-kernel, nd

Hi David,

> On 04.04.25 21:33, Yeoreum Yun wrote:
> > Hi David.
> >
> > > On 03.04.25 19:46, Yeoreum Yun wrote:
> > > > The FEAT_MTE_STORE_ONLY feature provides support for
> > > > tag check for store operation only. read operation is considered
> > > > as unchecked operation so it doesn't raise tag check fault.
> > >
> > > Can you add/share more details of what the implications are, how it would be
> > > used, who would set it, etc.
> > >
> > > Just from staring at this short paragraph leaves me rather clueless.
> > >
> >
> > Sorry for my bad.
> >
> > ARMv8.5 based processors introduce the Memory Tagging Extension (MTE) feature.
> > MTE is built on top of the ARMv8.0 virtual address tagging TBI
> > (Top Byte Ignore) feature and allows software to access a 4-bit
> > allocation tag for each 16-byte granule in the physical address space.
> > A logical tag is derived from bits 59-56 of the virtual
> > address used for the memory access. A CPU with MTE enabled will compare
> > the logical tag against the allocation tag and potentially raise an
> > tag check fault on mismatch, subject to system registers configuration.
> >
> > Since ARMv8.9, FEAT_MTE_STORE_ONLY can be used to restrict raise of tag
> > check fault on store operation only.
>
> Oh, so other operations (read/fetch) will not check the tag.

Yes it is. the read operation considered as uncheck, so it wouldn't
check the tag.

> > For this, application can use PR_MTE_STORE_ONLY flag
> > when it sets the MTE setting with prctl().
> >
> > This would be useful for debugging purpose
> > i.e) finding memory courruption point, use-after-free and etc.
>
> So what's the benefit of this relaxation? I assume it's faster because less
> memory access has to perform tag checks, and the issues you mention here can
> still be mostly caught (not all cases of use-after-free, but at least the
> destructive ones).

Right. but as you mention, the to reduce overhead by omitting the
tag check on read operation (sometime this overhead is too much than
gain some benefit) [0]

[0] https://www.usenix.org/conference/woot24/presentation/jacobs


Thanks.
--
Sincerely,
Yeoreum Yun

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

end of thread, other threads:[~2025-04-04 21:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-03 17:46 [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature Yeoreum Yun
2025-04-03 17:46 ` [PATCH v2 1/4] arm64/feature: add MTE_STORE_ONLY feature Yeoreum Yun
2025-04-03 17:46 ` [PATCH v2 2/4] prtcl: introduce PR_MTE_STORE_ONLY Yeoreum Yun
2025-04-03 17:47 ` [PATCH v2 3/4] arm64/kernel: support store-only mte tag check Yeoreum Yun
2025-04-03 17:47 ` [PATCH v2 4/4] tools/kselftest: add MTE_STORE_ONLY feature hwcap test Yeoreum Yun
2025-04-04 15:58   ` Mark Brown
2025-04-04 17:38 ` [PATCH v2 0/4] support FEAT_MTE_STORE_ONLY feature David Hildenbrand
2025-04-04 19:33   ` Yeoreum Yun
2025-04-04 20:18     ` David Hildenbrand
2025-04-04 21:08       ` Yeoreum Yun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®