The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations
@ 2026-06-26 18:42 Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 1/5] bpf: dispatcher: allocate bpf_dispatcher->rw_image with vmalloc() Mike Rapoport (Microsoft)
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-06-26 18:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Daniel Borkmann, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	Mike Rapoport, H. Peter Anvin, Yonghong Song, bpf, linux-kernel,
	x86

Hi,

BPF allocations of executable memory on x86 are essentially read-only. Most
paths that call bpf_jit_alloc_exec() immediately make it ROX with
set_memory_rox().

The code generation, at least on x86, uses separately allocated writable
buffers and then updates the actual text memory with text_poke().

These patches do several small adjustments to how BPF allocates executable
memory and enable EXECMEM_ROX_CACHE for BPF allocations on x86.

---
Mike Rapoport (Microsoft) (5):
      bpf: dispatcher: allocate bpf_dispatcher->rw_image with vmalloc()
      bpf: drop __weak from bpf_jit_alloc_exec() and bpf_jit_free_exec()
      bpf: alloc_prog_pack(): skip ROX management for already ROX memory
      bpf, x86: make sure allocation in arch_bpf_trampoline_size() is writable
      x86/bpf: enable EXECMEM_ROX_CACHE for BPF allocations

 arch/x86/mm/init.c          |  4 ++--
 arch/x86/net/bpf_jit_comp.c |  5 ++---
 include/linux/filter.h      |  1 +
 kernel/bpf/core.c           | 30 +++++++++++++++++++++---------
 kernel/bpf/dispatcher.c     |  5 ++++-
 5 files changed, 30 insertions(+), 15 deletions(-)
---
base-commit: 53435562a725962e4de0c29653223129ba11643a
change-id: 20260626-execmem-x86-rox-bpf-v0-b4241ade80df

Best regards,
--  
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH bpf-next 1/5] bpf: dispatcher: allocate bpf_dispatcher->rw_image with vmalloc()
  2026-06-26 18:42 [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
@ 2026-06-26 18:42 ` Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 2/5] bpf: drop __weak from bpf_jit_alloc_exec() and bpf_jit_free_exec() Mike Rapoport (Microsoft)
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-06-26 18:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Daniel Borkmann, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	Mike Rapoport, H. Peter Anvin, Yonghong Song, bpf, linux-kernel,
	x86

bpf_dispatcher->rw_image is a temporary writable buffer that
arch_prepare_bpf_dispatcher() fills and then copies into
bpf_dispatcher->image using bpf_arch_text_copy().

The rel32 offsets emitted by emit_bpf_dispatcher() are calculated against
->image, so ->rw_image does not need to live in the module address range.

Allocate ->rw_image with vmalloc() to avoid permissions dance when
EXECMEM_BPF will be backed by ROX caches.

Also saves a bit of space in the more scarce module address space.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 kernel/bpf/dispatcher.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/dispatcher.c b/kernel/bpf/dispatcher.c
index b77db7413f8c..a7a6a375cdd3 100644
--- a/kernel/bpf/dispatcher.c
+++ b/kernel/bpf/dispatcher.c
@@ -148,7 +148,10 @@ void bpf_dispatcher_change_prog(struct bpf_dispatcher *d, struct bpf_prog *from,
 		d->image = bpf_prog_pack_alloc(PAGE_SIZE, bpf_jit_fill_hole_with_zero);
 		if (!d->image)
 			goto out;
-		d->rw_image = bpf_jit_alloc_exec(PAGE_SIZE);
+		/* d->rw_image doesn't need to be in module memory range, so we
+		 * can use vmalloc.
+		 */
+		d->rw_image = vmalloc(PAGE_SIZE);
 		if (!d->rw_image) {
 			bpf_prog_pack_free(d->image, PAGE_SIZE);
 			d->image = NULL;

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH bpf-next 2/5] bpf: drop __weak from bpf_jit_alloc_exec() and bpf_jit_free_exec()
  2026-06-26 18:42 [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 1/5] bpf: dispatcher: allocate bpf_dispatcher->rw_image with vmalloc() Mike Rapoport (Microsoft)
@ 2026-06-26 18:42 ` Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 3/5] bpf: alloc_prog_pack(): skip ROX management for already ROX memory Mike Rapoport (Microsoft)
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-06-26 18:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Daniel Borkmann, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	Mike Rapoport, H. Peter Anvin, Yonghong Song, bpf, linux-kernel,
	x86

bpf_jit_alloc_exec() and bpf_jit_free_exec() are wrappers for the
corresponding execmem APIs.

Architectures define the properties of the memory range needed by BPF in
their initialization of execmem and don't need to override neither of
them.

