]> 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>
Fri, 14 Mar 2025 11:34:58 +0000 (11:34 +0000)
commitae28f15a0c6a7913dd0049924ee6826ed173677a
tree14c9ce0b3c81c99c021c69f8efa07bebeeb26b40
parent2114c5db3c6dc573e76391be19c3cde630fe63ff
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