1 From e16f646082d458ec595304dbc2e6906fdc417495 Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Wed, 20 Dec 2017 18:07:42 +0100
4 Subject: [PATCH 165/231] x86/mm/dump_pagetables: Make the address hints
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
12 The address hints are a trainwreck. The array entry numbers have to kept
13 magically in sync with the actual hints, which is doomed as some of the
14 array members are initialized at runtime via the entry numbers.
16 Designated initializers have been around before this code was
19 Use the entry numbers to populate the address hints array and add the
20 missing bits and pieces. Split 32 and 64 bit for readability sake.
22 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
23 Cc: Andy Lutomirski <luto@kernel.org>
24 Cc: Borislav Petkov <bp@alien8.de>
25 Cc: Dave Hansen <dave.hansen@linux.intel.com>
26 Cc: H. Peter Anvin <hpa@zytor.com>
27 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
28 Cc: Juergen Gross <jgross@suse.com>
29 Cc: Linus Torvalds <torvalds@linux-foundation.org>
30 Cc: Peter Zijlstra <peterz@infradead.org>
31 Cc: linux-kernel@vger.kernel.org
32 Signed-off-by: Ingo Molnar <mingo@kernel.org>
33 (cherry picked from commit 146122e24bdf208015d629babba673e28d090709)
34 Signed-off-by: Andy Whitcroft <apw@canonical.com>
35 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
36 (cherry picked from commit 7f4d9163531183fbaa0df1d1b1ceecbade4e58dc)
37 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
39 arch/x86/mm/dump_pagetables.c | 90 +++++++++++++++++++++++++------------------
40 1 file changed, 53 insertions(+), 37 deletions(-)
42 diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
43 index 91aa41c5e0dd..318a7c30e87e 100644
44 --- a/arch/x86/mm/dump_pagetables.c
45 +++ b/arch/x86/mm/dump_pagetables.c
46 @@ -44,10 +44,12 @@ struct addr_marker {
47 unsigned long max_lines;
50 -/* indices for address_markers; keep sync'd w/ address_markers below */
51 +/* Address space markers hints */
55 enum address_markers_idx {
61 @@ -56,56 +58,70 @@ enum address_markers_idx {
62 KASAN_SHADOW_START_NR,
65 -# ifdef CONFIG_X86_ESPFIX64
66 +#ifdef CONFIG_X86_ESPFIX64
81 +static struct addr_marker address_markers[] = {
82 + [USER_SPACE_NR] = { 0, "User Space" },
83 + [KERNEL_SPACE_NR] = { (1UL << 63), "Kernel Space" },
84 + [LOW_KERNEL_NR] = { 0UL, "Low Kernel Mapping" },
85 + [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
86 + [VMEMMAP_START_NR] = { 0UL, "Vmemmap" },
88 + [KASAN_SHADOW_START_NR] = { KASAN_SHADOW_START, "KASAN shadow" },
89 + [KASAN_SHADOW_END_NR] = { KASAN_SHADOW_END, "KASAN shadow end" },
91 +#ifdef CONFIG_X86_ESPFIX64
92 + [ESPFIX_START_NR] = { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
95 + [EFI_END_NR] = { EFI_VA_END, "EFI Runtime Services" },
97 + [HIGH_KERNEL_NR] = { __START_KERNEL_map, "High Kernel Mapping" },
98 + [MODULES_VADDR_NR] = { MODULES_VADDR, "Modules" },
99 + [MODULES_END_NR] = { MODULES_END, "End Modules" },
100 + [FIXADDR_START_NR] = { FIXADDR_START, "Fixmap Area" },
101 + [END_OF_SPACE_NR] = { -1, NULL }
104 +#else /* CONFIG_X86_64 */
106 +enum address_markers_idx {
111 -# ifdef CONFIG_HIGHMEM
112 +#ifdef CONFIG_HIGHMEM
121 -/* Address space markers hints */
122 static struct addr_marker address_markers[] = {
123 - { 0, "User Space" },
124 -#ifdef CONFIG_X86_64
125 - { 0x8000000000000000UL, "Kernel Space" },
126 - { 0/* PAGE_OFFSET */, "Low Kernel Mapping" },
127 - { 0/* VMALLOC_START */, "vmalloc() Area" },
128 - { 0/* VMEMMAP_START */, "Vmemmap" },
130 - { KASAN_SHADOW_START, "KASAN shadow" },
131 - { KASAN_SHADOW_END, "KASAN shadow end" },
132 + [USER_SPACE_NR] = { 0, "User Space" },
133 + [KERNEL_SPACE_NR] = { PAGE_OFFSET, "Kernel Mapping" },
134 + [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
135 + [VMALLOC_END_NR] = { 0UL, "vmalloc() End" },
136 +#ifdef CONFIG_HIGHMEM
137 + [PKMAP_BASE_NR] = { 0UL, "Persistent kmap() Area" },
139 -# ifdef CONFIG_X86_ESPFIX64
140 - { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
143 - { EFI_VA_END, "EFI Runtime Services" },
145 - { __START_KERNEL_map, "High Kernel Mapping" },
146 - { MODULES_VADDR, "Modules" },
147 - { MODULES_END, "End Modules" },
149 - { PAGE_OFFSET, "Kernel Mapping" },
150 - { 0/* VMALLOC_START */, "vmalloc() Area" },
151 - { 0/*VMALLOC_END*/, "vmalloc() End" },
152 -# ifdef CONFIG_HIGHMEM
153 - { 0/*PKMAP_BASE*/, "Persistent kmap() Area" },
155 - { 0/*FIXADDR_START*/, "Fixmap Area" },
157 - { -1, NULL } /* End of list */
158 + [FIXADDR_START_NR] = { 0UL, "Fixmap area" },
159 + [END_OF_SPACE_NR] = { -1, NULL }
162 +#endif /* !CONFIG_X86_64 */
164 /* Multipliers for offsets within the PTEs */
165 #define PTE_LEVEL_MULT (PAGE_SIZE)
166 #define PMD_LEVEL_MULT (PTRS_PER_PTE * PTE_LEVEL_MULT)