All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mm: trace: decode architecture-specific VMA flags
@ 2026-09-02  6:45 Meijing Zhao
  2026-09-02  6:45 ` [PATCH v2 1/3] mm: trace: decode arm64 and sparc64 VM_ARCH_1 flags Meijing Zhao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Meijing Zhao @ 2026-09-02  6:45 UTC (permalink / raw)
  To: Lorenzo Stoakes, Andrew Morton
  Cc: Meijing Zhao, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Wandun Chen, linux-mm, linux-trace-kernel, linux-kernel

From: Meijing Zhao <zhaomeijing@lixiang.com>

show_vma_flags(), which is used by VMA tracepoints and %pGv, names
generic VM_* bits but does not fully decode architecture-specific flag
positions.  As a result, trace output and VMA dumps can show a generic
"arch_1" name or a raw hexadecimal value instead of the meaning assigned
by the target architecture.

This series adds symbolic names for the arm64 and sparc64 meanings of
VM_ARCH_1, arm64 MTE flags, user shadow stack flags, and protection-key
encoding bits under their corresponding configuration guards.

Changes in v2:
- Rebase onto v7.3-rc1.
- Fix the patch 1 changelog: "bti" and "adi" are descriptive trace
  names, but do not match the two-character smaps mnemonics.
- Cc Lorenzo Stoakes.

Meijing Zhao (3):
  mm: trace: decode arm64 and sparc64 VM_ARCH_1 flags
  mm: trace: decode MTE and shadow stack VMA flags
  mm: trace: name protection key encoding bits

 include/trace/events/mmflags.h | 43 ++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

-- 
2.25.1


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

* [PATCH v2 1/3] mm: trace: decode arm64 and sparc64 VM_ARCH_1 flags
  2026-09-02  6:45 [PATCH v2 0/3] mm: trace: decode architecture-specific VMA flags Meijing Zhao
@ 2026-09-02  6:45 ` Meijing Zhao
  2026-09-02  6:45 ` [PATCH v2 2/3] mm: trace: decode MTE and shadow stack VMA flags Meijing Zhao
  2026-09-02  6:45 ` [PATCH v2 3/3] mm: trace: name protection key encoding bits Meijing Zhao
  2 siblings, 0 replies; 4+ messages in thread
From: Meijing Zhao @ 2026-09-02  6:45 UTC (permalink / raw)
  To: Lorenzo Stoakes, Andrew Morton
  Cc: Meijing Zhao, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Wandun Chen, linux-mm, linux-trace-kernel, linux-kernel

From: Meijing Zhao <zhaomeijing@lixiang.com>

The VM_ARCH_1 bit has architecture-specific meanings.  show_vma_flags(),
which is used by VMA tracepoints and %pGv, already reports the powerpc,
parisc and no-MMU meanings, but falls back to the generic "arch_1" name
on arm64 and sparc64.

Report VM_ARM64_BTI as "bti" and VM_SPARC_ADI as "adi" so trace output
and %pGv dumps expose the actual architecture-specific state.

Signed-off-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
 include/trace/events/mmflags.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 935893e5ea53..02caeaf359ab 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -168,6 +168,10 @@ IF_HAVE_PG_ARCH_3(arch_3)
 #define __VM_ARCH_SPECIFIC_1 {VM_SAO,     "sao"           }
 #elif defined(CONFIG_PARISC)
 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP,	"growsup"	}
+#elif defined(CONFIG_SPARC64)
+#define __VM_ARCH_SPECIFIC_1 {VM_SPARC_ADI, "adi"		}
+#elif defined(CONFIG_ARM64)
+#define __VM_ARCH_SPECIFIC_1 {VM_ARM64_BTI, "bti"		}
 #elif !defined(CONFIG_MMU)
 #define __VM_ARCH_SPECIFIC_1 {VM_MAPPED_COPY,"mappedcopy"	}
 #else
-- 
2.25.1


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

