All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kristina Martšenko" <kristina.martsenko@arm.com>,
	kvmarm@lists.linux.dev, linux-efi@vger.kernel.org
Cc: "Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Linu Cherian" <linu.cherian@arm.com>,
	"Anshuman Khandual" <anshuman.khandual@arm.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Hanjun Guo" <guohanjun@huawei.com>,
	"Sudeep Holla" <sudeep.holla@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>,
	"Oliver Upton" <oupton@kernel.org>,
	"Fuad Tabba" <fuad.tabba@linux.dev>,
	"Joey Gouly" <joey.gouly@arm.com>,
	"Steffen Eiden" <seiden@linux.ibm.com>,
	"Suzuki K Poulose" <suzuki.poulose@arm.com>,
	"Zenghui Yu" <yuzenghui@huawei.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Jinqian Yang" <yangjinqian1@huawei.com>,
	"Zi Yan" <ziy@nvidia.com>
Subject: Re: [RFC v2 11/13] arm64: Support TLBIP instructions
Date: Thu, 26 Nov 2026 12:06:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-235475@kernel.org> (raw)
In-Reply-To: <20261126114936.864256-12-kristina.martsenko@arm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] arm64: tlb: missing __always_inline on __tlbi_level() and guard
  on __tlbip()
- [Low] arm64: tlb: missing #undef __tlbip_user at end of asm/tlbflush.h
--

commit 483f71029edea8a91bc6a1e440a10493264ee5af
Author: Kristina Martšenko <kristina.martsenko@arm.com>

arm64: Support TLBIP instructions

This commit updates the TLBI helper functions in asm/tlbflush.h to issue
128-bit TLBIP instructions when requested and adds a Kconfig check for
assembler support of FEAT_TLBID.

> diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
> index 8338d780ca595..da7f99d722a58 100644
> --- a/arch/arm64/include/asm/tlbflush.h
> +++ b/arch/arm64/include/asm/tlbflush.h
> @@ -41,11 +41,27 @@
>  
>  #define __tlbi(op, ...)		__TLBI_N(op, ##__VA_ARGS__, 1, 0)
>  
> +#define __tlbip(op, arg) do {							\
> +	u128 __arg = (arg);							\
> +	register u64 low asm ("x0") = (u64)__arg;				\
> +	register u64 high asm ("x1") = (u64)(__arg >> 64);			\
> +										\
> +	asm (ARM64_ASM_PREAMBLE ".arch_extension tlbid\n"			\
> +	     "tlbip " #op ", %0, %1\n"						\
> +	  : : "r" (low), "r" (high));						\
> +} while (0)
> +
>  #define __tlbi_user(op, arg) do {						\
>  	if (arm64_kernel_unmapped_at_el0())					\
>  		__tlbi(op, (arg) | USER_ASID_FLAG);				\
>  } while (0)
>  
> +#define __tlbip_user(op, arg) do {						\
> +	if (arm64_kernel_unmapped_at_el0()) {					\
> +		__tlbip(op, (arg) | (u128)USER_ASID_FLAG);			\
> +	}									\
> +} while (0)

[Severity: Low]
Should __tlbip_user be undefined at the end of asm/tlbflush.h alongside
#undef __tlbi_user?  Commit edc55b7abb25 ("arm64: mm: Implicitly
invalidate user ASID based on TLBI operation") added #undef __tlbi_user so
the internal helper would not leak to translation units including this
header.

> @@ -132,49 +148,75 @@ static inline void sme_dvmsync_batch(void)

[ ... ]

> -static __always_inline void ipas2e1(u64 arg)
> +static __always_inline void ipas2e1(bool tlbip, u128 arg)
>  {
> -	__tlbi(ipas2e1, arg);
> +	compiletime_assert(!tlbip, "Unsupported TLBIP operand");
> +
> +	__tlbi(ipas2e1, (u64)arg);
>  }
>  
> -static __always_inline void ipas2e1is(u64 arg)
> +static __always_inline void ipas2e1is(bool tlbip, u128 arg)
>  {
> -	__tlbi(ipas2e1is, arg);
> +	if (tlbip)
> +		__tlbip(ipas2e1is, arg);
> +	else
> +		__tlbi(ipas2e1is, (u64)arg);
>  }
>  
>  static __always_inline void __tlbi_level_asid(tlbi_op op, u64 addr, u32 level,
> @@ -188,7 +230,7 @@ static __always_inline void __tlbi_level_asid(tlbi_op op, u64 addr, u32 level,
>  		FIELD_MODIFY(TLBI_TTL_MASK, &arg, ttl);
>  	}
>  
> -	op(arg);
> +	op(false, arg);
>  }
>  
>  static inline void __tlbi_level(tlbi_op op, u64 addr, u32 level)

[Severity: Low]
Can building fail if the compiler decides not to inline __tlbi_level()?

Unlike __tlbi_level_asid(), __tlbi_range(), and __flush_tlb_range_op(),
__tlbi_level() is marked static inline rather than static __always_inline.
Wait-free elimination of the indirect tlbi_op call relies on inlining the
entire call chain from callers such as __kvm_tlb_flush_vmid_ipa_nsh(),
which passes ipas2e1 to __tlbi_level().

If __tlbi_level() is not inlined, the tlbi_op callbacks passed to it are
instantiated out-of-line with a non-constant tlbip argument:
compiletime_assert(!tlbip, ...) in ipas2e1() will fail compilation, and
__tlbip() in helpers such as ipas2e1is() will emit .arch_extension tlbid
and tlbip instructions even when CONFIG_ARM64_TLBID=n and
CONFIG_AS_HAS_TLBID=n.

Marking __tlbi_level() as static __always_inline and guarding __tlbip()
with CONFIG_ARM64_TLBID would avoid depending on inlining heuristics.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126114936.864256-1-kristina.martsenko@arm.com?part=11

  reply	other threads:[~2026-11-26 12:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 11:49 [RFC v2 00/13] arm64: Add support for TLBI domains Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 01/13] arm64: sysreg: Add definitions for TLBID Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 02/13] arm64: boot: Handle TLBID boot requirements Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 03/13] arm64: Detect TLBID Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 04/13] KVM: arm64: Hide TLBID from guest sysregs Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 05/13] KVM: arm64: Hide TLBID from guest instructions Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 06/13] ACPICA: Add TLBI table definition Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 07/13] ACPI: TLBI: Parse domains from table Kristina Martšenko
2026-11-26 12:04   ` sashiko-bot
2026-11-26 11:49 ` [RFC v2 08/13] arm64: tlbid: Set up CPU domain bitmaps Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 09/13] efi/arm: Check return value of init_new_context() Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 10/13] arm64: tlbid: Track the TLBI domain of a task Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 11/13] arm64: Support TLBIP instructions Kristina Martšenko
2026-11-26 12:06   ` sashiko-bot [this message]
2026-11-26 11:49 ` [RFC v2 12/13] arm64: tlbid: Pass domain to TLBI instructions Kristina Martšenko
2026-11-26 11:49 ` [RFC v2 13/13] arm64: tlbid: Add documentation Kristina Martšenko

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=sashiko-outbox-235475@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=david@kernel.org \
    --cc=fuad.tabba@linux.dev \
    --cc=guohanjun@huawei.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=joey.gouly@arm.com \
    --cc=kristina.martsenko@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linu.cherian@arm.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seiden@linux.ibm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yangjinqian1@huawei.com \
    --cc=yuzenghui@huawei.com \
    --cc=ziy@nvidia.com \
    /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 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.