On Mon, Oct 20, 2014 at 6:19 PM, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
I started out tweaking some things for kexec, and then things got out of hand...
Anyway, there is hopefully some stuff here that we will reuse, but I am not getting my hopes up that this will land upstream unmodified.
The main premise of these patches is that, in order to support kexec, we need to add code to the kernel that is able to deal with the state of the firmware after SetVirtualAddressMap() has been called. However, if we are going to deal with that anyway, why not make that the default state, and have only a single code path for both cases.
This means SVAM() needs to move to the stub, and hence the code that invents the layout needs to move with it. The result is that the kernel proper is entered with the virt_addr members of all EFI_MEMORY_RUNTIME regions assigned, and the mapping installled in UEFI. The kernel proper needs to set up the page tables, and switch to them while performing the runtime services calls. Note that there is also an efi_to_phys() to translate the values of the fw_vendor and tables fields of the EFI system table. Again, this is something we need to do anyway under kexec, or we end up handing over state between one kernel and the next, which implies different code paths between non-kexec and kexec.
That's sounds like a pretty sane approach, well done!
g.