[PATCH 8/9] x86/kexec: Cope with relocate_kernel() not being at the start of the page

David Woodhouse dwmw2 at infradead.org
Fri Jan 3 02:10:00 PST 2025


On Tue, 2024-12-17 at 10:25 +0100, Ard Biesheuvel wrote:
> 
> > > You can still avoid the absolute relocations though, ...
> > ...
> > > > +       addq    $identity_mapped, %rsi
> > > > +       subq    $__relocate_kernel_start, %rsi
> > > 
> > > ... if you turn this into
> > > 
> > > 0:     addq    $identity_mapped - 0b, %rsi
> > >        subq    $__relocate_kernel_start - 0b, %rsi
> > 
> > Is there any benefit to doing so? Are absolute relocations problematic?
> 
> Every absolute relocation produces an entry in the relocation table
> that needs to be applied at every boot when KASLR is in effect. Beyond
> that, it doesn't matter.
> 
> I've looked into PIC codegen/PIE linking for the core kernel, which is
> why this caught my eye. If that effort ever advances, I'll need to
> revisit this code as well and apply the change I suggested.

OK, since it looks like I'll be reposting this series once I'm back at
a keyboard for real, I've done that in my tree.

There's one more absolute relocation, for saved_context just before
returning to the kernel from the 'virtual_mapped' code. That's only
reloading the GDT, and we could probably do that from the C code in
machine_kexec().
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5069 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kexec/attachments/20250103/f6101be8/attachment.p7s>


More information about the kexec mailing list