* [PATCH v2] riscv: mm: Pre-allocate module page tables for execmem
@ 2026-10-16 10:28 ` Karl Mehltretter
0 siblings, 0 replies; 4+ messages in thread
From: Karl Mehltretter @ 2026-10-16 10:28 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou
Cc: Karl Mehltretter, Alexandre Ghiti, Mike Rapoport,
Luis Chamberlain, Björn Töpel, linux-riscv, bpf,
linux-kernel
RV64 pre-allocates page-table levels for late kernel mappings. The module
range is guarded by CONFIG_MODULES, although execmem can use it without
modules. BPF_JIT_REGION_START..BPF_JIT_REGION_END lies within
MODULES_VADDR..MODULES_END.
With CONFIG_BPF_JIT=y and CONFIG_MODULES=n, execmem adds a mapping to
init_mm while the current process retains an empty PGD entry. Initializing
a BPF program pack then faults:
Unable to handle kernel paging request ...
[ffffffff78000000] pgd=0000000000000000
...
bpf_jit_fill_hole_with_zero
bpf_prog_pack_alloc
Use CONFIG_EXECMEM for the module-range pre-allocation, as powerpc does
for its execmem page-table setup. Both CONFIG_MODULES and CONFIG_BPF_JIT
select it.
Fixes: 2c9e5d4a0082 ("bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Björn Töpel <bjorn@kernel.org>
---
Changes in v2:
- State that the BPF JIT region lies inside the module region (Mike).
- Add Acked-by tags from Mike Rapoport and Björn Töpel.
- No code changes from v1.
v1: https://lore.kernel.org/r/20261015033643.84972-1-kmehltretter@gmail.com/
Notes:
Tested on a BeagleV Ahead with matched LLVM 18.1.3 builds based on
v7.3-rc7:
- unpatched: a native XDP attach triggered the Oops above
- patched: native XDP attach and detach completed without an Oops
arch/riscv/mm/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index fb37b0b67efe..d92342c162e2 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1437,7 +1437,7 @@ static void __init preallocate_pgd_pages_range(unsigned long start, unsigned lon
void __init pgtable_cache_init(void)
{
preallocate_pgd_pages_range(VMALLOC_START, VMALLOC_END, "vmalloc");
- if (IS_ENABLED(CONFIG_MODULES))
+ if (IS_ENABLED(CONFIG_EXECMEM))
preallocate_pgd_pages_range(MODULES_VADDR, MODULES_END, "bpf/modules");
if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) {
preallocate_pgd_pages_range(VMEMMAP_START, VMEMMAP_END, "vmemmap");
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2] riscv: mm: Pre-allocate module page tables for execmem
@ 2026-10-16 10:28 ` Karl Mehltretter
0 siblings, 0 replies; 4+ messages in thread
From: Karl Mehltretter @ 2026-10-16 10:28 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou
Cc: Karl Mehltretter, Alexandre Ghiti, Mike Rapoport,
Luis Chamberlain, Björn Töpel, linux-riscv, bpf,
linux-kernel
RV64 pre-allocates page-table levels for late kernel mappings. The module
range is guarded by CONFIG_MODULES, although execmem can use it without
modules. BPF_JIT_REGION_START..BPF_JIT_REGION_END lies within
MODULES_VADDR..MODULES_END.
With CONFIG_BPF_JIT=y and CONFIG_MODULES=n, execmem adds a mapping to
init_mm while the current process retains an empty PGD entry. Initializing
a BPF program pack then faults:
Unable to handle kernel paging request ...
[ffffffff78000000] pgd=0000000000000000
...
bpf_jit_fill_hole_with_zero
bpf_prog_pack_alloc
Use CONFIG_EXECMEM for the module-range pre-allocation, as powerpc does
for its execmem page-table setup. Both CONFIG_MODULES and CONFIG_BPF_JIT
select it.
Fixes: 2c9e5d4a0082 ("bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Björn Töpel <bjorn@kernel.org>
---
Changes in v2:
- State that the BPF JIT region lies inside the module region (Mike).
- Add Acked-by tags from Mike Rapoport and Björn Töpel.
- No code changes from v1.
v1: https://lore.kernel.org/r/20261015033643.84972-1-kmehltretter@gmail.com/
Notes:
Tested on a BeagleV Ahead with matched LLVM 18.1.3 builds based on
v7.3-rc7:
- unpatched: a native XDP attach triggered the Oops above
- patched: native XDP attach and detach completed without an Oops
arch/riscv/mm/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index fb37b0b67efe..d92342c162e2 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1437,7 +1437,7 @@ static void __init preallocate_pgd_pages_range(unsigned long start, unsigned lon
void __init pgtable_cache_init(void)
{
preallocate_pgd_pages_range(VMALLOC_START, VMALLOC_END, "vmalloc");
- if (IS_ENABLED(CONFIG_MODULES))
+ if (IS_ENABLED(CONFIG_EXECMEM))
preallocate_pgd_pages_range(MODULES_VADDR, MODULES_END, "bpf/modules");
if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) {
preallocate_pgd_pages_range(VMEMMAP_START, VMEMMAP_END, "vmemmap");
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
--
2.39.5 (Apple Git-154)
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] riscv: mm: Pre-allocate module page tables for execmem
2026-10-16 10:28 ` Karl Mehltretter
@ 2026-11-14 9:29 ` Karl Mehltretter
-1 siblings, 0 replies; 4+ messages in thread
From: Karl Mehltretter @ 2026-11-14 9:29 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou
Cc: Alexandre Ghiti, Mike Rapoport, Luis Chamberlain,
Björn Töpel, linux-riscv, bpf, linux-kernel
On Fri, Oct 16, 2026 at 12:28:47PM +0100, Karl Mehltretter wrote:
> Unable to handle kernel paging request ...
> [ffffffff78000000] pgd=0000000000000000
> ...
> bpf_jit_fill_hole_with_zero
> bpf_prog_pack_alloc
>
> Use CONFIG_EXECMEM for the module-range pre-allocation, as powerpc does
> for its execmem page-table setup. Both CONFIG_MODULES and CONFIG_BPF_JIT
> select it.
>
> Fixes: 2c9e5d4a0082 ("bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Acked-by: Björn Töpel <bjorn@kernel.org>
> ---
> Changes in v2:
> - State that the BPF JIT region lies inside the module region (Mike).
> - Add Acked-by tags from Mike Rapoport and Björn Töpel.
> - No code changes from v1.
>
A friendly ping on v2 of this RV64 execmem page-table fix.
Is anything else needed from my side?
Thanks,
Karl
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] riscv: mm: Pre-allocate module page tables for execmem
@ 2026-11-14 9:29 ` Karl Mehltretter
0 siblings, 0 replies; 4+ messages in thread
From: Karl Mehltretter @ 2026-11-14 9:29 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou
Cc: Alexandre Ghiti, Mike Rapoport, Luis Chamberlain,
Björn Töpel, linux-riscv, bpf, linux-kernel
On Fri, Oct 16, 2026 at 12:28:47PM +0100, Karl Mehltretter wrote:
> Unable to handle kernel paging request ...
> [ffffffff78000000] pgd=0000000000000000
> ...
> bpf_jit_fill_hole_with_zero
> bpf_prog_pack_alloc
>
> Use CONFIG_EXECMEM for the module-range pre-allocation, as powerpc does
> for its execmem page-table setup. Both CONFIG_MODULES and CONFIG_BPF_JIT
> select it.
>
> Fixes: 2c9e5d4a0082 ("bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Acked-by: Björn Töpel <bjorn@kernel.org>
> ---
> Changes in v2:
> - State that the BPF JIT region lies inside the module region (Mike).
> - Add Acked-by tags from Mike Rapoport and Björn Töpel.
> - No code changes from v1.
>
A friendly ping on v2 of this RV64 execmem page-table fix.
Is anything else needed from my side?
Thanks,
Karl
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-14 9:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 10:28 [PATCH v2] riscv: mm: Pre-allocate module page tables for execmem Karl Mehltretter
2026-10-16 10:28 ` Karl Mehltretter
2026-11-14 9:29 ` Karl Mehltretter
2026-11-14 9:29 ` Karl Mehltretter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.