* [PATCH v2 2/3] mm: trace: decode MTE and shadow stack VMA flags
  2026-09-02  6:45 [PATCH v2 0/3] mm: trace: decode architecture-specific VMA flags Meijing Zhao
  2026-09-02  6:45 ` [PATCH v2 1/3] mm: trace: decode arm64 and sparc64 VM_ARCH_1 flags Meijing Zhao
@ 2026-09-02  6:45 ` Meijing Zhao
  2026-09-02  6:45 ` [PATCH v2 3/3] mm: trace: name protection key encoding bits Meijing Zhao
  2 siblings, 0 replies; 4+ messages in thread
From: Meijing Zhao @ 2026-09-02  6:45 UTC (permalink / raw)
  To: Lorenzo Stoakes, Andrew Morton
  Cc: Meijing Zhao, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Wandun Chen, linux-mm, linux-trace-kernel, linux-kernel

From: Meijing Zhao <zhaomeijing@lixiang.com>

show_vma_flags(), which is used by VMA tracepoints and %pGv, leaves
architecture-specific HIGH_ARCH_* bits unnamed.  Arm64 MTE flags and
user shadow stack flags are therefore printed as raw hexadecimal values.

These bit positions are shared between architectures.  For example, bit
37 represents VM_MTE_ALLOWED on arm64 but VM_SHADOW_STACK on x86, so a
shared HIGH_ARCH_* bit cannot be given an unconditional name.

Add conditionally compiled names for VM_MTE, VM_MTE_ALLOWED and
VM_SHADOW_STACK.  Keep the configuration guards aligned with the
definitions of these aliases so each shared bit position is decoded
according to the target architecture.

For example, an arm64 VMA containing VM_MTE_ALLOWED is now printed as:

  ...|account|mte_allowed|...

instead of:

  ...|account|0x2000000000

Signed-off-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
 include/trace/events/mmflags.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 02caeaf359ab..2f980d20a9f6 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -202,6 +202,19 @@ IF_HAVE_PG_ARCH_3(arch_3)
 # define IF_HAVE_VM_DROPPABLE(flag, name)
 #endif
 
+#ifdef CONFIG_ARM64_MTE
+# define IF_HAVE_VM_MTE(flag, name) {flag, name},
+#else
+# define IF_HAVE_VM_MTE(flag, name)
+#endif
+
+#if defined(CONFIG_X86_USER_SHADOW_STACK) || defined(CONFIG_RISCV_USER_CFI) || \
+	defined(CONFIG_ARM64_GCS)
+# define IF_HAVE_VM_SHADOW_STACK(flag, name) {flag, name},
+#else
+# define IF_HAVE_VM_SHADOW_STACK(flag, name)
+#endif
+
 #define __def_vmaflag_names						\
 	{VM_READ,			"read"		},		\
 	{VM_WRITE,			"write"		},		\
@@ -237,6 +250,9 @@ IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY,	"softdirty"	)		\
 	{VM_HUGEPAGE,			"hugepage"	},		\
 	{VM_NOHUGEPAGE,			"nohugepage"	},		\
 IF_HAVE_VM_DROPPABLE(VM_DROPPABLE,	"droppable"	)		\
+IF_HAVE_VM_MTE(VM_MTE,			"mte")			\
+IF_HAVE_VM_MTE(VM_MTE_ALLOWED,		"mte_allowed")		\
+IF_HAVE_VM_SHADOW_STACK(VM_SHADOW_STACK, "shadow_stack")	\
 	{VM_MERGEABLE,			"mergeable"	}		\
 
 #define show_vma_flags(flags)						\
-- 
2.25.1


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

* [PATCH v2 3/3] mm: trace: name protection key encoding bits
  2026-09-02  6:45 [PATCH v2 0/3] mm: trace: decode architecture-specific VMA flags Meijing Zhao
  2026-09-02  6:45 ` [PATCH v2 1/3] mm: trace: decode arm64 and sparc64 VM_ARCH_1 flags Meijing Zhao
  2026-09-02  6:45 ` [PATCH v2 2/3] mm: trace: decode MTE and shadow stack VMA flags Meijing Zhao
@ 2026-09-02  6:45 ` Meijing Zhao
  2 siblings, 0 replies; 4+ messages in thread