Drop the __weak qualifier from bpf_jit_alloc_exec() and
bpf_jit_free_exec().

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 kernel/bpf/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 649cce41e13f..2188f6b5a9e2 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1060,12 +1060,12 @@ void bpf_jit_uncharge_modmem(u32 size)
 	atomic_long_sub(size, &bpf_jit_current);
 }
 
-void *__weak bpf_jit_alloc_exec(unsigned long size)
+void *bpf_jit_alloc_exec(unsigned long size)
 {
 	return execmem_alloc(EXECMEM_BPF, size);
 }
 
-void __weak bpf_jit_free_exec(void *addr)
+void bpf_jit_free_exec(void *addr)
 {
 	execmem_free(addr);
 }

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH bpf-next 3/5] bpf: alloc_prog_pack(): skip ROX management for already ROX memory
  2026-06-26 18:42 [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 1/5] bpf: dispatcher: allocate bpf_dispatcher->rw_image with vmalloc() Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 2/5] bpf: drop __weak from bpf_jit_alloc_exec() and bpf_jit_free_exec() Mike Rapoport (Microsoft)
@ 2026-06-26 18:42 ` Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 4/5] bpf, x86: make sure allocation in arch_bpf_trampoline_size() is writable Mike Rapoport (Microsoft)
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-06-26 18:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Daniel Borkmann, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	Mike Rapoport, H. Peter Anvin, Yonghong Song, bpf, linux-kernel,
	x86

execmem_alloc() can return ROX memory that is already filled with
architecture defined trapping instructions.

In preparation for enabling this mode for BPF on x86, make sure that there
is no redundant management of the ROX memory.

There is no need to fill allocated memory with trapping instructions, to
request permissions reset on free and to set ROX permissions as this all
is handled by execmem_alloc().

Add bpf_jit_mem_is_rox() wrapper for execmem_is_rox(), use it to check if
execmem_alloc() returns ROX memory and skip the redundant steps in that
case.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 kernel/bpf/core.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 2188f6b5a9e2..9666b6cca797 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -904,6 +904,11 @@ static LIST_HEAD(pack_list);
 
 #define BPF_PROG_CHUNK_COUNT (BPF_PROG_PACK_SIZE / BPF_PROG_CHUNK_SIZE)
 
+static bool bpf_jit_mem_is_rox(void)
+{
+	return execmem_is_rox(EXECMEM_BPF);
+}
+
 static struct bpf_prog_pack *alloc_new_pack(bpf_jit_fill_hole_t bpf_fill_ill_insns)
 {
 	struct bpf_prog_pack *pack;
@@ -915,14 +920,16 @@ static struct bpf_prog_pack *alloc_new_pack(bpf_jit_fill_hole_t bpf_fill_ill_ins
 	pack->ptr = bpf_jit_alloc_exec(BPF_PROG_PACK_SIZE);
 	if (!pack->ptr)
 		goto out;
-	bpf_fill_ill_insns(pack->ptr, BPF_PROG_PACK_SIZE);
 	bitmap_zero(pack->bitmap, BPF_PROG_PACK_SIZE / BPF_PROG_CHUNK_SIZE);
 
-	set_vm_flush_reset_perms(pack->ptr);
-	err = set_memory_rox((unsigned long)pack->ptr,
-			     BPF_PROG_PACK_SIZE / PAGE_SIZE);
-	if (err)
-		goto out;
+	if (!bpf_jit_mem_is_rox()) {
+		bpf_fill_ill_insns(pack->ptr, BPF_PROG_PACK_SIZE);
+		set_vm_flush_reset_perms(pack->ptr);
+		err = set_memory_rox((unsigned long)pack->ptr,
+				     BPF_PROG_PACK_SIZE / PAGE_SIZE);
+		if (err)
+			goto out;
+	}
 	list_add_tail(&pack->list, &pack_list);
 	return pack;
 
@@ -943,7 +950,7 @@ void *bpf_prog_pack_alloc(u32 size, bpf_jit_fill_hole_t bpf_fill_ill_insns)
 	if (size > BPF_PROG_PACK_SIZE) {
 		size = round_up(size, PAGE_SIZE);
 		ptr = bpf_jit_alloc_exec(size);
-		if (ptr) {
+		if (ptr && !bpf_jit_mem_is_rox()) {
 			int err;
 
 			bpf_fill_ill_insns(ptr, size);

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH bpf-next 4/5] bpf, x86: make sure allocation in arch_bpf_trampoline_size() is writable
  2026-06-26 18:42 [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
                   ` (2 preceding siblings ...)
  2026-06-26 18:42 ` [PATCH bpf-next 3/5] bpf: alloc_prog_pack(): skip ROX management for already ROX memory Mike Rapoport (Microsoft)
@ 2026-06-26 18:42 ` Mike Rapoport (Microsoft)
  2026-06-26 18:42 ` [PATCH bpf-next 5/5] x86/bpf: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
  2026-07-09  8:03 ` [PATCH bpf-next 0/5] bpf, x86: " Mike Rapoport
  5 siblings, 0 replies; 10+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-06-26 18:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Daniel Borkmann, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	Mike Rapoport, H. Peter Anvin, Yonghong Song, bpf, linux-kernel,
	x86

