Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Pierre-Clément Tosi" <ptosi@google.com>
To: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	 "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: "Marc Zyngier" <maz@kernel.org>,
	"Fuad Tabba" <fuad.tabba@linux.dev>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Pierre-Clément Tosi" <ptosi@google.com>
Subject: [PATCH 2/4] arm64: Introduce <asm/mte-tagging.h>
Date: Tue, 01 Dec 2026 15:49:18 +0100	[thread overview]
Message-ID: <20261201-mte-page-api-v1-2-5e38d19462ea@google.com> (raw)
In-Reply-To: <20261201-mte-page-api-v1-0-5e38d19462ea@google.com>

Since mte.h is included by multiple low-level headers such as pgtable.h
or uaccess.h, it is hard to extend it without falling into circular
dependency traps. This is specifically relevant since upcoming patches
will need to call linux/mm.h macros, which would break the build as-is.

One way to get around this issue would be to add new code in *.c files,
like commit da9f24dc4336 ("arm64: mte: Add mte_clear_folio_tags()") had
to do but that isn't ideal for simple helpers which the compiler should
ideally be able to inline.

A cleaner alternative is to split up mte.h into more fundamental headers
and untangle the different clients. For example, pgtable.h only needs
mte.h for swap logic while uaccess.h uses it for TCO-guarded sections.

Therefore, introduce a dedicated header for tagging functions, mostly
intended to be included from *.c files and such that it itself can
include headers such as linux/mm.h without triggering circular includes.

For now, include it from all callers of mte_[zero_]clear_page_tags() and
limit the header to including mte.h. Future commits will build on that.

Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
---
 arch/arm64/include/asm/mte-tagging.h | 13 +++++++++++++
 arch/arm64/kernel/cpufeature.c       |  1 +
 arch/arm64/kernel/mte.c              |  1 +
 arch/arm64/kvm/guest.c               |  1 +
 arch/arm64/kvm/mmu.c                 |  1 +
 arch/arm64/mm/fault.c                |  1 +
 6 files changed, 18 insertions(+)

diff --git a/arch/arm64/include/asm/mte-tagging.h b/arch/arm64/include/asm/mte-tagging.h
new file mode 100644
index 000000000000..5da9c6433fb8
--- /dev/null
+++ b/arch/arm64/include/asm/mte-tagging.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * MTE tagging helpers.
+ *
+ * Header dedicated to tagging functions, pulled out of <asm/mte.h> to simplify
+ * the header dependency graph and intended to mostly be included from .c files.
+ */
+#ifndef __ASM_MTE_TAGGING_H
+#define __ASM_MTE_TAGGING_H
+
+#include <asm/mte.h>
+
+#endif /* __ASM_MTE_TAGGING_H */
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 8265803357c1..e817d49037a6 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -88,6 +88,7 @@
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/mpam.h>
+#include <asm/mte-tagging.h>
 #include <asm/mte.h>
 #include <asm/hypervisor.h>
 #include <asm/processor.h>
diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
index 850bcee21e77..0aadaabbe31e 100644
--- a/arch/arm64/kernel/mte.c
+++ b/arch/arm64/kernel/mte.c
@@ -21,6 +21,7 @@
 
 #include <asm/barrier.h>
 #include <asm/cpufeature.h>
+#include <asm/mte-tagging.h>
 #include <asm/mte.h>
 #include <asm/ptrace.h>
 #include <asm/sysreg.h>
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index b7d36c2abfdf..fc6d067b97ef 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -25,6 +25,7 @@
 #include <asm/kvm.h>
 #include <asm/kvm_emulate.h>
 #include <asm/kvm_nested.h>
+#include <asm/mte-tagging.h>
 #include <asm/sigcontext.h>
 
 #include "trace.h"
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index a0d4981ebb99..0ae2e19d0bc6 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -22,6 +22,7 @@
 #include <asm/kvm_pkvm.h>
 #include <asm/kvm_asm.h>
 #include <asm/kvm_emulate.h>
+#include <asm/mte-tagging.h>
 #include <asm/virt.h>
 
 #include "trace.h"
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index cf855aa1c30f..e093e8473b5e 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -39,6 +39,7 @@
 #include <asm/debug-monitors.h>
 #include <asm/esr.h>
 #include <asm/kprobes.h>
+#include <asm/mte-tagging.h>
 #include <asm/mte.h>
 #include <asm/processor.h>
 #include <asm/sysreg.h>

-- 
2.56.1.839.g22a8290db9-goog



  parent reply	other threads:[~2026-12-01 14:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 14:49 [PATCH 0/4] Expand MTE tagging API to multi-page and !0 tags Pierre-Clément Tosi
2026-12-01 14:49 ` [PATCH 1/4] arm64: Introduce mte_tag_of()/mte_tagged() helpers Pierre-Clément Tosi
2026-12-01 14:49 ` Pierre-Clément Tosi [this message]
2026-12-01 14:49 ` [PATCH 3/4] arm64: Introduce mte_tag_page[s]() Pierre-Clément Tosi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201-mte-page-api-v1-2-5e38d19462ea@google.com \
    --to=ptosi@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=fuad.tabba@linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox