Skip to content

Commit d2bf322

Browse files
ryanhrobctmarinas
authored andcommitted
arm64: mm: Introduce a C wrapper for by-range TLB invalidation
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 <torvalds@linux-foundation.org> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 5b3fb8a commit d2bf322

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

arch/arm64/include/asm/tlbflush.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,36 @@ static inline void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch)
468468
* operations can only span an even number of pages. We save this for last to
469469
* ensure 64KB start alignment is maintained for the LPA2 case.
470470
*/
471+
static __always_inline void rvae1is(u64 arg)
472+
{
473+
__tlbi(rvae1is, arg);
474+
}
475+
476+
static __always_inline void rvale1(u64 arg)
477+
{
478+
__tlbi(rvale1, arg);
479+
}
480+
481+
static __always_inline void rvale1is(u64 arg)
482+
{
483+
__tlbi(rvale1is, arg);
484+
}
485+
486+
static __always_inline void rvaale1is(u64 arg)
487+
{
488+
__tlbi(rvaale1is, arg);
489+
}
490+
491+
static __always_inline void ripas2e1is(u64 arg)
492+
{
493+
__tlbi(ripas2e1is, arg);
494+
}
495+
496+
static __always_inline void __tlbi_range(tlbi_op op, u64 arg)
497+
{
498+
op(arg);
499+
}
500+
471501
#define __flush_tlb_range_op(op, start, pages, stride, \
472502
asid, tlb_level, tlbi_user, lpa2) \
473503
do { \
@@ -495,7 +525,7 @@ do { \
495525
if (num >= 0) { \
496526
addr = __TLBI_VADDR_RANGE(__flush_start >> shift, asid, \
497527
scale, num, tlb_level); \
498-
__tlbi(r##op, addr); \
528+
__tlbi_range(r##op, addr); \
499529
if (tlbi_user) \
500530
__tlbi_user(r##op, addr); \
501531
__flush_start += __TLBI_RANGE_PAGES(num, scale) << PAGE_SHIFT; \

0 commit comments

Comments
 (0)