Skip to content

Commit 5fde3db

Browse files
zongboxpalmer-dabbelt
authored andcommitted
riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support
ARCH_SUPPORTS_DEBUG_PAGEALLOC provides a hook to map and unmap pages for debugging purposes. Implement the __kernel_map_pages functions to fill the poison pattern. Signed-off-by: Zong Li <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 395a21f commit 5fde3db

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

arch/riscv/Kconfig

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ config ARCH_SELECT_MEMORY_MODEL
131131
config ARCH_WANT_GENERAL_HUGETLB
132132
def_bool y
133133

134+
config ARCH_SUPPORTS_DEBUG_PAGEALLOC
135+
def_bool y
136+
134137
config SYS_SUPPORTS_HUGETLBFS
135138
def_bool y
136139

arch/riscv/mm/pageattr.c

+13
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,16 @@ int set_direct_map_default_noflush(struct page *page)
172172

173173
return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks);
174174
}
175+
176+
void __kernel_map_pages(struct page *page, int numpages, int enable)
177+
{
178+
if (!debug_pagealloc_enabled())
179+
return;
180+
181+
if (enable)
182+
__set_memory((unsigned long)page_address(page), numpages,
183+
__pgprot(_PAGE_PRESENT), __pgprot(0));
184+
else
185+
__set_memory((unsigned long)page_address(page), numpages,
186+
__pgprot(0), __pgprot(_PAGE_PRESENT));
187+
}

0 commit comments

Comments
 (0)