Skip to content

Commit a3d3280

Browse files
AlexGhitipalmer-dabbelt
authored andcommitted
riscv: Fix config KASAN && SPARSEMEM && !SPARSE_VMEMMAP
In order to get the pfn of a struct page* when sparsemem is enabled without vmemmap, the mem_section structures need to be initialized which happens in sparse_init. But kasan_early_init calls pfn_to_page way before sparse_init is called, which then tries to dereference a null mem_section pointer. Fix this by removing the usage of this function in kasan_early_init. Fixes: 8ad8b72 ("riscv: Add KASAN support") Signed-off-by: Alexandre Ghiti <[email protected]> Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 8b274f2 commit a3d3280

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/riscv/mm/kasan_init.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ asmlinkage void __init kasan_early_init(void)
202202

203203
for (i = 0; i < PTRS_PER_PTE; ++i)
204204
set_pte(kasan_early_shadow_pte + i,
205-
mk_pte(virt_to_page(kasan_early_shadow_page),
206-
PAGE_KERNEL));
205+
pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL));
207206

208207
for (i = 0; i < PTRS_PER_PMD; ++i)
209208
set_pmd(kasan_early_shadow_pmd + i,

0 commit comments

Comments
 (0)