]> www.infradead.org Git - users/dwmw2/linux.git/commit
x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier
authorDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 16 Dec 2024 10:49:12 +0000 (10:49 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 12 Mar 2025 14:23:34 +0000 (14:23 +0000)
commit9500b0b9f7152444b9477af91a1574c016fd10bf
tree2ff3c814d180592a90c3298dd498e7d3cf081463
parent2ed69608c6d5065a88cff66851520d7dd04e972f
x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier

Commit 2114796ca041 ("x86/kexec: Mark machine_kexec() with __nocfi") marked
the machine_kexec() function with __nocfi because I failed to make objtool
happy when actually *providing* CFI information for the relocate_kernel()
function that it calls, and __nocfi was the easy workaround.

When that eventually gets fixed, the check on calling the relocate_kernel()
function pointer may trap. Obviously that should never happen unless the
function prototype gets messed up, but that's exactly what the CFI check is
for.

So it would be kind of helpful if the IDT was still in place and the trap
could be *handled*. It can remain valid until the moment that %cr3 gets
replaced, so shift the invalidation down into relocate_kernel() itself.

This is a useful cleanup regardless of making CFI work, so do it now.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/x86/kernel/machine_kexec_64.c
arch/x86/kernel/relocate_kernel_64.S