[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250711161732.384-2-will@kernel.org>
Date: Fri, 11 Jul 2025 17:17:23 +0100
From: Will Deacon <will@...nel.org>
To: linux-arm-kernel@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org,
Will Deacon <will@...nel.org>,
Ard Biesheuvel <ardb@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Ryan Roberts <ryan.roberts@....com>,
Mark Rutland <mark.rutland@....com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Oliver Upton <oliver.upton@...ux.dev>,
Marc Zyngier <maz@...nel.org>
Subject: [PATCH 01/10] arm64: mm: Introduce a C wrapper for by-level TLB invalidation helpers
In preparation for reducing our reliance on complex preprocessor macros
for TLB invalidation routines, introduce a new C wrapper for by-level
TLB invalidation helpers which can be used instead of the __tlbi() macro
and can additionally be called from C code.
Signed-off-by: Will Deacon <will@...nel.org>
---
arch/arm64/include/asm/tlbflush.h | 33 ++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
index aa9efee17277..1c7548ec6cb7 100644
--- a/arch/arm64/include/asm/tlbflush.h
+++ b/arch/arm64/include/asm/tlbflush.h
@@ -88,6 +88,16 @@ static inline unsigned long get_trans_granule(void)
}
}
+enum tlbi_op {
+ vae1is,
+ vae2is,
+ vale1is,
+ vale2is,
+ vaale1is,
+ ipas2e1,
+ ipas2e1is,
+};
+
/*
* Level-based TLBI operations.
*
@@ -105,6 +115,27 @@ static inline unsigned long get_trans_granule(void)
#define TLBI_TTL_UNKNOWN INT_MAX
+#define __GEN_TLBI_OP_CASE(op) \
+ case op: \
+ __tlbi(op, arg); \
+ break
+
+static __always_inline void __tlbi_level_op(const enum tlbi_op op, u64 arg)
+{
+ switch (op) {
+ __GEN_TLBI_OP_CASE(vae1is);
+ __GEN_TLBI_OP_CASE(vae2is);
+ __GEN_TLBI_OP_CASE(vale1is);
+ __GEN_TLBI_OP_CASE(vale2is);
+ __GEN_TLBI_OP_CASE(vaale1is);
+ __GEN_TLBI_OP_CASE(ipas2e1);
+ __GEN_TLBI_OP_CASE(ipas2e1is);
+ default:
+ BUILD_BUG();
+ }
+}
+#undef __GEN_TLBI_OP_CASE
+
#define __tlbi_level(op, addr, level) do { \
u64 arg = addr; \
\
@@ -116,7 +147,7 @@ static inline unsigned long get_trans_granule(void)
arg |= FIELD_PREP(TLBI_TTL_MASK, ttl); \
} \
\
- __tlbi(op, arg); \
+ __tlbi_level_op(op, arg); \
} while(0)
#define __tlbi_user_level(op, arg, level) do { \
--
2.50.0.727.gbf7dc18ff4-goog
Powered by blists - more mailing lists