x86/setup: do not include kexec_handover.h from asm/setup.h
Subsystems (3)
Pratyush Yadav
maintainerPATCH 1/1 x86/setup: do not include kexec_handover.h from asm/setup.h
From: "Pratyush Yadav (Google)" <[email protected]>
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 anything from KHO. Remove the header from setup.h, and directly include it in setup.c and kaslr.c, which do use things from KHO. It should also help reduce files recompiled when kexec_handover.h changes.
---
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.
arch/x86/boot/compressed/kaslr.c | 2 ++ arch/x86/include/asm/setup.h | 2 -- arch/x86/kernel/setup.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/kaslr.c +2 -0
@@ -32,6 +32,8 @@#include <asm/setup.h> /* For COMMAND_LINE_SIZE */ #undef _SETUP +#include <linux/kexec_handover.h> +extern unsigned long get_cmd_line_ptr (void );/* Simplified build-specific string for starting entropy. */
arch/x86/include/asm/setup.h +0 -2
@@ -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>
arch/x86/kernel/setup.c +1 -0
@@ -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>
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
Borislav Petkov
maintainerQuoted 8 lines · Pratyush Yadav
From: "Pratyush Yadav (Google)" <[email protected]>
x86
asm/setup.hincludeslinux/kexec_handover.h. This is because it is used bysetup.candkaslr.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 likemm.h, it causes a big dump of compliation failures.
This is exactly why we are trying hard to block people from using more linux/ namespace headers in the decompressor code. Please split it and put only the bits that are needed by the decompressor into a header in arch/x86/include/asm/shared/ and use that in the decompressor.
There are examples there.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteMike Rapoport
maintainerQuoted 10 lines · Borislav Petkov
Quoted 8 lines · Pratyush Yadav
From: "Pratyush Yadav (Google)" <[email protected]>
x86
asm/setup.hincludeslinux/kexec_handover.h. This is because it is used bysetup.candkaslr.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 likemm.h, it causes a big dump of compliation failures.
Quoted 6 lines
This is exactly why we are trying hard to block people from using more linux/ namespace headers in the decompressor code. Please split it and put only the bits that are needed by the decompressor into a header in
arch/x86/include/asm/shared/and use that in the decompressor.There are examples there.
The examples there are really x86 specific.
KHO needs decompressor to recognise 'struct kho_scratch' that's defined in include/linux/kexec_handover.h
I see there's a duplicated 'struct efi_unaccepted_memory' for decompressor needs, should KHO do the same for 'struct kho_scratch'?
Signature · 2 lines
Sincerely yours, Mike.
Borislav Petkov
maintainerQuoted 3 lines · Mike Rapoport
The examples there are really x86 specific.
KHO needs decompressor to recognise 'structkho_scratch' that's defined ininclude/linux/kexec_handover.h
That struct is huuuge :-P
struct kho_scratch {
phys_addr_t addr;
phys_addr_t size;
};Quoted 2 lines
I see there's a duplicated 'struct
efi_unaccepted_memory' for decompressor needs, should KHO do the same for 'structkho_scratch'?
You could. But it would go out of sync perhaps.
You could also try a
include/asm-generic/kho.h
and put only really generic, basic gunk there and include it everywhere.
HTH.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteMike Rapoport
maintainerQuoted 11 lines · Borislav Petkov
Quoted 3 lines · Mike Rapoport
The examples there are really x86 specific.
KHO needs decompressor to recognise 'structkho_scratch' that's defined ininclude/linux/kexec_handover.hThat struct is huuuge :-P
struct kho_scratch { phys_addr_t addr; phys_addr_t size; };
The size does not matter ;-P
Quoted 10 lines
Quoted 2 lines
I see there's a duplicated 'struct
efi_unaccepted_memory' for decompressor needs, should KHO do the same for 'structkho_scratch'?You could. But it would go out of sync perhaps.
You could also try a
include/asm-generic/kho.hand put only really generic, basic gunk there and include it everywhere.
asm-generic would be my preference too if that's fine to include in decompressor.
Signature · 2 lines
Sincerely yours, Mike.
Borislav Petkov
maintainerQuoted 1 line · Mike Rapoport
The size does not matter ;-P
Yeah, that's what they all say :-P
Quoted 2 lines
asm-generic would be my preference too if that's fine to include in decompressor.
Sure, the main idea is that if we add more linux/ namespace includes into the decompressor, they end up pulling in the world and more and then you end up in build and include hell. So we try to make sure only more or less self-contained headers are included.
And there's a bunch of build magic in scripts/Makefile.asm-headers and this
# Support for using generic headers in asm-generic asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj
in the main Makefile which lets you do things like that apparently:
$ git grep generic-y arch/x86/ arch/x86/include/asm/Kbuild:13:generic-y += early_ioremap.h arch/x86/include/asm/Kbuild:14:generic-y += fprobe.h arch/x86/include/asm/Kbuild:15:generic-y += mcs_spinlock.h arch/x86/include/asm/Kbuild:16:generic-y += mmzone.h arch/x86/include/asm/Kbuild:17:generic-y += ring_buffer.h
but you'd need to try it - I've only heard about it from the sidelines.
:-)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette