Skip to contentSkip to conversation

x86/sev: Work around broken noinstr on GCC

PATCH Applied Ard Biesheuvel 5 participants 5 messages Jul 14, 2025 – Jul 15, 2025 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/sev: Work around broken noinstr on GCC

From: Ard Biesheuvel <[email protected]>

Forcibly disable KCSAN for the sev-nmi.c source file, which only contains functions annotated as 'noinstr' but is emitted with calls to KCSAN instrumentation nonetheless. E.g.,

vmlinux.o: error: objtool: __sev_es_nmi_complete+0x58: call to __kcsan_check_access() leaves .noinstr.text section make[2]: *** [/usr/local/google/home/ardb/linux/scripts/Makefile.vmlinux_o:72: vmlinux.o] Error 1

---
 arch/x86/coco/sev/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/coco/sev/Makefile +2 -1
index db3255b979bd..342d79f0ab6a 100644
@@ -5,5 +5,6 @@ obj-y += core.o sev-nmi.o vc-handle.o
 # Clang 14 and older may fail to respect __no_sanitize_undefined when inlining
 UBSAN_SANITIZE_sev-nmi.o	:= n
 
-# GCC may fail to respect __no_sanitize_address when inlining
+# GCC may fail to respect __no_sanitize_address or __no_kcsan when inlining
 KASAN_SANITIZE_sev-nmi.o	:= n
+KCSAN_SANITIZE_sev-nmi.o	:= n
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
maintainer
#1 lore raw
Quoted 21 lines · Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

Forcibly disable KCSAN for the sev-nmi.c source file, which only contains functions annotated as 'noinstr' but is emitted with calls to KCSAN instrumentation nonetheless. E.g.,

vmlinux.o: error: objtool: __sev_es_nmi_complete+0x58: call to __kcsan_check_access() leaves .noinstr.text section make[2]: *** [/usr/local/google/home/ardb/linux/scripts/Makefile.vmlinux_o:72: vmlinux.o] Error 1

---
 arch/x86/coco/sev/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/coco/sev/Makefile +0 -0
index db3255b979bd..342d79f0ab6a 100644

arch/x86/coco/sev/Makefile obj-y += core.o sev-nmi.o vc-handle.o · line 10

Quoted 7 lines
arch/x86/coco/sev/Makefile +2 -1
@@ -5,5 +5,6 @@ obj-y += core.o sev-nmi.o vc-handle.o
 # Clang 14 and older may fail to respect __no_sanitize_undefined when inlining
 UBSAN_SANITIZE_sev-nmi.o	:= n
 
-# GCC may fail to respect __no_sanitize_address when inlining
+# GCC may fail to respect __no_sanitize_address or __no_kcsan when inlining
 KASAN_SANITIZE_sev-nmi.o	:= n
+KCSAN_SANITIZE_sev-nmi.o	:= n

Hmm, so this points to the carve out:

b66fcee1574e ("x86/sev: Move noinstr NMI handling code into separate source file")

but then we didn't do any KCSAN exclusion to SEV code before either.

I guess send this to Linus now so that it is in 6.16?

Hmm.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#2 lore raw
Quoted 33 lines · Borislav Petkov
Quoted 20 lines · Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

Forcibly disable KCSAN for the sev-nmi.c source file, which only contains functions annotated as 'noinstr' but is emitted with calls to KCSAN instrumentation nonetheless. E.g.,

vmlinux.o: error: objtool: __sev_es_nmi_complete+0x58: call to __kcsan_check_access() leaves .noinstr.text section make[2]: *** [/usr/local/google/home/ardb/linux/scripts/Makefile.vmlinux_o:72: vmlinux.o] Error 1

---
 arch/x86/coco/sev/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/coco/sev/Makefile +0 -0
index db3255b979bd..342d79f0ab6a 100644

arch/x86/coco/sev/Makefile obj-y += core.o sev-nmi.o vc-handle.o

