The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2] x86/setup: do not include kexec_handover.h from asm/setup.h
@ 2026-07-03 14:37 Pratyush Yadav
  2026-07-03 15:30 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Pratyush Yadav @ 2026-07-03 14:37 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, Pasha Tatashin, Mike Rapoport, Pratyush Yadav
  Cc: linux-kernel, x86, kexec

From: "Pratyush Yadav (Google)" <pratyush@kernel.org>

x86 asm/setup.h includes linux/kexec_handover.h. This is because it is
used by setup.c and kaslr.c. But this inclusion is problematic. The
header is included in many places, so it results in the KHO header being
propagated there. Also, the setup header is used by realmode code. If
KHO header includes things like mm.h, it causes a big dump of
compliation failures.

Nothing in setup.h uses anything from KHO. Remove the header from
setup.h, and directly include it in setup.c. which does use things from
KHO. Since kaslr.c is a part of the decompressor, avoid including linux
headers there directly. Instead, split out struct kho_scratch, which is
the only thing the kaslr.c uses, and move it to
include/asm-generic/kexec_handover.h.

This change should also help reduce files recompiled when
kexec_handover.h changes.

Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
---

Notes:
    Thomas/Ingo/Borislav/Dave, is it okay if we take this patch through the
    live update tree? I have a patch series for KHO that depends on this,
    but it is 20 odd patches and I don't want to spam the x86 list with
    them. So I am sending this change out separately. It is an improvement
    on its own anyway since it reduces recompilation on kexec_handover.h
    changes.
    
    All the changed files see relatively low patch traffic so chances of
    conflicts should minimal I think. And if there are any, I imagine they
    will be relatively simple to resolve.
    
    Changes in v2:
    - Do not include linux/kexec_handover.h in kaslr.c. Instead, split out
      struct kho_scratch, which is the only thing kaslr uses. Move it to its
      own header in include/asm-generic/kexec_handover.h

 MAINTAINERS                          |  1 +
 arch/x86/boot/compressed/kaslr.c     |  2 ++
 arch/x86/include/asm/setup.h         |  2 --
 arch/x86/kernel/setup.c              |  1 +
 include/asm-generic/kexec_handover.h | 12 ++++++++++++
 include/linux/kexec_handover.h       |  6 +-----
 6 files changed, 17 insertions(+), 7 deletions(-)
 create mode 100644 include/asm-generic/kexec_handover.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 15011f5752a9..a3ed337e827d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14334,6 +14334,7 @@ S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git
 F:	Documentation/admin-guide/mm/kho.rst
 F:	Documentation/core-api/kho/*
+F:	include/asm-generic/kexec_handover.h
 F:	include/linux/kexec_handover.h
 F:	include/linux/kho/
 F:	include/linux/kho_block.h
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 8e4bf5365ac6..ac02aed8757b 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -32,6 +32,8 @@
 #include <asm/setup.h>	/* For COMMAND_LINE_SIZE */
 #undef _SETUP
 
+#include <asm-generic/kexec_handover.h>
+
 extern unsigned long get_cmd_line_ptr(void);
 
 /* Simplified build-specific string for starting entropy. */
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index 914eb32581c7..895d09faaf83 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -69,8 +69,6 @@ extern void x86_ce4100_early_setup(void);
 static inline void x86_ce4100_early_setup(void) { }
 #endif
 
-#include <linux/kexec_handover.h>
-
 #ifndef _SETUP
 
 #include <asm/espfix.h>
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 46882ce79c3a..5ebb521e136d 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -16,6 +16,7 @@
 #include <linux/init_ohci1394_dma.h>
 #include <linux/initrd.h>
 #include <linux/iscsi_ibft.h>
+#include <linux/kexec_handover.h>
 #include <linux/memblock.h>
 #include <linux/panic_notifier.h>
 #include <linux/pci.h>
diff --git a/include/asm-generic/kexec_handover.h b/include/asm-generic/kexec_handover.h
new file mode 100644
index 000000000000..50839fb5ee8e
--- /dev/null
+++ b/include/asm-generic/kexec_handover.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_GENERIC_KEXEC_HANDOVER_H
+#define __ASM_GENERIC_KEXEC_HANDOVER_H
+
+#include <linux/types.h>
+
+struct kho_scratch {
+	phys_addr_t addr;
+	phys_addr_t size;
+};
+
+#endif /* __ASM_GENERIC_KEXEC_HANDOVER_H */
diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h
index 8968c56d2d73..48a9793c2b76 100644
--- a/include/linux/kexec_handover.h
+++ b/include/linux/kexec_handover.h
@@ -5,11 +5,7 @@
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/types.h>
-
-struct kho_scratch {
-	phys_addr_t addr;
-	phys_addr_t size;
-};
+#include <asm-generic/kexec_handover.h>
 
 struct kho_vmalloc;
 
-- 
2.55.0.rc2.803.g1fd1e6609c-goog


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

* Re: [PATCH v2] x86/setup: do not include kexec_handover.h from asm/setup.h
  2026-07-03 14:37 [PATCH v2] x86/setup: do not include kexec_handover.h from asm/setup.h Pratyush Yadav
@ 2026-07-03 15:30 ` Borislav Petkov
  2026-07-03 16:23   ` Pratyush Yadav
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2026-07-03 15:30 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: Thomas Gleixner, Ingo Molnar, Dave Hansen, H. Peter Anvin,
	Pasha Tatashin, Mike Rapoport, linux-kernel, x86, kexec

On Fri, Jul 03, 2026 at 04:37:03PM +0200, Pratyush Yadav wrote:
> From: "Pratyush Yadav (Google)" <pratyush@kernel.org>
> 
> x86 asm/setup.h includes linux/kexec_handover.h. This is because it is
> used by setup.c and kaslr.c. But this inclusion is problematic. The
> header is included in many places, so it results in the KHO header being
> propagated there. Also, the setup header is used by realmode code. If
> KHO header includes things like mm.h, it causes a big dump of
> compliation failures.

Use a spellchecker.

> Nothing in setup.h uses anything from KHO. Remove the header from
> setup.h, and directly include it in setup.c. which does use things from
> KHO. Since kaslr.c is a part of the decompressor, avoid including linux
> headers there directly. Instead, split out struct kho_scratch, which is
> the only thing the kaslr.c uses, and move it to
> include/asm-generic/kexec_handover.h.
> 
> This change should also help reduce files recompiled when

Avoid having "This patch" or "This commit" in the commit message. It is
tautologically useless.

Also, do

$ git grep 'This patch' Documentation/process

for more details.

> kexec_handover.h changes.
> 
> Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
> ---
> 
> Notes:
>     Thomas/Ingo/Borislav/Dave, is it okay if we take this patch through the

See my reply to Mike about using the generic-y infrastructure.

Thx.

-- 
Regards/Gruss,
    Boris.

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

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

* Re: [PATCH v2] x86/setup: do not include kexec_handover.h from asm/setup.h
  2026-07-03 15:30 ` Borislav Petkov
@ 2026-07-03 16:23   ` Pratyush Yadav
  2026-07-03 17:38     ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Pratyush Yadav @ 2026-07-03 16:23 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Pratyush Yadav, Thomas Gleixner, Ingo Molnar, Dave Hansen,
	H. Peter Anvin, Pasha Tatashin, Mike Rapoport, linux-kernel, x86,
	kexec

On Fri, Jul 03 2026, Borislav Petkov wrote:

> On Fri, Jul 03, 2026 at 04:37:03PM +0200, Pratyush Yadav wrote:
>> From: "Pratyush Yadav (Google)" <pratyush@kernel.org>
>> 
>> x86 asm/setup.h includes linux/kexec_handover.h. This is because it is
>> used by setup.c and kaslr.c. But this inclusion is problematic. The
>> header is included in many places, so it results in the KHO header being
>> propagated there. Also, the setup header is used by realmode code. If
>> KHO header includes things like mm.h, it causes a big dump of
>> compliation failures.
>
>> Nothing in setup.h uses anything from KHO. Remove the header from
>> setup.h, and directly include it in setup.c. which does use things from
>> KHO. Since kaslr.c is a part of the decompressor, avoid including linux
>> headers there directly. Instead, split out struct kho_scratch, which is
>> the only thing the kaslr.c uses, and move it to
>> include/asm-generic/kexec_handover.h.
>> 
>> This change should also help reduce files recompiled when
>
>> kexec_handover.h changes.
>> 
>> Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
>> ---
>> 
>> Notes:
>>     Thomas/Ingo/Borislav/Dave, is it okay if we take this patch through the
>
> See my reply to Mike about using the generic-y infrastructure.

