Re: [PATCH v3] x86/setup: do not include kexec_handover.h from asm/setup.h

Borislav Petkov <[email protected]>
Newsgroups org.infradead.lists.kexec,org.kernel.vger.linux-kernel
Message-ID <20260707021832.GFakxh-I-NNNTujBMH@fat_crate.local>
On Mon, Jul 06, 2026 at 05:37:49PM +0200, Pratyush Yadav wrote:
> 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
> compilation 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 should also help reduce files recompiled when kexec_handover.h
> changes.
> 
> Signed-off-by: Pratyush Yadav (Google) <[email protected]>
> ---
> 
> 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 v3:
>     - Fix changelog nitpicks.
>     - Add kexec_handover.h to generic-y and use asm/kexec_handover.h in
>       kaslr.c
>     
>     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/Kbuild          |  1 +
>  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 +-----
>  7 files changed, 18 insertions(+), 7 deletions(-)
>  create mode 100644 include/asm-generic/kexec_handover.h

Acked-by: Borislav Petkov (AMD) <[email protected]>

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.