[SRU][N:linux-gcp][PATCH v2 17/24] x86/sev: Move SEV compilation units
Ian Whitfield
ian.whitfield at canonical.com
Mon Jun 23 20:48:15 UTC 2025
From: "Borislav Petkov (AMD)" <bp at alien8.de>
BugLink: https://bugs.launchpad.net/bugs/2111956
A long time ago it was agreed upon that the coco stuff needs to go where
it belongs:
https://lore.kernel.org/all/Yg5nh1RknPRwIrb8@zn.tnic
and not keep it in arch/x86/kernel. TDX did that and SEV can't find time
to do so. So lemme do it. If people have trouble converting their
ongoing featuritis patches, ask me for a sed script.
No functional changes.
Move the instrumentation exclusion bits too, as helpfully caught and
reported by the 0day folks.
Closes: https://lore.kernel.org/oe-kbuild-all/202406220748.hG3qlmDx-lkp@intel.com
Reported-by: kernel test robot <lkp at intel.com>
Closes: https://lore.kernel.org/oe-lkp/202407091342.46d7dbb-oliver.sang@intel.com
Reported-by: kernel test robot <oliver.sang at intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp at alien8.de>
Reviewed-by: Nikunj A Dadhania <nikunj at amd.com>
Reviewed-by: Ashish Kalra <ashish.kalra at amd.com>
Tested-by: kernel test robot <oliver.sang at intel.com>
Link: https://lore.kernel.org/r/20240619093014.17962-1-bp@kernel.org
(cherry picked from commit 38918e0bb2c51c21ea464b071a254b27ff9aa71d)
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
arch/x86/boot/compressed/sev.c | 2 +-
arch/x86/coco/Makefile | 1 +
arch/x86/coco/sev/Makefile | 15 +++++++++++++++
arch/x86/{kernel/sev.c => coco/sev/core.c} | 2 +-
.../{kernel/sev-shared.c => coco/sev/shared.c} | 0
arch/x86/kernel/Makefile | 5 -----
6 files changed, 18 insertions(+), 7 deletions(-)
create mode 100644 arch/x86/coco/sev/Makefile
rename arch/x86/{kernel/sev.c => coco/sev/core.c} (99%)
rename arch/x86/{kernel/sev-shared.c => coco/sev/shared.c} (100%)
diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
index 1f77a8ba49a4..d973ada152a5 100644
--- a/arch/x86/boot/compressed/sev.c
+++ b/arch/x86/boot/compressed/sev.c
@@ -126,7 +126,7 @@ static bool fault_in_kernel_space(unsigned long address)
#include "../../lib/insn.c"
/* Include code for early handlers */
-#include "../../kernel/sev-shared.c"
+#include "../../coco/sev/shared.c"
static struct svsm_ca *svsm_get_caa(void)
{
diff --git a/arch/x86/coco/Makefile b/arch/x86/coco/Makefile
index c816acf78b6a..eabdc7486538 100644
--- a/arch/x86/coco/Makefile
+++ b/arch/x86/coco/Makefile
@@ -6,3 +6,4 @@ CFLAGS_core.o += -fno-stack-protector
obj-y += core.o
obj-$(CONFIG_INTEL_TDX_GUEST) += tdx/
+obj-$(CONFIG_AMD_MEM_ENCRYPT) += sev/
diff --git a/arch/x86/coco/sev/Makefile b/arch/x86/coco/sev/Makefile
new file mode 100644
index 000000000000..4e375e7305ac
--- /dev/null
+++ b/arch/x86/coco/sev/Makefile
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y += core.o
+
+ifdef CONFIG_FUNCTION_TRACER
+CFLAGS_REMOVE_core.o = -pg
+endif
+
+KASAN_SANITIZE_core.o := n
+KMSAN_SANITIZE_core.o := n
+KCOV_INSTRUMENT_core.o := n
+
+# With some compiler versions the generated code results in boot hangs, caused
+# by several compilation units. To be safe, disable all instrumentation.
+KCSAN_SANITIZE := n
diff --git a/arch/x86/kernel/sev.c b/arch/x86/coco/sev/core.c
similarity index 99%
rename from arch/x86/kernel/sev.c
rename to arch/x86/coco/sev/core.c
index dac90524a38a..e3670210cbc9 100644
--- a/arch/x86/kernel/sev.c
+++ b/arch/x86/coco/sev/core.c
@@ -594,7 +594,7 @@ static __always_inline void vc_forward_exception(struct es_em_ctxt *ctxt)
}
/* Include code shared with pre-decompression boot stage */
-#include "sev-shared.c"
+#include "shared.c"
static inline struct svsm_ca *svsm_get_caa(void)
{
diff --git a/arch/x86/kernel/sev-shared.c b/arch/x86/coco/sev/shared.c
similarity index 100%
rename from arch/x86/kernel/sev-shared.c
rename to arch/x86/coco/sev/shared.c
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0000325ab98f..0c25d242eb3c 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -17,7 +17,6 @@ CFLAGS_REMOVE_ftrace.o = -pg
CFLAGS_REMOVE_early_printk.o = -pg
CFLAGS_REMOVE_head64.o = -pg
CFLAGS_REMOVE_head32.o = -pg
-CFLAGS_REMOVE_sev.o = -pg
CFLAGS_REMOVE_rethook.o = -pg
endif
@@ -26,7 +25,6 @@ KASAN_SANITIZE_dumpstack.o := n
KASAN_SANITIZE_dumpstack_$(BITS).o := n
KASAN_SANITIZE_stacktrace.o := n
KASAN_SANITIZE_paravirt.o := n
-KASAN_SANITIZE_sev.o := n
# With some compiler versions the generated code results in boot hangs, caused
# by several compilation units. To be safe, disable all instrumentation.
@@ -37,7 +35,6 @@ KMSAN_SANITIZE_nmi.o := n
# If instrumentation of the following files is enabled, boot hangs during
# first second.
KCOV_INSTRUMENT_head$(BITS).o := n
-KCOV_INSTRUMENT_sev.o := n
CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace
@@ -140,8 +137,6 @@ obj-$(CONFIG_UNWINDER_ORC) += unwind_orc.o
obj-$(CONFIG_UNWINDER_FRAME_POINTER) += unwind_frame.o
obj-$(CONFIG_UNWINDER_GUESS) += unwind_guess.o
-obj-$(CONFIG_AMD_MEM_ENCRYPT) += sev.o
-
obj-$(CONFIG_CFI_CLANG) += cfi.o
obj-$(CONFIG_CALL_THUNKS) += callthunks.o
--
2.43.0
More information about the kernel-team
mailing list