To double check I got your point correctly, is this what you mean?

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index ac02aed8757b..22267a83e064 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -32,7 +32,7 @@
 #include <asm/setup.h>	/* For COMMAND_LINE_SIZE */
 #undef _SETUP
 
-#include <asm-generic/kexec_handover.h>
+#include <asm/kexec_handover.h>
 
 extern unsigned long get_cmd_line_ptr(void);
 
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 078fd2c0d69d..47ef8cb482e3 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -15,3 +15,4 @@ generic-y += fprobe.h
 generic-y += mcs_spinlock.h
 generic-y += mmzone.h
 generic-y += ring_buffer.h
+generic-y += kexec_handover.h

-- 
Regards,
Pratyush Yadav

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

* Re: [PATCH v2] x86/setup: do not include kexec_handover.h from asm/setup.h
  2026-07-03 16:23   ` Pratyush Yadav
@ 2026-07-03 17:38     ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2026-07-03 17:38 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: Thomas Gleixner, Ingo Molnar, Dave Hansen, H. Peter Anvin,
	Pasha Tatashin, Mike Rapoport, linux-kernel, x86, kexec

On Fri, Jul 03, 2026 at 06:23:33PM +0200, Pratyush Yadav wrote:
> On Fri, Jul 03 2026, Borislav Petkov wrote:
> 
> > On Fri, Jul 03, 2026 at 04:37:03PM +0200, Pratyush Yadav wrote:
> >> From: "Pratyush Yadav (Google)" <pratyush@kernel.org>
> >> 
> >> x86 asm/setup.h includes linux/kexec_handover.h. This is because it is
> >> used by setup.c and kaslr.c. But this inclusion is problematic. The
> >> header is included in many places, so it results in the KHO header being
> >> propagated there. Also, the setup header is used by realmode code. If
> >> KHO header includes things like mm.h, it causes a big dump of
> >> compliation failures.
> >
> >> Nothing in setup.h uses anything from KHO. Remove the header from
> >> setup.h, and directly include it in setup.c. which does use things from
> >> KHO. Since kaslr.c is a part of the decompressor, avoid including linux
> >> headers there directly. Instead, split out struct kho_scratch, which is
> >> the only thing the kaslr.c uses, and move it to
> >> include/asm-generic/kexec_handover.h.
> >> 
> >> This change should also help reduce files recompiled when
> >
> >> kexec_handover.h changes.
> >> 
> >> Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
> >> ---
> >> 
> >> Notes:
> >>     Thomas/Ingo/Borislav/Dave, is it okay if we take this patch through the
> >
> > See my reply to Mike about using the generic-y infrastructure.
> 
> To double check I got your point correctly, is this what you mean?
> 
> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> index ac02aed8757b..22267a83e064 100644
> --- a/arch/x86/boot/compressed/kaslr.c
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -32,7 +32,7 @@
>  #include <asm/setup.h>	/* For COMMAND_LINE_SIZE */
>  #undef _SETUP
>  
> -#include <asm-generic/kexec_handover.h>
> +#include <asm/kexec_handover.h>
>  
>  extern unsigned long get_cmd_line_ptr(void);
>  
> diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
> index 078fd2c0d69d..47ef8cb482e3 100644
> --- a/arch/x86/include/asm/Kbuild
> +++ b/arch/x86/include/asm/Kbuild
> @@ -15,3 +15,4 @@ generic-y += fprobe.h
>  generic-y += mcs_spinlock.h
>  generic-y += mmzone.h
>  generic-y += ring_buffer.h
> +generic-y += kexec_handover.h
> 
> -- 

Looks about right, AFAICT.

Thx.

-- 
Regards/Gruss,
    Boris.

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

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

end of thread, other threads:[~2026-07-03 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 14:37 [PATCH v2] x86/setup: do not include kexec_handover.h from asm/setup.h Pratyush Yadav
2026-07-03 15:30 ` Borislav Petkov
2026-07-03 16:23   ` Pratyush Yadav
2026-07-03 17:38     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox