[RFC PATCH 2/2] x86/kexec: Add data section to relocate_kernel
David Woodhouse
dwmw2 at infradead.org
Tue Nov 12 02:45:05 PST 2024
On Tue, 2024-11-12 at 11:14 +0100, Peter Zijlstra wrote:
> On Tue, Nov 12, 2024 at 08:44:33AM +0000, David Woodhouse wrote:
> > On Fri, 2024-11-08 at 12:26 +0100, H. Peter Anvin wrote:
> > >
> > > > --- a/arch/x86/kernel/vmlinux.lds.S
> > > > +++ b/arch/x86/kernel/vmlinux.lds.S
> > > > @@ -100,7 +100,7 @@ const_pcpu_hot = pcpu_hot;
> > > > . = ALIGN(PAGE_SIZE); \
> > > > __relocate_kernel_start = .; \
> > > > *(.text.relocate_kernel); \
> > > > - *(.rodata.relocate_kernel); \
> > > > + *(.data.relocate_kernel); \
>
> Why are we having data in the middle of the text section?
This is the relocate_kernel() page. It's the last thing the kernel
calls on kexec.
The kernel first takes a *copy* of it and places it into the identity
mapping page tables which are set up for kexec.
The relocate_kernel() function is then called at its *original*
location in the kernel text. Before reloading %cr3, it stores some
information which is going to become unavailable into its own page
(currently using a bit of a nasty hack based on a hard-coded
KEXEC_CONTROL_CODE_MAX_SIZE because we can't just use data symbol
references).
Then it reloads %cr3 and jumps to the identity-mapped copy of itself.
Could we put .text.relocate_kernel and .data.relocate_kernel somewhere
*other* than the main kernel text segment? Probably... it use use
alternative instructions, but we could deal with that. And if we call
from machine_kexec() directly into the *copy* (having marked it
executable), maybe...?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5965 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kexec/attachments/20241112/21bc0af1/attachment-0001.p7s>
More information about the kexec
mailing list