From nobody Mon Feb 9 11:05:06 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 106C731A7E1 for ; Mon, 19 Jan 2026 17:22:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768843340; cv=none; b=ct+3jrZK/08MzJi/2Fe72kbZDNwREy0+bkiCd/eigtCZvlK1fMEo+J5oY1P2m34Dwpogl03K1zDVRWmf8R9w7jGd3TNiODXYrfMRG5jNZVGZ732fdStbjaji1/IDxKWPzl8/WwbtZhBpVJP3z5xcCOt0mozBdYPK1Dv64w1K//Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768843340; c=relaxed/simple; bh=+9okBmb4A6JfMPaO89u7gn/tW27gU1QYcF5WHazg0Fg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCLZgjV+TPFZtaaNr51d9u9c18tvt8NBDRSnUej4OgV4eWRSCgJlfnZGcyNlI90VPGdXjTEv89mcNwzL1liQWVHvVA/17K7VCqIsyHHCInUooKT1AphXyHpPx7tLCny/5D6UdrsmORU16WUV6Q2dm8FN5Y/mOWu6nrCZw/yLlYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DD7F91476; Mon, 19 Jan 2026 09:22:11 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F00963F632; Mon, 19 Jan 2026 09:22:16 -0800 (PST) From: Ryan Roberts To: Will Deacon , Ard Biesheuvel , Catalin Marinas , Mark Rutland , Linus Torvalds , Oliver Upton , Marc Zyngier , Dev Jain , Linu Cherian , Jonathan Cameron Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 02/13] arm64: mm: Introduce a C wrapper for by-range TLB invalidation Date: Mon, 19 Jan 2026 17:21:49 +0000 Message-ID: <20260119172202.1681510-3-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119172202.1681510-1-ryan.roberts@arm.com> References: <20260119172202.1681510-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As part of efforts to reduce our reliance on complex preprocessor macros for TLB invalidation routines, introduce a new C wrapper for by-range TLB invalidation which can be used instead of the __tlbi() macro and can additionally be called from C code. Each specific tlbi range op is implemented as a C function and the appropriate function pointer is passed to __tlbi_range(). Since everything is declared inline and is statically resolvable, the compiler will convert the indirect function call to a direct inline execution. Suggested-by: Linus Torvalds Signed-off-by: Ryan Roberts Reviewed-by: Jonathan Cameron --- arch/arm64/include/asm/tlbflush.h | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlb= flush.h index a8ca2593a289..acd59bc61e00 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -457,6 +457,36 @@ static inline void arch_tlbbatch_flush(struct arch_tlb= flush_unmap_batch *batch) * operations can only span an even number of pages. We save this for l= ast to * ensure 64KB start alignment is maintained for the LPA2 case. */ +static __always_inline void rvae1is(u64 arg) +{ + __tlbi(rvae1is, arg); +} + +static __always_inline void rvale1(u64 arg) +{ + __tlbi(rvale1, arg); +} + +static __always_inline void rvale1is(u64 arg) +{ + __tlbi(rvale1is, arg); +} + +static __always_inline void rvaale1is(u64 arg) +{ + __tlbi(rvaale1is, arg); +} + +static __always_inline void ripas2e1is(u64 arg) +{ + __tlbi(ripas2e1is, arg); +} + +static __always_inline void __tlbi_range(tlbi_op op, u64 arg) +{ + op(arg); +} + #define __flush_tlb_range_op(op, start, pages, stride, \ asid, tlb_level, tlbi_user, lpa2) \ do { \ @@ -484,7 +514,7 @@ do { \ if (num >=3D 0) { \ addr =3D __TLBI_VADDR_RANGE(__flush_start >> shift, asid, \ scale, num, tlb_level); \ - __tlbi(r##op, addr); \ + __tlbi_range(r##op, addr); \ if (tlbi_user) \ __tlbi_user(r##op, addr); \ __flush_start +=3D __TLBI_RANGE_PAGES(num, scale) << PAGE_SHIFT; \ --=20 2.43.0