arch_bpf_trampoline_size() allocates a buffer to get actual size required
for a trampoline.

This buffer must be in the module address space because
__arch_prepare_bpf_trampoline() calculates  rel32 offsets relatively to
that buffer.

In preparation for enabling ROX mode for EXECMEM_BPF make sure that the
allocated memory is writable.

Add bpf_jit_alloc_exec_rw() wrapper for execmem_alloc_rw() and use it for
buffer allocation in arch_bpf_trampoline_size().

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 arch/x86/net/bpf_jit_comp.c | 5 ++---
 include/linux/filter.h      | 1 +
 kernel/bpf/core.c           | 5 +++++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 054e043ffcd2..ba562d3bf031 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -3703,13 +3703,12 @@ int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags,
 	int ret;
 
 	/* Allocate a temporary buffer for __arch_prepare_bpf_trampoline().
-	 * This will NOT cause fragmentation in direct map, as we do not
-	 * call set_memory_*() on this buffer.
 	 *
 	 * We cannot use kvmalloc here, because we need image to be in
 	 * module memory range.
+	 * Since it must be writable use bpf_jit_alloc_exec_rw().
 	 */
-	image = bpf_jit_alloc_exec(PAGE_SIZE);
+	image = bpf_jit_alloc_exec_rw(PAGE_SIZE);
 	if (!image)
 		return -ENOMEM;
 
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 67d337ede91b..773b16f06572 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1323,6 +1323,7 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
 void bpf_jit_binary_free(struct bpf_binary_header *hdr);
 u64 bpf_jit_alloc_exec_limit(void);
 void *bpf_jit_alloc_exec(unsigned long size);
+void *bpf_jit_alloc_exec_rw(unsigned long size);
 void bpf_jit_free_exec(void *addr);
 void bpf_jit_free(struct bpf_prog *fp);
 struct bpf_binary_header *
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 9666b6cca797..55284b5d0292 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1072,6 +1072,11 @@ void *bpf_jit_alloc_exec(unsigned long size)
 	return execmem_alloc(EXECMEM_BPF, size);
 }
 
