Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jisheng Zhang" <jszhang@kernel.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Andrey Ryabinin" <ryabinin.a.a@gmail.com>,
	"Alexander Potapenko" <glider@google.com>,
	"Andrey Konovalov" <andreyknvl@gmail.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
	"Tejun Heo" <tj@kernel.org>, "Dennis Zhou" <dennis@kernel.org>,
	"Christoph Lameter" <cl@gentwo.org>
Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org
Subject: Re: [PATCH 2/4] arm64: entry: Always inline helpers used by non-instrumentable paths
Date: Sun, 08 Nov 2026 07:43:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-203634@kernel.org> (raw)
In-Reply-To: <20261107071339.17467-3-jszhang@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] arm64: entry: kasan_hw_tags_enabled() not marked __always_inline
  for noinstr
- [Low] arm64: entry: sme_{enter,exit} helpers call non-noinstr
  test_thread_flag()
- [Low] arm64: entry: #else stubs for MTE and SME helpers not marked
  __always_inline
--

commit 36003a6dfa6a3ccb4d813e94b64d8956098d7ce8
Author: Jisheng Zhang <jszhang@kernel.org>

arm64: entry: Always inline helpers used by non-instrumentable paths

This commit changes several MTE, SME, CPU feature, and entry helpers from
plain inline to __always_inline so they are not emitted out-of-line in
.text when called from noinstr entry and exit paths.

> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
> index a67d5774e6728..157d0551f6279 100644
> --- a/arch/arm64/include/asm/fpsimd.h
> +++ b/arch/arm64/include/asm/fpsimd.h
> @@ -749,14 +749,14 @@ void sme_enable_dvmsync(void);
>  void sme_set_active(void);
>  void sme_clear_active(void);
>  
> -static inline void sme_enter_from_user_mode(void)
> +static __always_inline void sme_enter_from_user_mode(void)
>  {
>  	if (alternative_has_cap_unlikely(ARM64_WORKAROUND_4193714) &&
>  	    test_thread_flag(TIF_SME))
>  		sme_clear_active();
>  }
>  
> -static inline void sme_exit_to_user_mode(void)
> +static __always_inline void sme_exit_to_user_mode(void)
>  {
>  	if (alternative_has_cap_unlikely(ARM64_WORKAROUND_4193714) &&
>  	    test_thread_flag(TIF_SME))

[Severity: Low]
Should sme_enter_from_user_mode() and sme_exit_to_user_mode() use
tif_test_bit(TIF_SME) instead of test_thread_flag(TIF_SME)?

test_thread_flag() expands to test_ti_thread_flag(), which is plain static
inline and calls instrumented test_bit():

include/linux/thread_info.h:test_ti_thread_flag() {
	return test_bit(flag, (unsigned long *)&ti->flags);
}

Inlining these SME helpers across the noinstr EL0 entry and exit paths in
arch/arm64/kernel/entry-common.c allows the compiler to outline
test_ti_thread_flag() into .text under CONFIG_CC_OPTIMIZE_FOR_SIZE=y or emit
bitop instrumentation in .noinstr.text, whereas tif_test_bit() is already
marked __always_inline and avoids bitop instrumentation for noinstr callers.

[ ... ]

> diff --git a/arch/arm64/include/asm/mte.h b/arch/arm64/include/asm/mte.h
> index 83f3b05fc7849..b2bf2e70c9aec 100644
> --- a/arch/arm64/include/asm/mte.h
> +++ b/arch/arm64/include/asm/mte.h
> @@ -222,7 +222,7 @@ static inline bool folio_try_hugetlb_mte_tagging(struct folio *folio)
>  }
>  #endif
>  
> -static inline void mte_disable_tco_entry(struct task_struct *task)
> +static __always_inline void mte_disable_tco_entry(struct task_struct *task)
>  {
>  	if (!system_supports_mte())
>  		return;
> @@ -245,7 +245,7 @@ static inline void mte_disable_tco_entry(struct task_struct *task)
>  #ifdef CONFIG_KASAN_HW_TAGS
>  void mte_check_tfsr_el1(void);
>  
> -static inline void mte_check_tfsr_entry(void)
> +static __always_inline void mte_check_tfsr_entry(void)
>  {
>  	if (!kasan_hw_tags_enabled())
>  		return;

[Severity: Low]
Does kasan_hw_tags_enabled() also need to be marked __always_inline?

mte_disable_tco_entry(), mte_check_tfsr_entry(), and mte_check_tfsr_exit()
all call kasan_hw_tags_enabled(), which is still defined as plain static
inline in include/linux/kasan-enabled.h (even though the underlying
kasan_enabled() helper is already __always_inline). Force-inlining the MTE
entry and exit helpers into arch/arm64/kernel/entry-common.c expands
kasan_hw_tags_enabled() across dozens of noinstr call sites, so GCC with
CONFIG_CC_OPTIMIZE_FOR_SIZE=y and CONFIG_KASAN_HW_TAGS=y can still emit an
out-of-line copy of kasan_hw_tags_enabled() in .text.

> @@ -256,7 +256,7 @@ static inline void mte_check_tfsr_entry(void)
>  	mte_check_tfsr_el1();
>  }
>  
> -static inline void mte_check_tfsr_exit(void)
> +static __always_inline void mte_check_tfsr_exit(void)
>  {
>  	if (!kasan_hw_tags_enabled())
>  		return;

[Severity: Low]
Should the #else stubs for mte_check_tfsr_entry() and mte_check_tfsr_exit()
(when !CONFIG_KASAN_HW_TAGS) and for sme_enter_from_user_mode() and
sme_exit_to_user_mode() in arch/arm64/include/asm/fpsimd.h (when
!CONFIG_ARM64_SME) also be marked __always_inline to match
system_uses_mte_async_or_asymm_mode()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261107071339.17467-1-jszhang@kernel.org?part=2


  reply	other threads:[~2026-11-08  7:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  7:13 [PATCH 0/4] arm64: Fix instrumentation escapes from noinstr path Jisheng Zhang
2026-11-07  7:13 ` [PATCH 1/4] arm64: percpu: Always inline helpers used by noinstr code Jisheng Zhang
2026-11-08  7:43   ` sashiko-bot
2026-11-07  7:13 ` [PATCH 2/4] arm64: entry: Always inline helpers used by non-instrumentable paths Jisheng Zhang
2026-11-08  7:43   ` sashiko-bot [this message]
2026-11-07  7:13 ` [PATCH 3/4] arm64: stacktrace: Always inline internal stack boundary helpers Jisheng Zhang
2026-11-07  7:13 ` [PATCH 4/4] arm64: alternatives: Make branch and ADRP offset helpers noinst Jisheng Zhang
2026-11-08  7:43   ` sashiko-bot

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-203634@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=andreyknvl@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=cl@gentwo.org \
    --cc=dennis@kernel.org \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=jszhang@kernel.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=ryabinin.a.a@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tj@kernel.org \
    --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