x86/sev: Work around broken noinstr on GCC
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
@@ -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
Borislav Petkov
maintainerQuoted 21 lines · Ard Biesheuvel
From: Ard Biesheuvel <[email protected]>
Forcibly disable KCSAN for the
sev-nmi.csource 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 1Reported-by Randy Dunlap <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>--- arch/x86/coco/sev/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/coco/sev/Makefile +0
-0
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-netiquetteQuoted 33 lines · Borislav Petkov
Quoted 20 lines · Ard Biesheuvel
From: Ard Biesheuvel <[email protected]>
Forcibly disable KCSAN for the
sev-nmi.csource 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 1Reported-by Randy Dunlap <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>--- arch/x86/coco/sev/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/coco/sev/Makefile +0
-0arch/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,
Quoted 2 lines
I guess send this to Linus now so that it is in 6.16?
Yes.
Quoted 10 lines · Ard Biesheuvel
From: Ard Biesheuvel <[email protected]>
Forcibly disable KCSAN for the
sev-nmi.csource 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 1Reported-by Randy Dunlap <[email protected]>
Thanks.
Quoted 17 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/x86/coco/sev/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)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
Signature · 1 line
~Randy
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
@@ -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