+void *bpf_jit_alloc_exec_rw(unsigned long size)
+{
+	return execmem_alloc_rw(EXECMEM_BPF, size);
+}
+
 void bpf_jit_free_exec(void *addr)
 {
 	execmem_free(addr);

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH bpf-next 5/5] x86/bpf: enable EXECMEM_ROX_CACHE for BPF allocations
  2026-06-26 18:42 [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
                   ` (3 preceding siblings ...)
  2026-06-26 18:42 ` [PATCH bpf-next 4/5] bpf, x86: make sure allocation in arch_bpf_trampoline_size() is writable Mike Rapoport (Microsoft)
@ 2026-06-26 18:42 ` Mike Rapoport (Microsoft)
  2026-07-09  8:03 ` [PATCH bpf-next 0/5] bpf, x86: " Mike Rapoport
  5 siblings, 0 replies; 10+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-06-26 18:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Daniel Borkmann, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	Mike Rapoport, H. Peter Anvin, Yonghong Song, bpf, linux-kernel,
	x86

BPF core and x86 JIT use text poking and temporary writable buffers and
thus can handle ROX memory.

Enable ROX cache for EXECMEM_BPF when configuration and CPU features allow
that.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 arch/x86/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index fb67217fddcd..079f8c7e9e3c 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -1107,10 +1107,10 @@ struct execmem_info __init *execmem_arch_setup(void)
 				.alignment = MODULE_ALIGN,
 			},
 			[EXECMEM_BPF] = {
-				.flags	= EXECMEM_KASAN_SHADOW,
+				.flags	= flags,
 				.start	= start,
 				.end	= MODULES_END,
-				.pgprot	= PAGE_KERNEL,
+				.pgprot	= pgprot,
 				.alignment = MODULE_ALIGN,
 			},
 			[EXECMEM_MODULE_DATA] = {

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations
  2026-06-26 18:42 [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
                   ` (4 preceding siblings ...)
  2026-06-26 18:42 ` [PATCH bpf-next 5/5] x86/bpf: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
@ 2026-07-09  8:03 ` Mike Rapoport
  2026-07-09 12:12   ` Daniel Borkmann
  5 siblings, 1 reply; 10+ messages in thread
From: Mike Rapoport @ 2026-07-09  8:03 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Daniel Borkmann, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	H. Peter Anvin, Yonghong Song, bpf, linux-kernel, x86

Gentle ping

On Fri, Jun 26, 2026 at 09:42:27PM +0300, Mike Rapoport (Microsoft) wrote:
> Hi,
> 
> BPF allocations of executable memory on x86 are essentially read-only. Most
> paths that call bpf_jit_alloc_exec() immediately make it ROX with
> set_memory_rox().
> 
> The code generation, at least on x86, uses separately allocated writable
> buffers and then updates the actual text memory with text_poke().
> 
> These patches do several small adjustments to how BPF allocates executable
> memory and enable EXECMEM_ROX_CACHE for BPF allocations on x86.
> 
> ---
> Mike Rapoport (Microsoft) (5):
>       bpf: dispatcher: allocate bpf_dispatcher->rw_image with vmalloc()
>       bpf: drop __weak from bpf_jit_alloc_exec() and bpf_jit_free_exec()
>       bpf: alloc_prog_pack(): skip ROX management for already ROX memory
>       bpf, x86: make sure allocation in arch_bpf_trampoline_size() is writable
>       x86/bpf: enable EXECMEM_ROX_CACHE for BPF allocations
> 
>  arch/x86/mm/init.c          |  4 ++--
>  arch/x86/net/bpf_jit_comp.c |  5 ++---
>  include/linux/filter.h      |  1 +
>  kernel/bpf/core.c           | 30 +++++++++++++++++++++---------
>  kernel/bpf/dispatcher.c     |  5 ++++-
>  5 files changed, 30 insertions(+), 15 deletions(-)
> ---
> base-commit: 53435562a725962e4de0c29653223129ba11643a
> change-id: 20260626-execmem-x86-rox-bpf-v0-b4241ade80df
> 
> Best regards,
> --  
> Sincerely yours,
> Mike.
> 

-- 
Sincerely yours,
Mike.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations
  2026-07-09  8:03 ` [PATCH bpf-next 0/5] bpf, x86: " Mike Rapoport
@ 2026-07-09 12:12   ` Daniel Borkmann
  2026-07-09 12:55     ` Mike Rapoport
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Borkmann @ 2026-07-09 12:12 UTC (permalink / raw)
  To: Mike Rapoport, Alexei Starovoitov, Andrii Nakryiko,
	Andy Lutomirski, Borislav Petkov, Dave Hansen, Eduard Zingerman,
	Ingo Molnar, Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner
  Cc: Emil Tsalapatis, Jiri Olsa, John Fastabend, Martin KaFai Lau,
	H. Peter Anvin, Yonghong Song, bpf, linux-kernel, x86

Hi Mike,

On 7/9/26 10:03 AM, Mike Rapoport wrote:
> Gentle ping
> 
> On Fri, Jun 26, 2026 at 09:42:27PM +0300, Mike Rapoport (Microsoft) wrote:
>> Hi,
>>
>> BPF allocations of executable memory on x86 are essentially read-only. Most
>> paths that call bpf_jit_alloc_exec() immediately make it ROX with
>> set_memory_rox().
>>
>> The code generation, at least on x86, uses separately allocated writable
>> buffers and then updates the actual text memory with text_poke().
>>
>> These patches do several small adjustments to how BPF allocates executable
>> memory and enable EXECMEM_ROX_CACHE for BPF allocations on x86.
I think there was an open Q from Alexei wrt the sashiko reports [0] and
whether you could address them. Once done, please resend to bpf list.

Thanks,
Daniel

   [0] https://lore.kernel.org/bpf/20260626-execmem-x86-rox-bpf-v0-v1-0-45a0b0ed4fe9@kernel.org/#r

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations
  2026-07-09 12:12   ` Daniel Borkmann
@ 2026-07-09 12:55     ` Mike Rapoport
  2026-07-10 12:30       ` Daniel Borkmann
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Rapoport @ 2026-07-09 12:55 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Dave Hansen, Eduard Zingerman, Ingo Molnar,
	Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner, Emil Tsalapatis, Jiri Olsa, John Fastabend,
	Martin KaFai Lau, H. Peter Anvin, Yonghong Song, bpf,
	linux-kernel, x86

Hi Daniel,

On Thu, Jul 09, 2026 at 02:12:04PM +0200, Daniel Borkmann wrote:
> Hi Mike,
> 
> On 7/9/26 10:03 AM, Mike Rapoport wrote:
> > Gentle ping
> > 
> > On Fri, Jun 26, 2026 at 09:42:27PM +0300, Mike Rapoport (Microsoft) wrote:
> > > Hi,
> > > 
> > > BPF allocations of executable memory on x86 are essentially read-only. Most
> > > paths that call bpf_jit_alloc_exec() immediately make it ROX with
> > > set_memory_rox().
> > > 
> > > The code generation, at least on x86, uses separately allocated writable
> > > buffers and then updates the actual text memory with text_poke().
> > > 
> > > These patches do several small adjustments to how BPF allocates executable
> > > memory and enable EXECMEM_ROX_CACHE for BPF allocations on x86.
>
> I think there was an open Q from Alexei wrt the sashiko reports [0] and
> whether you could address them. Once done, please resend to bpf list.

Thanks for the link!
I'm not subscribed to bpf@ and it took me a few minutes to realize why I
don't see this in my inbox.
 
> Thanks,
> Daniel
> 
>   [0] https://lore.kernel.org/bpf/20260626-execmem-x86-rox-bpf-v0-v1-0-45a0b0ed4fe9@kernel.org/#r

-- 
Sincerely yours,
Mike.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations
  2026-07-09 12:55     ` Mike Rapoport
@ 2026-07-10 12:30       ` Daniel Borkmann
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Borkmann @ 2026-07-10 12:30 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Alexei Starovoitov, Andrii Nakryiko, Andy Lutomirski,
	Borislav Petkov, Dave Hansen, Eduard Zingerman, Ingo Molnar,
	Kumar Kartikeya Dwivedi, Peter Zijlstra, Song Liu,
	Thomas Gleixner, Emil Tsalapatis, Jiri Olsa, John Fastabend,
	Martin KaFai Lau, H. Peter Anvin, Yonghong Song, bpf,
	linux-kernel, x86

Hi Mike,

On 7/9/26 2:55 PM, Mike Rapoport wrote:
> On Thu, Jul 09, 2026 at 02:12:04PM +0200, Daniel Borkmann wrote:
>> On 7/9/26 10:03 AM, Mike Rapoport wrote:
>>> Gentle ping
>>>
>>> On Fri, Jun 26, 2026 at 09:42:27PM +0300, Mike Rapoport (Microsoft) wrote:
>>>> Hi,
>>>>
>>>> BPF allocations of executable memory on x86 are essentially read-only. Most
>>>> paths that call bpf_jit_alloc_exec() immediately make it ROX with
>>>> set_memory_rox().
>>>>
>>>> The code generation, at least on x86, uses separately allocated writable
>>>> buffers and then updates the actual text memory with text_poke().
>>>>
>>>> These patches do several small adjustments to how BPF allocates executable
>>>> memory and enable EXECMEM_ROX_CACHE for BPF allocations on x86.
>>
>> I think there was an open Q from Alexei wrt the sashiko reports [0] and
>> whether you could address them. Once done, please resend to bpf list.
> 
> Thanks for the link!
> I'm not subscribed to bpf@ and it took me a few minutes to realize why I
> don't see this in my inbox.

Ok, np. Despite the sashiko false positives, could you pls resend against
latest bpf-next, so your set can run through the upstream BPF CI?

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-07-10 12:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26 18:42 [PATCH bpf-next 0/5] bpf, x86: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
2026-06-26 18:42 ` [PATCH bpf-next 1/5] bpf: dispatcher: allocate bpf_dispatcher->rw_image with vmalloc() Mike Rapoport (Microsoft)
2026-06-26 18:42 ` [PATCH bpf-next 2/5] bpf: drop __weak from bpf_jit_alloc_exec() and bpf_jit_free_exec() Mike Rapoport (Microsoft)
2026-06-26 18:42 ` [PATCH bpf-next 3/5] bpf: alloc_prog_pack(): skip ROX management for already ROX memory Mike Rapoport (Microsoft)
2026-06-26 18:42 ` [PATCH bpf-next 4/5] bpf, x86: make sure allocation in arch_bpf_trampoline_size() is writable Mike Rapoport (Microsoft)
2026-06-26 18:42 ` [PATCH bpf-next 5/5] x86/bpf: enable EXECMEM_ROX_CACHE for BPF allocations Mike Rapoport (Microsoft)
2026-07-09  8:03 ` [PATCH bpf-next 0/5] bpf, x86: " Mike Rapoport
2026-07-09 12:12   ` Daniel Borkmann
2026-07-09 12:55     ` Mike Rapoport
2026-07-10 12:30       ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox