Skip to content

Commit 2cc6c4a

Browse files
yashshah7paul-walmsley-sifive
authored andcommitted
RISC-V: Add address map dumper
Add support for dumping the kernel address space layout to the console. User can enable CONFIG_DEBUG_VM to dump the virtual memory region into dmesg buffer during boot-up. Signed-off-by: Yash Shah <[email protected]> Reviewed-by: Logan Gunthorpe <[email protected]> Reviewed-by: Anup Patel <[email protected]> [[email protected]: dropped .init/.text/.data/.bss prints; added PCI legacy I/O region display] Signed-off-by: Paul Walmsley <[email protected]>
1 parent de29fe3 commit 2cc6c4a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

arch/riscv/mm/init.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,37 @@ void setup_zero_page(void)
4545
memset((void *)empty_zero_page, 0, PAGE_SIZE);
4646
}
4747

48+
#ifdef CONFIG_DEBUG_VM
49+
static inline void print_mlk(char *name, unsigned long b, unsigned long t)
50+
{
51+
pr_notice("%12s : 0x%08lx - 0x%08lx (%4ld kB)\n", name, b, t,
52+
(((t) - (b)) >> 10));
53+
}
54+
55+
static inline void print_mlm(char *name, unsigned long b, unsigned long t)
56+
{
57+
pr_notice("%12s : 0x%08lx - 0x%08lx (%4ld MB)\n", name, b, t,
58+
(((t) - (b)) >> 20));
59+
}
60+
61+
static void print_vm_layout(void)
62+
{
63+
pr_notice("Virtual kernel memory layout:\n");
64+
print_mlk("fixmap", (unsigned long)FIXADDR_START,
65+
(unsigned long)FIXADDR_TOP);
66+
print_mlm("pci io", (unsigned long)PCI_IO_START,
67+
(unsigned long)PCI_IO_END);
68+
print_mlm("vmemmap", (unsigned long)VMEMMAP_START,
69+
(unsigned long)VMEMMAP_END);
70+
print_mlm("vmalloc", (unsigned long)VMALLOC_START,
71+
(unsigned long)VMALLOC_END);
72+
print_mlm("lowmem", (unsigned long)PAGE_OFFSET,
73+
(unsigned long)high_memory);
74+
}
75+
#else
76+
static void print_vm_layout(void) { }
77+
#endif /* CONFIG_DEBUG_VM */
78+
4879
void __init mem_init(void)
4980
{
5081
#ifdef CONFIG_FLATMEM
@@ -55,6 +86,7 @@ void __init mem_init(void)
5586
memblock_free_all();
5687

5788
mem_init_print_info(NULL);
89+
print_vm_layout();
5890
}
5991

6092
#ifdef CONFIG_BLK_DEV_INITRD

0 commit comments

Comments
 (0)