Quoted 8 lines
arch/x86/coco/sev/Makefile +2 -2
@@ -5,5 +5,6 @@ obj-y += core.o sev-nmi.o vc-handle.o
 # Clang 14 and older may fail to respect __no_sanitize_undefined when inlining
 UBSAN_SANITIZE_sev-nmi.o     := n
 
-# GCC may fail to respect __no_sanitize_address when inlining
+# GCC may fail to respect __no_sanitize_address or __no_kcsan when inlining
 KASAN_SANITIZE_sev-nmi.o     := n
+KCSAN_SANITIZE_sev-nmi.o     := n
--

Hmm, so this points to the carve out:

Quoted 4 lines

b66fcee1574e ("x86/sev: Move noinstr NMI handling code into separate source file")

but then we didn't do any KCSAN exclusion to SEV code before either.

This is actually an oversight on my part,

Fixes a3cbbb4717e1 ("x86/boot: Move SEV startup code into startup/")
Quoted 2 lines

I guess send this to Linus now so that it is in 6.16?

Yes.

Acked-by Tested-by on v1 1/1
#3 lore raw
In reply to Ard Biesheuvel
Quoted 10 lines · Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

Forcibly disable KCSAN for the sev-nmi.c source file, which only contains functions annotated as 'noinstr' but is emitted with calls to KCSAN instrumentation nonetheless. E.g.,

vmlinux.o: error: objtool: __sev_es_nmi_complete+0x58: call to __kcsan_check_access() leaves .noinstr.text section make[2]: *** [/usr/local/google/home/ardb/linux/scripts/Makefile.vmlinux_o:72: vmlinux.o] Error 1

Thanks.

Quoted 17 lines
---
 arch/x86/coco/sev/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/coco/sev/Makefile +2 -1
index db3255b979bd..342d79f0ab6a 100644
@@ -5,5 +5,6 @@ obj-y += core.o sev-nmi.o vc-handle.o
 # Clang 14 and older may fail to respect __no_sanitize_undefined when inlining
 UBSAN_SANITIZE_sev-nmi.o	:= n
 
-# GCC may fail to respect __no_sanitize_address when inlining
+# GCC may fail to respect __no_sanitize_address or __no_kcsan when inlining
 KASAN_SANITIZE_sev-nmi.o	:= n
+KCSAN_SANITIZE_sev-nmi.o	:= n
Signature · 1 line
~Randy
merge bot Applied
#4 lore raw
In reply to Ard Biesheuvel
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     6b995d01683feae619aa3263d18a6aa19bface16
Gitweb:        https://git.kernel.org/tip/6b995d01683feae619aa3263d18a6aa19bface16
Author:        Ard Biesheuvel <[email protected]>
AuthorDate:    Mon, 14 Jul 2025 09:34:03 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Tue, 15 Jul 2025 10:12:25 +02:00

x86/sev: Work around broken noinstr on GCC

Forcibly disable KCSAN for the sev-nmi.c source file, which only contains functions annotated as 'noinstr' but is emitted with calls to KCSAN instrumentation nonetheless. E.g.,

vmlinux.o: error: objtool: __sev_es_nmi_complete+0x58: call to __kcsan_check_access() leaves .noinstr.text section make[2]: *** [/usr/local/google/home/ardb/linux/scripts/Makefile.vmlinux_o:72: vmlinux.o] Error 1

---
 arch/x86/coco/sev/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/coco/sev/Makefile +2 -1
index db3255b..342d79f 100644
@@ -5,5 +5,6 @@ obj-y += core.o sev-nmi.o vc-handle.o
 # Clang 14 and older may fail to respect __no_sanitize_undefined when inlining
 UBSAN_SANITIZE_sev-nmi.o	:= n
 
-# GCC may fail to respect __no_sanitize_address when inlining
+# GCC may fail to respect __no_sanitize_address or __no_kcsan when inlining
 KASAN_SANITIZE_sev-nmi.o	:= n
+KCSAN_SANITIZE_sev-nmi.o	:= n