Re: [RFC PATCH] x86/boot: Get rid of linux/init.h include

From: Ingo Molnar
Date: Fri Nov 22 2024 - 11:56:13 EST



* Borislav Petkov (AMD) <bp@xxxxxxxxx> wrote:

>
> 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?

Sounds good.


> --- 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

The canonical solution in such cases is to use the existing header
guard, ie:

#ifdef _LINUX_INIT_H
# error Do not include kernel proper namespace headers
#endif

Then we can skip defining KERNEL_PROPER_HEADER as well, and this change
will be purely to x86 code.

Thanks,

Ingo