Merge tag 'efi-fixes-for-v6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

Pull EFI fix from Ard Biesheuvel:

- Followup fix for the EFI boot sequence refactor, which may result in
physical KASLR putting the kernel in a region which is being used for
a special purpose via a command line argument.

* tag 'efi-fixes-for-v6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
x86/efistub: Omit physical KASLR when memory reservations exist

+26 -2
+26 -2
drivers/firmware/efi/libstub/x86-stub.c
··· 776 efi_warn("Decompression failed: %s\n", str); 777 } 778 779 static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry) 780 { 781 unsigned long virt_addr = LOAD_PHYSICAL_ADDR; ··· 826 if (efi_system_table->hdr.revision <= EFI_2_00_SYSTEM_TABLE_REVISION && 827 !memcmp(efistub_fw_vendor(), ami, sizeof(ami))) { 828 efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n"); 829 seed[0] = 0; 830 } 831 ··· 907 } 908 909 #ifdef CONFIG_CMDLINE_BOOL 910 - status = efi_parse_options(CONFIG_CMDLINE); 911 if (status != EFI_SUCCESS) { 912 efi_err("Failed to parse options\n"); 913 goto fail; ··· 916 if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) { 917 unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr | 918 ((u64)boot_params->ext_cmd_line_ptr << 32)); 919 - status = efi_parse_options((char *)cmdline_paddr); 920 if (status != EFI_SUCCESS) { 921 efi_err("Failed to parse options\n"); 922 goto fail;
··· 776 efi_warn("Decompression failed: %s\n", str); 777 } 778 779 + static const char *cmdline_memmap_override; 780 + 781 + static efi_status_t parse_options(const char *cmdline) 782 + { 783 + static const char opts[][14] = { 784 + "mem=", "memmap=", "efi_fake_mem=", "hugepages=" 785 + }; 786 + 787 + for (int i = 0; i < ARRAY_SIZE(opts); i++) { 788 + const char *p = strstr(cmdline, opts[i]); 789 + 790 + if (p == cmdline || (p > cmdline && isspace(p[-1]))) { 791 + cmdline_memmap_override = opts[i]; 792 + break; 793 + } 794 + } 795 + 796 + return efi_parse_options(cmdline); 797 + } 798 + 799 static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry) 800 { 801 unsigned long virt_addr = LOAD_PHYSICAL_ADDR; ··· 806 if (efi_system_table->hdr.revision <= EFI_2_00_SYSTEM_TABLE_REVISION && 807 !memcmp(efistub_fw_vendor(), ami, sizeof(ami))) { 808 efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n"); 809 + seed[0] = 0; 810 + } else if (cmdline_memmap_override) { 811 + efi_info("%s detected on the kernel command line - disabling physical KASLR\n", 812 + cmdline_memmap_override); 813 seed[0] = 0; 814 } 815 ··· 883 } 884 885 #ifdef CONFIG_CMDLINE_BOOL 886 + status = parse_options(CONFIG_CMDLINE); 887 if (status != EFI_SUCCESS) { 888 efi_err("Failed to parse options\n"); 889 goto fail; ··· 892 if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) { 893 unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr | 894 ((u64)boot_params->ext_cmd_line_ptr << 32)); 895 + status = parse_options((char *)cmdline_paddr); 896 if (status != EFI_SUCCESS) { 897 efi_err("Failed to parse options\n"); 898 goto fail;