]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0128-mm-sparsemem-Fix-ARM64-boot-crash-when-CONFIG_SPARSE.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0128-mm-sparsemem-Fix-ARM64-boot-crash-when-CONFIG_SPARSE.patch
CommitLineData
321d628a
FG
1From 783e517bb1fd814658cdb26d1d7b5d8f67b448e4 Mon Sep 17 00:00:00 2001
2From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
3Date: Tue, 7 Nov 2017 11:33:37 +0300
e4cdf2a5 4Subject: [PATCH 128/241] mm/sparsemem: Fix ARM64 boot crash when
321d628a
FG
5 CONFIG_SPARSEMEM_EXTREME=y
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10CVE-2017-5754
11
12Since commit:
13
14 83e3c48729d9 ("mm/sparsemem: Allocate mem_section at runtime for CONFIG_SPARSEMEM_EXTREME=y")
15
16we allocate the mem_section array dynamically in sparse_memory_present_with_active_regions(),
17but some architectures, like arm64, don't call the routine to initialize sparsemem.
18
19Let's move the initialization into memory_present() it should cover all
20architectures.
21
22Reported-and-tested-by: Sudeep Holla <sudeep.holla@arm.com>
23Tested-by: Bjorn Andersson <bjorn.andersson@linaro.org>
24Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
25Acked-by: Will Deacon <will.deacon@arm.com>
26Cc: Andrew Morton <akpm@linux-foundation.org>
27Cc: Linus Torvalds <torvalds@linux-foundation.org>
28Cc: Peter Zijlstra <peterz@infradead.org>
29Cc: Thomas Gleixner <tglx@linutronix.de>
30Cc: linux-mm@kvack.org
31Fixes: 83e3c48729d9 ("mm/sparsemem: Allocate mem_section at runtime for CONFIG_SPARSEMEM_EXTREME=y")
32Link: http://lkml.kernel.org/r/20171107083337.89952-1-kirill.shutemov@linux.intel.com
33Signed-off-by: Ingo Molnar <mingo@kernel.org>
34(cherry picked from commit 629a359bdb0e0652a8227b4ff3125431995fec6e)
35Signed-off-by: Andy Whitcroft <apw@canonical.com>
36Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
37(cherry picked from commit fbc3acbf37de68310eb5bbc7f4d1977e7b90100e)
38Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
39---
40 mm/page_alloc.c | 10 ----------
41 mm/sparse.c | 10 ++++++++++
42 2 files changed, 10 insertions(+), 10 deletions(-)
43
44diff --git a/mm/page_alloc.c b/mm/page_alloc.c
45index 66eb23ab658d..1423da8dd16f 100644
46--- a/mm/page_alloc.c
47+++ b/mm/page_alloc.c
48@@ -5707,16 +5707,6 @@ void __init sparse_memory_present_with_active_regions(int nid)
49 unsigned long start_pfn, end_pfn;
50 int i, this_nid;
51
52-#ifdef CONFIG_SPARSEMEM_EXTREME
53- if (!mem_section) {
54- unsigned long size, align;
55-
56- size = sizeof(struct mem_section) * NR_SECTION_ROOTS;
57- align = 1 << (INTERNODE_CACHE_SHIFT);
58- mem_section = memblock_virt_alloc(size, align);
59- }
60-#endif
61-
62 for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, &this_nid)
63 memory_present(this_nid, start_pfn, end_pfn);
64 }
65diff --git a/mm/sparse.c b/mm/sparse.c
66index 308a0789d1bb..9c48e4fe8ce0 100644
67--- a/mm/sparse.c
68+++ b/mm/sparse.c
69@@ -210,6 +210,16 @@ void __init memory_present(int nid, unsigned long start, unsigned long end)
70 {
71 unsigned long pfn;
72
73+#ifdef CONFIG_SPARSEMEM_EXTREME
74+ if (unlikely(!mem_section)) {
75+ unsigned long size, align;
76+
77+ size = sizeof(struct mem_section) * NR_SECTION_ROOTS;
78+ align = 1 << (INTERNODE_CACHE_SHIFT);
79+ mem_section = memblock_virt_alloc(size, align);
80+ }
81+#endif
82+
83 start &= PAGE_SECTION_MASK;
84 mminit_validate_memmodel_limits(&start, &end);
85 for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) {
86--
872.14.2
88