]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.8.16/arm64-mark-reserved-memblock-regions-explicitly-in-iomem.patch
Drop watchdog patch
[thirdparty/kernel/stable-queue.git] / releases / 4.8.16 / arm64-mark-reserved-memblock-regions-explicitly-in-iomem.patch
1 From e7cd190385d17790cc3eb3821b1094b00aacf325 Mon Sep 17 00:00:00 2001
2 From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 Date: Mon, 22 Aug 2016 15:55:24 +0900
4 Subject: arm64: mark reserved memblock regions explicitly in iomem
5
6 From: AKASHI Takahiro <takahiro.akashi@linaro.org>
7
8 commit e7cd190385d17790cc3eb3821b1094b00aacf325 upstream.
9
10 Kdump(kexec-tools) parses /proc/iomem to identify all the memory regions
11 on the system. Since the current kernel names "nomap" regions, like UEFI
12 runtime services code/data, as "System RAM," kexec-tools sets up elf core
13 header to include them in a crash dump file (/proc/vmcore).
14
15 Then crash dump kernel parses UEFI memory map again, re-marks those regions
16 as "nomap" and does not create a memory mapping for them unlike the other
17 areas of System RAM. In this case, copying /proc/vmcore through
18 copy_oldmem_page() on crash dump kernel will end up with a kernel abort,
19 as reported in [1].
20
21 This patch names all the "nomap" regions explicitly as "reserved" so that
22 we can exclude them from a crash dump file. acpi_os_ioremap() must also
23 be modified because those regions have WB attributes [2].
24
25 Apart from kdump, this change also matches x86's use of acpi (and
26 /proc/iomem).
27
28 [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/448186.html
29 [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/450089.html
30
31 Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
32 Tested-by: James Morse <james.morse@arm.com>
33 Reviewed-by: James Morse <james.morse@arm.com>
34 Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
35 Signed-off-by: Will Deacon <will.deacon@arm.com>
36 Cc: Matthias Brugger <mbrugger@suse.com>
37 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
38
39 ---
40 arch/arm64/include/asm/acpi.h | 8 ++++++--
41 arch/arm64/kernel/setup.c | 9 +++++++--
42 2 files changed, 13 insertions(+), 4 deletions(-)
43
44 --- a/arch/arm64/include/asm/acpi.h
45 +++ b/arch/arm64/include/asm/acpi.h
46 @@ -12,7 +12,7 @@
47 #ifndef _ASM_ACPI_H
48 #define _ASM_ACPI_H
49
50 -#include <linux/mm.h>
51 +#include <linux/memblock.h>
52 #include <linux/psci.h>
53
54 #include <asm/cputype.h>
55 @@ -32,7 +32,11 @@
56 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
57 acpi_size size)
58 {
59 - if (!page_is_ram(phys >> PAGE_SHIFT))
60 + /*
61 + * EFI's reserve_regions() call adds memory with the WB attribute
62 + * to memblock via early_init_dt_add_memory_arch().
63 + */
64 + if (!memblock_is_memory(phys))
65 return ioremap(phys, size);
66
67 return ioremap_cache(phys, size);
68 --- a/arch/arm64/kernel/setup.c
69 +++ b/arch/arm64/kernel/setup.c
70 @@ -206,10 +206,15 @@ static void __init request_standard_reso
71
72 for_each_memblock(memory, region) {
73 res = alloc_bootmem_low(sizeof(*res));
74 - res->name = "System RAM";
75 + if (memblock_is_nomap(region)) {
76 + res->name = "reserved";
77 + res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
78 + } else {
79 + res->name = "System RAM";
80 + res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
81 + }
82 res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
83 res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
84 - res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
85
86 request_resource(&iomem_resource, res);
87