On Mon, Apr 24, 2023 at 06:57:24PM +0200, Ard Biesheuvel wrote: > In preparation for updating the EFI stub boot flow to avoid the bare > metal decompressor code altogether, implement the support code for > switching between 4 and 5 levels of paging before jumping to the kernel > proper. I must admit it is neat. I like it a lot. Any chance we can share the code with the traditional decompressor? There's not much that EFI specific here. It should be possible to isolate it from the rest, no? > @@ -792,6 +925,14 @@ asmlinkage unsigned long efi_main(efi_handle_t handle, > (get_efi_config_table(ACPI_20_TABLE_GUID) ?: > get_efi_config_table(ACPI_TABLE_GUID)); > > +#ifdef CONFIG_X86_64 > + status = efi_setup_5level_paging(); > + if (status != EFI_SUCCESS) { > + efi_err("efi_setup_5level_paging() failed!\n"); > + goto fail; > + } > +#endif > + > /* > * If the kernel isn't already loaded at a suitable address, > * relocate it. > @@ -910,6 +1051,10 @@ asmlinkage unsigned long efi_main(efi_handle_t handle, > goto fail; > } > > +#ifdef CONFIG_X86_64 > + efi_5level_switch(); > +#endif > + > return bzimage_addr; > fail: > efi_err("efi_main() failed!\n"); Maybe use IS_ENABLED() + dummy efi_setup_5level_paging()/efi_5level_switch() instead of #ifdefs? -- Kiryl Shutsemau / Kirill A. Shutemov