public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Noinstr fixes for K[CA]SAN with GCOV
@ 2025-12-16 10:16 Brendan Jackman
  2025-12-16 10:16 ` [PATCH v3 1/3] kasan: mark !__SANITIZE_ADDRESS__ stubs __always_inline Brendan Jackman
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Brendan Jackman @ 2025-12-16 10:16 UTC (permalink / raw)
  To: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
	Dmitry Vyukov, Vincenzo Frascino, Marco Elver, Ard Biesheuvel,
	Andrew Morton, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: kasan-dev, linux-kernel, llvm, Brendan Jackman

As discussed in [2], the GCOV+*SAN issue is attacked from two angles:
both adding __always_inline to the instrumentation helpers AND disabling
GCOV for noinstr.c. Only one or the other of these things is needed to
make the build error go away, but they both make sense in their own
right and both may serve to prevent other similar errors from cropping
up in future.

Note I have not annotated !CONFIG_* stubs, only !__SANITIZE_*__ ones.
That's because for global settings (i.e. kconfig) it remains a bug to
call these stubs from the wrong context and we'd probably like to detect
that bug even if it could be eliminated from the current build. 

Concretely, the above is talking about KMSAN, i.e. stuff like
instrument_copy_from_user().

Other than that, I think everything in include/linux/instrumented.h is
covered now.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
Details:

 - ❯❯  clang --version
   Debian clang version 19.1.7 (3+build5)
   Target: x86_64-pc-linux-gnu
   Thread model: posix
   InstalledDir: /usr/lib/llvm-19/bin

 - Kernel config:

   https://gist.githubusercontent.com/bjackman/bbfdf4ec2e1dfd0e18657174f0537e2c/raw/a88dcc6567d14c69445e7928a7d5dfc23ca9f619/gistfile0.txt

Note I also get this error:

vmlinux.o: warning: objtool: set_ftrace_ops_ro+0x3b: relocation to !ENDBR: machine_kexec_prepare+0x810

That one's a total mystery to me. I guess it's better to "fix" the SEV
one independently rather than waiting until I know how to fix them both.

Note I also mentioned other similar errors in [0]. Those errors don't
exist in Linus' master and I didn't note down where I saw them. Either
they have since been fixed, or I observed them in Google's internal
codebase where they were instroduced downstream.

Changes in v3:
- Also fix __kcsan_{dis,en}able_current()
- Link to v2: https://lore.kernel.org/r/20251215-gcov-inline-noinstr-v2-0-6f100b94fa99@google.com

Changes in v2:
- Also disable GCOV for noinstr.c (i.e. squash in [0]).
- Link to v1: [2] 

[0] https://lore.kernel.org/all/DERNCQGNRITE.139O331ACPKZ9@google.com/
[1] https://lore.kernel.org/all/20251117-b4-sev-gcov-objtool-v1-1-54f7790d54df@google.com/
[2] https://lore.kernel.org/r/20251208-gcov-inline-noinstr-v1-0-623c48ca5714@google.com

---
Brendan Jackman (3):
      kasan: mark !__SANITIZE_ADDRESS__ stubs __always_inline
      kcsan: mark !__SANITIZE_THREAD__ stubs __always_inline
      x86/sev: Disable GCOV on noinstr object

 arch/x86/coco/sev/Makefile   | 2 ++
 include/linux/kasan-checks.h | 4 ++--
 include/linux/kcsan-checks.h | 8 ++++----
 3 files changed, 8 insertions(+), 6 deletions(-)
---
base-commit: 40fbbd64bba6c6e7a72885d2f59b6a3be9991eeb
change-id: 20251208-gcov-inline-noinstr-1550cfee445c

Best regards,
-- 
Brendan Jackman <jackmanb@google.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-01-05  9:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16 10:16 [PATCH v3 0/3] Noinstr fixes for K[CA]SAN with GCOV Brendan Jackman
2025-12-16 10:16 ` [PATCH v3 1/3] kasan: mark !__SANITIZE_ADDRESS__ stubs __always_inline Brendan Jackman
2025-12-16 13:01   ` Peter Zijlstra
2025-12-17 13:53     ` Brendan Jackman
2025-12-18  9:24       ` Peter Zijlstra
2025-12-19 11:45         ` Brendan Jackman
2026-01-04  6:07         ` Borislav Petkov
2025-12-16 10:16 ` [PATCH v3 2/3] kcsan: mark !__SANITIZE_THREAD__ " Brendan Jackman
2025-12-16 10:16 ` [PATCH v3 3/3] x86/sev: Disable GCOV on noinstr object Brendan Jackman
2026-01-05  9:47   ` [tip: x86/urgent] " tip-bot2 for Brendan Jackman
2025-12-16 10:18 ` [PATCH v3 0/3] Noinstr fixes for K[CA]SAN with GCOV Marco Elver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox