From 800a4d849a6f9f4bb50cc08cb8aedb3526a582f5 Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Wed, 11 Jan 2017 17:12:48 -0800 Subject: Add fix for some thinkpads missed during the rebase. --- 0001-efi-prune-invalid-memory-map-entries.patch | 141 ++++++++++++++++++++++++ kernel.spec | 8 +- 2 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 0001-efi-prune-invalid-memory-map-entries.patch diff --git a/0001-efi-prune-invalid-memory-map-entries.patch b/0001-efi-prune-invalid-memory-map-entries.patch new file mode 100644 index 000000000..4b65ef504 --- /dev/null +++ b/0001-efi-prune-invalid-memory-map-entries.patch @@ -0,0 +1,141 @@ +From c7c7030a020405d5826c03839e38986e0f78f2ea Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 13 Dec 2016 10:25:10 +0000 +Subject: [PATCH] efi: prune invalid memory map entries + +Some machines, such as the Lenovo ThinkPad W541 with firmware GNET80WW +(2.28), include memory map entries with phys_addr=0x0 and num_pages=0. + +Currently the log output for this case (with efi=debug) looks like: + +[ 0.000000] efi: mem45: [Reserved | | | | | | | | | | | | ] range=[0x0000000000000000-0xffffffffffffffff] (0MB) + +This is clearly wrong, and also not as informative as it could be. This +patch changes it so that if we find obviously invalid memory map +entries, we print an error and those entries. It also detects the +display of the address range calculation overflow, so the new output is: + +[ 0.000000] efi: [Firmware Bug]: Invalid EFI memory map entries: +[ 0.000000] efi: mem45: [Reserved | | | | | | | | | | | | ] range=[0x0000000000000000-0x0000000000000000] (invalid) + +It also detects memory map sizes that would overflow the physical +address, for example phys_addr=0xfffffffffffff000 and +num_pages=0x0200000000000001, and prints: + +[ 0.000000] efi: [Firmware Bug]: Invalid EFI memory map entries: +[ 0.000000] efi: mem45: [Reserved | | | | | | | | | | | | ] range=[phys_addr=0xfffffffffffff000-0x20ffffffffffffffff] (invalid) + +It then removes these entries from the memory map. + +Cc: Matt Fleming +Signed-off-by: Peter Jones +[ardb: refactor for clarity with no functional changes, avoid PAGE_SHIFT] +Signed-off-by: Ard Biesheuvel +--- + arch/x86/platform/efi/efi.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ + include/linux/efi.h | 1 + + 2 files changed, 71 insertions(+) + +diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c +index bf99aa7..0a1550b 100644 +--- a/arch/x86/platform/efi/efi.c ++++ b/arch/x86/platform/efi/efi.c +@@ -210,6 +210,74 @@ int __init efi_memblock_x86_reserve_range(void) + return 0; + } + ++#define OVERFLOW_ADDR_SHIFT (64 - EFI_PAGE_SHIFT) ++#define OVERFLOW_ADDR_MASK (U64_MAX << OVERFLOW_ADDR_SHIFT) ++#define U64_HIGH_BIT (~(U64_MAX >> 1)) ++ ++static bool __init efi_memmap_entry_valid(const efi_memory_desc_t *md, int i) ++{ ++ static __initdata bool once = true; ++ u64 end = (md->num_pages << EFI_PAGE_SHIFT) + md->phys_addr - 1; ++ u64 end_hi = 0; ++ char buf[64]; ++ ++ if (md->num_pages == 0) { ++ end = 0; ++ } else if (md->num_pages > EFI_PAGES_MAX || ++ EFI_PAGES_MAX - md->num_pages < ++ (md->phys_addr >> EFI_PAGE_SHIFT)) { ++ end_hi = (md->num_pages & OVERFLOW_ADDR_MASK) ++ >> OVERFLOW_ADDR_SHIFT; ++ ++ if ((md->phys_addr & U64_HIGH_BIT) && !(end & U64_HIGH_BIT)) ++ end_hi += 1; ++ } else { ++ return true; ++ } ++ ++ if (once) { ++ pr_warn(FW_BUG "Invalid EFI memory map entries:\n"); ++ once = false; ++ } ++ ++ if (end_hi) { ++ pr_warn("mem%02u: %s range=[0x%016llx-0x%llx%016llx] (invalid)\n", ++ i, efi_md_typeattr_format(buf, sizeof(buf), md), ++ md->phys_addr, end_hi, end); ++ } else { ++ pr_warn("mem%02u: %s range=[0x%016llx-0x%016llx] (invalid)\n", ++ i, efi_md_typeattr_format(buf, sizeof(buf), md), ++ md->phys_addr, end); ++ } ++ return false; ++} ++ ++static void __init efi_clean_memmap(void) ++{ ++ efi_memory_desc_t *out = efi.memmap.map; ++ const efi_memory_desc_t *in = out; ++ const efi_memory_desc_t *end = efi.memmap.map_end; ++ int i, n_removal; ++ ++ for (i = n_removal = 0; in < end; i++) { ++ if (efi_memmap_entry_valid(in, i)) { ++ if (out != in) ++ memcpy(out, in, efi.memmap.desc_size); ++ out = (void *)out + efi.memmap.desc_size; ++ } else { ++ n_removal++; ++ } ++ in = (void *)in + efi.memmap.desc_size; ++ } ++ ++ if (n_removal > 0) { ++ u64 size = efi.memmap.nr_map - n_removal; ++ ++ pr_warn("Removing %d invalid memory map entries.\n", n_removal); ++ efi_memmap_install(efi.memmap.phys_map, size); ++ } ++} ++ + void __init efi_print_memmap(void) + { + efi_memory_desc_t *md; +@@ -472,6 +540,8 @@ void __init efi_init(void) + } + } + ++ efi_clean_memmap(); ++ + if (efi_enabled(EFI_DBG)) + efi_print_memmap(); + } +diff --git a/include/linux/efi.h b/include/linux/efi.h +index 4c1b3ea..712a3aa 100644 +--- a/include/linux/efi.h ++++ b/include/linux/efi.h +@@ -103,6 +103,7 @@ typedef struct { + + #define EFI_PAGE_SHIFT 12 + #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) ++#define EFI_PAGES_MAX (U64_MAX >> EFI_PAGE_SHIFT) + + typedef struct { + u32 type; +-- +2.9.3 + diff --git a/kernel.spec b/kernel.spec index 2e0d5f23c..986c5a721 100644 --- a/kernel.spec +++ b/kernel.spec @@ -626,8 +626,11 @@ Patch665: netfilter-x_tables-deal-with-bogus-nextoffset-values.patch #ongoing complaint, full discussion delayed until ksummit/plumbers Patch849: 0001-iio-Use-event-header-from-kernel-tree.patch +# Work around thinkpad firmware memory layout issues and efi_mem_reserve() +Patch850: 0001-efi-prune-invalid-memory-map-entries.patch + # Request from dwalsh -Patch850: selinux-namespace-fix.patch +Patch851: selinux-namespace-fix.patch # END OF PATCH DEFINITIONS @@ -2167,6 +2170,9 @@ fi # # %changelog +* Wed Jan 11 2017 Laura Abbott +- Add fix for some thinkpads missed during the rebase. + * Mon Jan 09 2017 Laura Abbott - 4.9.2-200 - Linux v4.9.2 rebase -- cgit From 6565ab9edd7b1c9f9fc1b86b64321938fb6ce0bd Mon Sep 17 00:00:00 2001 From: "Justin M. Forbes" Date: Thu, 12 Jan 2017 17:34:19 -0600 Subject: 4.9.3 sources --- sources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources b/sources index b844112b1..2df03010c 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (linux-4.9.tar.xz) = bf67ff812cc3cb7e5059e82cc5db0d9a7c5637f7ed9a42e4730c715bf7047c81ed3a571225f92a33ef0b6d65f35595bc32d773356646df2627da55e9bc7f1f1a SHA512 (perf-man-4.9.tar.gz) = d23bb3da1eadd6623fddbf4696948de7675f3dcf57c711a7427dd7ae111394f58d8f42752938bbea7cd219f1e7f6f116fc67a1c74f769711063940a065f37b99 -SHA512 (patch-4.9.2.xz) = b7033105561d9829151dd1d374baa7f3e19e2ae767dc3a7a0abcf0be7bc821346deb5748809b146847b44f910243fef50a3db32f664ff88a54c37938852bfcb6 +SHA512 (patch-4.9.3.xz) = ebda3a59a2d61759db2b49d57e7805f24423e786a0401b9e71de800038fa38d5d7740127b7d87fd0c5a8ea2ecfe7c3be2d717afe3166d97e48efa9522063dde3 -- cgit From b87411c84063c0afc4c1644b98d7ec99766537eb Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Thu, 12 Jan 2017 15:38:07 -0800 Subject: Linux v4.9.3 --- kernel.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel.spec b/kernel.spec index 986c5a721..f8317c7f5 100644 --- a/kernel.spec +++ b/kernel.spec @@ -54,7 +54,7 @@ Summary: The Linux kernel %if 0%{?released_kernel} # Do we have a -stable update to apply? -%define stable_update 2 +%define stable_update 3 # Set rpm version accordingly %if 0%{?stable_update} %define stablerev %{stable_update} @@ -2170,6 +2170,9 @@ fi # # %changelog +* Thu Jan 12 2017 Laura Abbott - 4.9.3-200 +- Linux v4.9.3 + * Wed Jan 11 2017 Laura Abbott - Add fix for some thinkpads missed during the rebase. -- cgit From daebcac5174fc731de75e6ab0c01805707eac3b7 Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Thu, 12 Jan 2017 16:20:19 -0800 Subject: Re add dropped patch --- kernel.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel.spec b/kernel.spec index f8317c7f5..d1cd87f1a 100644 --- a/kernel.spec +++ b/kernel.spec @@ -632,6 +632,9 @@ Patch850: 0001-efi-prune-invalid-memory-map-entries.patch # Request from dwalsh Patch851: selinux-namespace-fix.patch +#rhbz 1390308 +Patch852: nouveau-add-maxwell-to-backlight-init.patch + # END OF PATCH DEFINITIONS %endif -- cgit