From 701bf4b244d07787929f2fa2e1eb4c3bdb48f679 Mon Sep 17 00:00:00 2001 From: Riku Voipio Date: Wed, 1 Feb 2017 14:39:59 +0200 Subject: [PATCH] Revert efistub changes, Closes: #853170 [benh: Update changelog] --- debian/changelog | 4 + ...ub-arm-pass-latest-memory-map-to-the.patch | 200 ++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 205 insertions(+) create mode 100644 debian/patches/bugfix/arm64/efi-libstub-arm-pass-latest-memory-map-to-the.patch diff --git a/debian/changelog b/debian/changelog index d092c28df..0d05be446 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,10 @@ linux (4.9.6-4) UNRELEASED; urgency=medium * [armel] ARM: dts: orion5x-lschl: More consistent naming on linkstation series + [ Riku Voipio ] + * [arm64] Revert "efi/libstub/arm*: Pass latest memory map to the kernel" + (Closes: #853170) + -- Ben Hutchings Fri, 27 Jan 2017 18:14:31 +0000 linux (4.9.6-3) unstable; urgency=medium diff --git a/debian/patches/bugfix/arm64/efi-libstub-arm-pass-latest-memory-map-to-the.patch b/debian/patches/bugfix/arm64/efi-libstub-arm-pass-latest-memory-map-to-the.patch new file mode 100644 index 000000000..07f161d9e --- /dev/null +++ b/debian/patches/bugfix/arm64/efi-libstub-arm-pass-latest-memory-map-to-the.patch @@ -0,0 +1,200 @@ +From 1816e2e5003836a142056957f7a813d846eba992 Mon Sep 17 00:00:00 2001 +From: Riku Voipio +Date: Wed, 1 Feb 2017 13:37:49 +0200 +Subject: [PATCH] Revert "efi/libstub/arm*: Pass latest memory map to the + kernel" + +This reverts commit 74ce3fd64bc44f89856ff57bf684882dc098f93b. +--- + drivers/firmware/efi/libstub/efistub.h | 8 ++++ + drivers/firmware/efi/libstub/fdt.c | 87 ++++++++++++---------------------- + 2 files changed, 39 insertions(+), 56 deletions(-) + +diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h +index fac67992bede..ee49cd23ee63 100644 +--- a/drivers/firmware/efi/libstub/efistub.h ++++ b/drivers/firmware/efi/libstub/efistub.h +@@ -30,6 +30,14 @@ efi_status_t efi_file_close(void *handle); + + unsigned long get_dram_base(efi_system_table_t *sys_table_arg); + ++efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, ++ unsigned long orig_fdt_size, ++ void *fdt, int new_fdt_size, char *cmdline_ptr, ++ u64 initrd_addr, u64 initrd_size, ++ efi_memory_desc_t *memory_map, ++ unsigned long map_size, unsigned long desc_size, ++ u32 desc_ver); ++ + efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, + void *handle, + unsigned long *new_fdt_addr, +diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c +index 921dfa047202..a6a93116a8f0 100644 +--- a/drivers/firmware/efi/libstub/fdt.c ++++ b/drivers/firmware/efi/libstub/fdt.c +@@ -16,10 +16,13 @@ + + #include "efistub.h" + +-static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, +- unsigned long orig_fdt_size, +- void *fdt, int new_fdt_size, char *cmdline_ptr, +- u64 initrd_addr, u64 initrd_size) ++efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, ++ unsigned long orig_fdt_size, ++ void *fdt, int new_fdt_size, char *cmdline_ptr, ++ u64 initrd_addr, u64 initrd_size, ++ efi_memory_desc_t *memory_map, ++ unsigned long map_size, unsigned long desc_size, ++ u32 desc_ver) + { + int node, num_rsv; + int status; +@@ -98,23 +101,25 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, + if (status) + goto fdt_set_fail; + +- fdt_val64 = U64_MAX; /* placeholder */ ++ fdt_val64 = cpu_to_fdt64((u64)(unsigned long)memory_map); + status = fdt_setprop(fdt, node, "linux,uefi-mmap-start", + &fdt_val64, sizeof(fdt_val64)); + if (status) + goto fdt_set_fail; + +- fdt_val32 = U32_MAX; /* placeholder */ ++ fdt_val32 = cpu_to_fdt32(map_size); + status = fdt_setprop(fdt, node, "linux,uefi-mmap-size", + &fdt_val32, sizeof(fdt_val32)); + if (status) + goto fdt_set_fail; + ++ fdt_val32 = cpu_to_fdt32(desc_size); + status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-size", + &fdt_val32, sizeof(fdt_val32)); + if (status) + goto fdt_set_fail; + ++ fdt_val32 = cpu_to_fdt32(desc_ver); + status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-ver", + &fdt_val32, sizeof(fdt_val32)); + if (status) +@@ -143,43 +148,6 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, + return EFI_LOAD_ERROR; + } + +-static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map) +-{ +- int node = fdt_path_offset(fdt, "/chosen"); +- u64 fdt_val64; +- u32 fdt_val32; +- int err; +- +- if (node < 0) +- return EFI_LOAD_ERROR; +- +- fdt_val64 = cpu_to_fdt64((unsigned long)*map->map); +- err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-start", +- &fdt_val64, sizeof(fdt_val64)); +- if (err) +- return EFI_LOAD_ERROR; +- +- fdt_val32 = cpu_to_fdt32(*map->map_size); +- err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-size", +- &fdt_val32, sizeof(fdt_val32)); +- if (err) +- return EFI_LOAD_ERROR; +- +- fdt_val32 = cpu_to_fdt32(*map->desc_size); +- err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-size", +- &fdt_val32, sizeof(fdt_val32)); +- if (err) +- return EFI_LOAD_ERROR; +- +- fdt_val32 = cpu_to_fdt32(*map->desc_ver); +- err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-ver", +- &fdt_val32, sizeof(fdt_val32)); +- if (err) +- return EFI_LOAD_ERROR; +- +- return EFI_SUCCESS; +-} +- + #ifndef EFI_FDT_ALIGN + #define EFI_FDT_ALIGN EFI_PAGE_SIZE + #endif +@@ -275,10 +243,20 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, + goto fail; + } + ++ /* ++ * Now that we have done our final memory allocation (and free) ++ * we can get the memory map key needed for ++ * exit_boot_services(). ++ */ ++ status = efi_get_memory_map(sys_table, &map); ++ if (status != EFI_SUCCESS) ++ goto fail_free_new_fdt; ++ + status = update_fdt(sys_table, + (void *)fdt_addr, fdt_size, + (void *)*new_fdt_addr, new_fdt_size, +- cmdline_ptr, initrd_addr, initrd_size); ++ cmdline_ptr, initrd_addr, initrd_size, ++ memory_map, map_size, desc_size, desc_ver); + + /* Succeeding the first time is the expected case. */ + if (status == EFI_SUCCESS) +@@ -288,16 +266,20 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, + /* + * We need to allocate more space for the new + * device tree, so free existing buffer that is +- * too small. ++ * too small. Also free memory map, as we will need ++ * to get new one that reflects the free/alloc we do ++ * on the device tree buffer. + */ + efi_free(sys_table, new_fdt_size, *new_fdt_addr); ++ sys_table->boottime->free_pool(memory_map); + new_fdt_size += EFI_PAGE_SIZE; + } else { + pr_efi_err(sys_table, "Unable to construct new device tree.\n"); +- goto fail_free_new_fdt; ++ goto fail_free_mmap; + } + } + ++ sys_table->boottime->free_pool(memory_map); + priv.runtime_map = runtime_map; + priv.runtime_entry_count = &runtime_entry_count; + status = efi_exit_boot_services(sys_table, handle, &map, &priv, +@@ -306,16 +288,6 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, + if (status == EFI_SUCCESS) { + efi_set_virtual_address_map_t *svam; + +- status = update_fdt_memmap((void *)*new_fdt_addr, &map); +- if (status != EFI_SUCCESS) { +- /* +- * The kernel won't get far without the memory map, but +- * may still be able to print something meaningful so +- * return success here. +- */ +- return EFI_SUCCESS; +- } +- + /* Install the new virtual address map */ + svam = sys_table->runtime->set_virtual_address_map; + status = svam(runtime_entry_count * desc_size, desc_size, +@@ -347,6 +319,9 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, + + pr_efi_err(sys_table, "Exit boot services failed.\n"); + ++fail_free_mmap: ++ sys_table->boottime->free_pool(memory_map); ++ + fail_free_new_fdt: + efi_free(sys_table, new_fdt_size, *new_fdt_addr); + +-- +2.11.0 + diff --git a/debian/patches/series b/debian/patches/series index 00f30b887..3c9af8e30 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -47,6 +47,7 @@ debian/fanotify-taint-on-use-of-fanotify_access_permissions.patch # Arch bug fixes bugfix/x86/asoc-intel-select-dw_dmac_core-since-it-s-mandatory.patch +bugfix/arm64/efi-libstub-arm-pass-latest-memory-map-to-the.patch # Arch features features/mips/MIPS-increase-MAX-PHYSMEM-BITS-on-Loongson-3-only.patch