[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANpmjNP=_g4Ecfyk7h-Z1bSWho3MXNU3CO_a77zs+phhUZu76Q@mail.gmail.com>
Date: Mon, 15 Dec 2025 13:11:45 +0100
From: Marco Elver <elver@...gle.com>
To: Brendan Jackman <jackmanb@...gle.com>
Cc: Andrey Ryabinin <ryabinin.a.a@...il.com>, Alexander Potapenko <glider@...gle.com>,
Andrey Konovalov <andreyknvl@...il.com>, Dmitry Vyukov <dvyukov@...gle.com>,
Vincenzo Frascino <vincenzo.frascino@....com>, Ard Biesheuvel <ardb@...nel.org>, kasan-dev@...glegroups.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/3] kcsan: mark !__SANITIZE_THREAD__ stub __always_inline
On Mon, 15 Dec 2025 at 11:12, Brendan Jackman <jackmanb@...gle.com> wrote:
>
> The x86 instrumented bitops in
> include/asm-generic/bitops/instrumented-non-atomic.h are
> KCSAN-instrumented via explicit calls to instrument_* functions from
> include/linux/instrumented.h.
>
> This bitops are used from noinstr code in __sev_es_nmi_complete(). This
> code avoids noinstr violations by disabling __SANITIZE_THREAD__ etc for
> the compilation unit.
>
> However, when GCOV is enabled, there can still be violations caused by
> the stub versions of these functions, since coverage instrumentation is
> injected that causes them to be out-of-lined.
>
> Fix this by just applying __always_inline.
>
> Signed-off-by: Brendan Jackman <jackmanb@...gle.com>
> ---
> include/linux/kcsan-checks.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/kcsan-checks.h b/include/linux/kcsan-checks.h
> index 92f3843d9ebb8177432bb4eccc151ea66d3dcbb7..cabb2ae46bdc0963bd89533777cab586ab4d5a1b 100644
> --- a/include/linux/kcsan-checks.h
> +++ b/include/linux/kcsan-checks.h
> @@ -226,7 +226,7 @@ static inline void kcsan_end_scoped_access(struct kcsan_scoped_access *sa) { }
> #define __kcsan_disable_current kcsan_disable_current
> #define __kcsan_enable_current kcsan_enable_current_nowarn
> #else /* __SANITIZE_THREAD__ */
> -static inline void kcsan_check_access(const volatile void *ptr, size_t size,
> +static __always_inline void kcsan_check_access(const volatile void *ptr, size_t size,
> int type) { }
> static inline void __kcsan_enable_current(void) { }
> static inline void __kcsan_disable_current(void) { }
It wouldn't be wrong to apply __always_inline to these 2 stub
functions as well, but I think it's fair if you just limit this to the
ones used from <linux/instrumented.h>. Either way, please
double-check.
Powered by blists - more mailing lists