linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] x86/boot: Get rid of linux/init.h include
@ 2024-11-22 16:31 Borislav Petkov (AMD)
  2024-11-22 16:55 ` Ingo Molnar
  0 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov (AMD) @ 2024-11-22 16:31 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: x86-ml, lkml

Hi,

this is what I think we should do (just a first patch) to decouple the
decompressor from kernel proper headers namespace so that there's no
collisions and ugly ifdeffery when those kernel proper headers get shared.

And if we want to share things, we will use asm/shared/ to put such shared
definitions there.

Thoughts?

---

Get rid of the linux/init.h kernel proper namespace include and add
a KERNEL_PROPER_HEADER header guard to protect any future inclusions
into the decompressor.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
---
 arch/x86/boot/compressed/error.h   | 2 --
 arch/x86/boot/compressed/head_32.S | 7 +++++--
 arch/x86/boot/compressed/head_64.S | 7 +++++--
 arch/x86/include/asm/init.h        | 2 +-
 include/linux/init.h               | 2 ++
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/x86/boot/compressed/error.h b/arch/x86/boot/compressed/error.h
index 31f9e080d61a..938f6f1f1589 100644
--- a/arch/x86/boot/compressed/error.h
+++ b/arch/x86/boot/compressed/error.h
@@ -2,8 +2,6 @@
 #ifndef BOOT_COMPRESSED_ERROR_H
 #define BOOT_COMPRESSED_ERROR_H
 
-#include <linux/compiler.h>
-
 void warn(const char *m);
 void error(char *m) __noreturn;
 void panic(const char *fmt, ...) __noreturn __cold;
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index 1cfe9802a42f..6d7728582215 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -24,7 +24,6 @@
  */
 	.text
 
-#include <linux/init.h>
 #include <linux/linkage.h>
 #include <asm/segment.h>
 #include <asm/page_types.h>
@@ -32,6 +31,10 @@
 #include <asm/asm-offsets.h>
 #include <asm/bootparam.h>
 
+#ifdef KERNEL_PROPER_HEADER
+#error Do not include kernel proper namespace headers
+#endif
+
 /*
  * These symbols needed to be marked as .hidden to prevent the BFD linker from
  * generating R_386_32 (rather than R_386_RELATIVE) relocations for them when
@@ -42,7 +45,7 @@
 	.hidden _ebss
 	.hidden _end
 
-	__HEAD
+	.section ".head.text","ax"
 SYM_FUNC_START(startup_32)
 	cld
 	cli
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 1dcb794c5479..75ea0c8e4116 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -25,7 +25,6 @@
 	.code32
 	.text
 
-#include <linux/init.h>
 #include <linux/linkage.h>
 #include <asm/segment.h>
 #include <asm/boot.h>
@@ -37,6 +36,10 @@
 #include <asm/trapnr.h>
 #include "pgtable.h"
 
+#ifdef KERNEL_PROPER_HEADER
+#error Do not include kernel proper namespace headers
+#endif
+
 /*
  * Fix alignment at 16 bytes. Following CONFIG_FUNCTION_ALIGNMENT will result
  * in assembly errors due to trying to move .org backward due to the excessive
@@ -52,7 +55,7 @@
 	.hidden _ebss
 	.hidden _end
 
-	__HEAD
+	.section ".head.text","ax"
 
 /*
  * This macro gives the relative virtual address of X, i.e. the offset of X
diff --git a/arch/x86/include/asm/init.h b/arch/x86/include/asm/init.h
index 14d72727d7ee..6c47c84a3731 100644
--- a/arch/x86/include/asm/init.h
+++ b/arch/x86/include/asm/init.h
@@ -2,7 +2,7 @@
 #ifndef _ASM_X86_INIT_H
 #define _ASM_X86_INIT_H
 
-#define __head	__section(".head.text")
+#define __head __section(".head.text")
 
 struct x86_mapping_info {
 	void *(*alloc_pgt_page)(void *); /* allocate buf for page table */
diff --git a/include/linux/init.h b/include/linux/init.h
index ee1309473bc6..21e636abf3c4 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -2,6 +2,8 @@
 #ifndef _LINUX_INIT_H
 #define _LINUX_INIT_H
 
+#define KERNEL_PROPER_HEADER
+
 #include <linux/build_bug.h>
 #include <linux/compiler.h>
 #include <linux/stringify.h>
-- 
2.43.0


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

end of thread, other threads:[~2024-11-25 18:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-22 16:31 [RFC PATCH] x86/boot: Get rid of linux/init.h include Borislav Petkov (AMD)
2024-11-22 16:55 ` Ingo Molnar
2024-11-22 17:02   ` Borislav Petkov
2024-11-25  8:24     ` Ingo Molnar
2024-11-25 10:22       ` Borislav Petkov
2024-11-25 16:57         ` Brian Gerst
2024-11-25 17:09           ` Borislav Petkov
2024-11-25 17:31             ` Brian Gerst
2024-11-25 18:15               ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).