Re: [BUG] riscv: Kernel panic in free_initmem when driver triggers modprobe
From: guibing
Date: Fri Apr 03 2026 - 11:52:34 EST
Hi Vivian,
thank you for your reply,the best_map_size function patch can solve the panic。
I check it again on v6.6.90 rv32 qemu virt platform, there is no problem. The problem may come from my gdb va2pa script which directly read physical memory address on FPGA, i'm not sure "x /x phy_addr" can work well, I will check it later.
vp1:770
vp0:0
virtual addr:c0800000
satp:80081c94
L1 page base :81c94000
L1 pte:300c0401
L2 page base :c0301000
L2 pte:8595bde9 -->here is error
phy addr:fffffffe1656f000
Thanks.
在 2026/4/3 1:45, Vivian Wang 写道:
static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size)
{
+ /*
+ * On 32-bit, avoid PGD (i.e. PMD) sized mappings, since we are not
+ * going to propagate PGD level changes.
+ */
+ if (!IS_ENABLED(CONFIG_64BIT))
+ return PAGE_SIZE;
+
/* Upgrade to PMD_SIZE mappings whenever possible */
if ((base & (PMD_SIZE - 1)) || (size & (PMD_SIZE - 1)))
return PAGE_SIZE;