[RFC] ELF Relocatable x86 and x86_64 bzImages




The problem:

We can't always run the kernel at 1MB or 2MB, and so people who need
different addresses must build multiple kernels. The bzImage format
can't even represent loading a kernel at other than it's default address.
With kexec on panic now starting to be used by distros having a kernel
not running at the default load address is starting to become common.

The goal of this patch series is to build kernels that are relocatable
at run time, and to extend the bzImage format to make it capable of
expressing a relocatable kernel.

In extending the bzImage format I am replacing the existing unused bootsector
with an ELF header. To express what is going on the ELF header will
have type ET_DYN. Just like the kernel loading an ET_DYN executable
bootloaders are not expected to process relocations. But the executable
may be shifted in the address space so long as it's alignment requirements
are met.

The x86_64 kernel is simply built to live at a fixed virtual address
and the boot page tables are relocated. The i386 kernel is built
to process relocations generated with --embedded-relocs (after vmlinux.lds.S)
has been fixed up to sort out static and dynamic relocations.

Currently there are 33 patches in my tree to do this.

The weirdest symptom I have had so far is that page faults did not
trigger the early exception handler on x86_64 (instead I got a reboot).

There is one outstanding issue where I am probably requiring too much alignment
on the arch/i386 kernel.

Can anyone find anything else?

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [PATCH 09/14] x86, boot: add new runtime_address and runtime_size bzImage fields
    ... Make the runtime address and the required amount of linear ... can use this information to select a kernel location; ... leal relocated, %eax ... -/* Find the address of the relocations. ...
    (Linux-Kernel)
  • Re: [PATCH/RFC] powerpc: avoid generating .eh_frame sections with gcc-4.4
    ... sections, which are, for the kernel, fairly pointless. ... What the flag above does is to restore the .eh_frame behavior from GCC ... The assembler doesn't know which of these to ... possible that the assembler selects more efficient relocations than GCC. ...
    (Linux-Kernel)
  • Re: [RFC] ELF Relocatable x86 and x86_64 bzImages
    ... The bzImage format ... can't even represent loading a kernel at other than it's default address. ... generally need to be as simple and as fixed as possible because bootloaders ... Beyond that if you look at head.S the code to process the relocations ...
    (Linux-Kernel)
  • Re: Patch to reorder functions in the vmlinux to a defined order
    ... to let the bootloader know it was possible though. ... With the linker able to generate the relocations you can ... do it outside of most of the kernel where we have the decompressor. ... I only haven't submitted the patches because I was too busy stabilizing ...
    (Linux-Kernel)
  • Re: [RFC] ELF Relocatable x86 and x86_64 bzImages
    ... can't even represent loading a kernel at other than it's default address. ... and to extend the bzImage format to make it capable of ... bootloaders are not expected to process relocations. ... The x86_64 kernel is simply built to live at a fixed virtual address ...
    (Linux-Kernel)