Skip to contentSkip to conversation

powerpc/bpf: populate extable entries only during the last pass

PATCH Applied Hari Bathini 3 participants 3 messages Apr 25, 2023 – Jul 3, 2023

Subsystems (4)
lore
Share & tools
lore

Hari Bathini

author maintainer
#0 lore raw

PATCH v2 1/1 powerpc/bpf: populate extable entries only during the last pass

Since commit 85e031154c7c ("powerpc/bpf: Perform complete extra passes to update addresses"), two additional passes are performed to avoid space and CPU time wastage on powerpc. But these extra passes led to WARN_ON_ONCE() hits in bpf_add_extable_entry() as extable entries are populated again, during the extra pass, without resetting the index. Fix it by resetting entry index before repopulating extable entries, if and when there is an additional pass.

Fixes 85e031154c7c ("powerpc/bpf: Perform complete extra passes to update addresses")
---
 arch/powerpc/net/bpf_jit_comp.c | 2 ++
 1 file changed, 2 insertions(+)
arch/powerpc/net/bpf_jit_comp.c +2 -0
index e93aefcfb83f..37043dfc1add 100644
@@ -101,6 +101,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
 		bpf_hdr = jit_data->header;
 		proglen = jit_data->proglen;
 		extra_pass = true;
+		/* During extra pass, ensure index is reset before repopulating extable entries */
+		cgctx.exentry_idx = 0;
 		goto skip_init_ctx;
 	}
 
Signature · 1 line
2.40.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Hari Bathini

Since commit 85e031154c7c ("powerpc/bpf: Perform complete extra passes to update addresses"), two additional passes are performed to avoid space and CPU time wastage on powerpc. But these extra passes led to WARN_ON_ONCE() hits in bpf_add_extable_entry() as extable entries are populated again, during the extra pass, without resetting the index. Fix it by resetting entry index before repopulating extable entries, if and when there is an additional pass.

Quoted 6 lines
Fixes 85e031154c7c ("powerpc/bpf: Perform complete extra passes to update addresses")
---
 arch/powerpc/net/bpf_jit_comp.c | 2 ++
 1 file changed, 2 insertions(+)

- Naveen

Quoted 18 lines
arch/powerpc/net/bpf_jit_comp.c +2 -0
index e93aefcfb83f..37043dfc1add 100644
@@ -101,6 +101,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
 		bpf_hdr = jit_data->header;
 		proglen = jit_data->proglen;
 		extra_pass = true;
+		/* During extra pass, ensure index is reset before repopulating extable entries */
+		cgctx.exentry_idx = 0;
 		goto skip_init_ctx;
 	}
 
Signature · 1 line
2.40.0
#2 lore raw
In reply to Hari Bathini
Quoted 9 lines · Hari Bathini

Since commit 85e031154c7c ("powerpc/bpf: Perform complete extra passes to update addresses"), two additional passes are performed to avoid space and CPU time wastage on powerpc. But these extra passes led to WARN_ON_ONCE() hits in bpf_add_extable_entry() as extable entries are populated again, during the extra pass, without resetting the index. Fix it by resetting entry index before repopulating extable entries, if and when there is an additional pass.

[...]

Applied to powerpc/fixes.

[1/1] powerpc/bpf: populate extable entries only during the last pass

      https://git.kernel.org/powerpc/c/35a4b8ce4ac00e940b46b1034916ccb22ce9bdef

cheers