[PATCH 8/9] x86/kexec: Cope with relocate_kernel() not being at the start of the page
Ard Biesheuvel
ardb at kernel.org
Mon Jan 6 08:27:26 PST 2025
On Mon, 6 Jan 2025 at 17:13, David Woodhouse <dwmw2 at infradead.org> wrote:
>
> On Mon, 2025-01-06 at 17:09 +0100, Ard Biesheuvel wrote:
> >
> > I suppose you're referring to
> >
> > #ifdef CONFIG_KEXEC_JUMP
> > /* Saved in save_processor_state. */
> > movq $saved_context, %rax
> > lgdt saved_context_gdt_desc(%rax)
> > #endif
> >
> > Any reason not to simply use
> >
> > lgdt saved_context+saved_context_gdt_desc(%rip)
> >
> > here?
>
> Because the %rip isn't what you (and the linker) think it is.
>
> This code is copied into a control page which is allocated as part of
> the kexec kimage. It can only access things within that same page via
> %rip. (Which is not as much of a restriction as it sounds, as for most
> of its execution the rest of the kernel isn't even present in the page
> tables).
Ah I was looking at an older version of that file - I now see that the
preceding (%rip) references have been replaced as well.
In any case, thanks for the head's up - I'll get back to this at some
point and cc you if making any further changes here.
More information about the kexec
mailing list