Skip to content

Commit 146122e

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/mm/dump_pagetables: Make the address hints correct and readable
The address hints are a trainwreck. The array entry numbers have to kept magically in sync with the actual hints, which is doomed as some of the array members are initialized at runtime via the entry numbers. Designated initializers have been around before this code was implemented.... Use the entry numbers to populate the address hints array and add the missing bits and pieces. Split 32 and 64 bit for readability sake. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent c053449 commit 146122e

File tree

1 file changed

+53
-37
lines changed

1 file changed

+53
-37
lines changed

arch/x86/mm/dump_pagetables.c

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ struct addr_marker {
4444
unsigned long max_lines;
4545
};
4646

47-
/* indices for address_markers; keep sync'd w/ address_markers below */
47+
/* Address space markers hints */
48+
49+
#ifdef CONFIG_X86_64
50+
4851
enum address_markers_idx {
4952
USER_SPACE_NR = 0,
50-
#ifdef CONFIG_X86_64
5153
KERNEL_SPACE_NR,
5254
LOW_KERNEL_NR,
5355
VMALLOC_START_NR,
@@ -56,56 +58,70 @@ enum address_markers_idx {
5658
KASAN_SHADOW_START_NR,
5759
KASAN_SHADOW_END_NR,
5860
#endif
59-
# ifdef CONFIG_X86_ESPFIX64
61+
#ifdef CONFIG_X86_ESPFIX64
6062
ESPFIX_START_NR,
61-
# endif
63+
#endif
64+
#ifdef CONFIG_EFI
65+
EFI_END_NR,
66+
#endif
6267
HIGH_KERNEL_NR,
6368
MODULES_VADDR_NR,
6469
MODULES_END_NR,
65-
#else
70+
FIXADDR_START_NR,
71+
END_OF_SPACE_NR,
72+
};
73+
74+
static struct addr_marker address_markers[] = {
75+
[USER_SPACE_NR] = { 0, "User Space" },
76+
[KERNEL_SPACE_NR] = { (1UL << 63), "Kernel Space" },
77+
[LOW_KERNEL_NR] = { 0UL, "Low Kernel Mapping" },
78+
[VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
79+
[VMEMMAP_START_NR] = { 0UL, "Vmemmap" },
80+
#ifdef CONFIG_KASAN
81+
[KASAN_SHADOW_START_NR] = { KASAN_SHADOW_START, "KASAN shadow" },
82+
[KASAN_SHADOW_END_NR] = { KASAN_SHADOW_END, "KASAN shadow end" },
83+
#endif
84+
#ifdef CONFIG_X86_ESPFIX64
85+
[ESPFIX_START_NR] = { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
86+
#endif
87+
#ifdef CONFIG_EFI
88+
[EFI_END_NR] = { EFI_VA_END, "EFI Runtime Services" },
89+
#endif
90+
[HIGH_KERNEL_NR] = { __START_KERNEL_map, "High Kernel Mapping" },
91+
[MODULES_VADDR_NR] = { MODULES_VADDR, "Modules" },
92+
[MODULES_END_NR] = { MODULES_END, "End Modules" },
93+
[FIXADDR_START_NR] = { FIXADDR_START, "Fixmap Area" },
94+
[END_OF_SPACE_NR] = { -1, NULL }
95+
};
96+
97+
#else /* CONFIG_X86_64 */
98+
99+
enum address_markers_idx {
100+
USER_SPACE_NR = 0,
66101
KERNEL_SPACE_NR,
67102
VMALLOC_START_NR,
68103
VMALLOC_END_NR,
69-
# ifdef CONFIG_HIGHMEM
104+
#ifdef CONFIG_HIGHMEM
70105
PKMAP_BASE_NR,
71-
# endif
72-
FIXADDR_START_NR,
73106
#endif
107+
FIXADDR_START_NR,
108+
END_OF_SPACE_NR,
74109
};
75110

76-
/* Address space markers hints */
77111
static struct addr_marker address_markers[] = {
78-
{ 0, "User Space" },
79-
#ifdef CONFIG_X86_64
80-
{ 0x8000000000000000UL, "Kernel Space" },
81-
{ 0/* PAGE_OFFSET */, "Low Kernel Mapping" },
82-
{ 0/* VMALLOC_START */, "vmalloc() Area" },
83-
{ 0/* VMEMMAP_START */, "Vmemmap" },
84-
#ifdef CONFIG_KASAN
85-
{ KASAN_SHADOW_START, "KASAN shadow" },
86-
{ KASAN_SHADOW_END, "KASAN shadow end" },
112+
[USER_SPACE_NR] = { 0, "User Space" },
113+
[KERNEL_SPACE_NR] = { PAGE_OFFSET, "Kernel Mapping" },
114+
[VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
115+
[VMALLOC_END_NR] = { 0UL, "vmalloc() End" },
116+
#ifdef CONFIG_HIGHMEM
117+
[PKMAP_BASE_NR] = { 0UL, "Persistent kmap() Area" },
87118
#endif
88-
# ifdef CONFIG_X86_ESPFIX64
89-
{ ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
90-
# endif
91-
# ifdef CONFIG_EFI
92-
{ EFI_VA_END, "EFI Runtime Services" },
93-
# endif
94-
{ __START_KERNEL_map, "High Kernel Mapping" },
95-
{ MODULES_VADDR, "Modules" },
96-
{ MODULES_END, "End Modules" },
97-
#else
98-
{ PAGE_OFFSET, "Kernel Mapping" },
99-
{ 0/* VMALLOC_START */, "vmalloc() Area" },
100-
{ 0/*VMALLOC_END*/, "vmalloc() End" },
101-
# ifdef CONFIG_HIGHMEM
102-
{ 0/*PKMAP_BASE*/, "Persistent kmap() Area" },
103-
# endif
104-
{ 0/*FIXADDR_START*/, "Fixmap Area" },
105-
#endif
106-
{ -1, NULL } /* End of list */
119+
[FIXADDR_START_NR] = { 0UL, "Fixmap area" },
120+
[END_OF_SPACE_NR] = { -1, NULL }
107121
};
108122

123+
#endif /* !CONFIG_X86_64 */
124+
109125
/* Multipliers for offsets within the PTEs */
110126
#define PTE_LEVEL_MULT (PAGE_SIZE)
111127
#define PMD_LEVEL_MULT (PTRS_PER_PTE * PTE_LEVEL_MULT)

0 commit comments

Comments
 (0)