Skip to content

Commit e4fcfe6

Browse files
AlexGhitipalmer-dabbelt
authored andcommitted
riscv: Fix kasan pud population
In sv48, the kasan inner regions are not aligned on PGDIR_SIZE and then when we populate the kasan linear mapping region, we clear the kasan vmalloc region which is in the same PGD. Fix this by copying the content of the kasan early pud after allocating a new PGD for the first time. Fixes: e8a62cc ("riscv: Implement sv48 support") Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com> Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 625e24a commit e4fcfe6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/riscv/mm/kasan_init.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ static void __init kasan_populate_pud(pgd_t *pgd,
113113
base_pud = pt_ops.get_pud_virt(pfn_to_phys(_pgd_pfn(*pgd)));
114114
} else {
115115
base_pud = (pud_t *)pgd_page_vaddr(*pgd);
116-
if (base_pud == lm_alias(kasan_early_shadow_pud))
116+
if (base_pud == lm_alias(kasan_early_shadow_pud)) {
117117
base_pud = memblock_alloc(PTRS_PER_PUD * sizeof(pud_t), PAGE_SIZE);
118+
memcpy(base_pud, (void *)kasan_early_shadow_pud,
119+
sizeof(pud_t) * PTRS_PER_PUD);
120+
}
118121
}
119122

120123
pudp = base_pud + pud_index(vaddr);

0 commit comments

Comments
 (0)