From: Meijing Zhao @ 2026-09-02  6:45 UTC (permalink / raw)
  To: Lorenzo Stoakes, Andrew Morton
  Cc: Meijing Zhao, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Wandun Chen, linux-mm, linux-trace-kernel, linux-kernel

From: Meijing Zhao <zhaomeijing@lixiang.com>

Protection keys are encoded in architecture-specific HIGH_ARCH_* VMA
flag bits.  show_vma_flags(), which is used by VMA tracepoints and %pGv,
does not name those bits, leaving them as raw hexadecimal values.

Name the protection-key encoding bits pkey_bit0 through pkey_bit4 under
CONFIG_ARCH_HAS_PKEYS.  The names make clear that these are bits of one
protection-key value rather than independent protection keys.  For
example, protection key 3 is represented as:

  pkey_bit0|pkey_bit1

Honor CONFIG_ARCH_PKEY_BITS when exposing bit 3 and bit 4 so only bits
provided by the architecture are included.

Signed-off-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
 include/trace/events/mmflags.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 2f980d20a9f6..ef9aa388b84f 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -202,6 +202,24 @@ IF_HAVE_PG_ARCH_3(arch_3)
 # define IF_HAVE_VM_DROPPABLE(flag, name)
 #endif
 
+#ifdef CONFIG_ARCH_HAS_PKEYS
+# define IF_HAVE_VM_PKEY(flag, name) {flag, name},
+#if CONFIG_ARCH_PKEY_BITS > 3
+# define IF_HAVE_VM_PKEY3(flag, name) {flag, name},
+#else
+# define IF_HAVE_VM_PKEY3(flag, name)
+#endif
+#if CONFIG_ARCH_PKEY_BITS > 4
+# define IF_HAVE_VM_PKEY4(flag, name) {flag, name},
+#else
+# define IF_HAVE_VM_PKEY4(flag, name)
+#endif
+#else
+# define IF_HAVE_VM_PKEY(flag, name)
+# define IF_HAVE_VM_PKEY3(flag, name)
+# define IF_HAVE_VM_PKEY4(flag, name)
+#endif
+
 #ifdef CONFIG_ARM64_MTE
 # define IF_HAVE_VM_MTE(flag, name) {flag, name},
 #else
@@ -250,6 +268,11 @@ IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY,	"softdirty"	)		\
 	{VM_HUGEPAGE,			"hugepage"	},		\
 	{VM_NOHUGEPAGE,			"nohugepage"	},		\
 IF_HAVE_VM_DROPPABLE(VM_DROPPABLE,	"droppable"	)		\
+IF_HAVE_VM_PKEY(VM_PKEY_BIT0,		"pkey_bit0")		\
+IF_HAVE_VM_PKEY(VM_PKEY_BIT1,		"pkey_bit1")		\
+IF_HAVE_VM_PKEY(VM_PKEY_BIT2,		"pkey_bit2")		\
+IF_HAVE_VM_PKEY3(VM_PKEY_BIT3,		"pkey_bit3")		\
+IF_HAVE_VM_PKEY4(VM_PKEY_BIT4,		"pkey_bit4")		\
 IF_HAVE_VM_MTE(VM_MTE,			"mte")			\
 IF_HAVE_VM_MTE(VM_MTE_ALLOWED,		"mte_allowed")		\
 IF_HAVE_VM_SHADOW_STACK(VM_SHADOW_STACK, "shadow_stack")	\
-- 
2.25.1

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

end of thread, other threads:[~2026-09-02  6:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02  6:45 [PATCH v2 0/3] mm: trace: decode architecture-specific VMA flags Meijing Zhao
2026-09-02  6:45 ` [PATCH v2 1/3] mm: trace: decode arm64 and sparc64 VM_ARCH_1 flags Meijing Zhao
2026-09-02  6:45 ` [PATCH v2 2/3] mm: trace: decode MTE and shadow stack VMA flags Meijing Zhao
2026-09-02  6:45 ` [PATCH v2 3/3] mm: trace: name protection key encoding bits Meijing Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.