Skip to contentSkip to conversation

riscv: bpf: Fix eBPF's exception tables

PATCH In review Jisheng Zhang 5 participants 7 messages Jan 10, 2022 – Jan 19, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: bpf: Fix eBPF's exception tables

eBPF's exception tables needs to be modified to relative synchronously.

---
 arch/riscv/net/bpf_jit_comp64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/net/bpf_jit_comp64.c +1 -1
index 69bab7e28f91..44c97535bc15 100644
@@ -498,7 +498,7 @@ static int add_exception_handler(const struct bpf_insn *insn,
 	offset = pc - (long)&ex->insn;
 	if (WARN_ON_ONCE(offset >= 0 || offset < INT_MIN))
 		return -ERANGE;
-	ex->insn = pc;
+	ex->insn = offset;
 
 	/*
 	 * Since the extable follows the program, the fixup offset is always
Signature · 1 line
2.34.1
#1 lore raw
Quoted 13 lines · Jisheng Zhang

eBPF's exception tables needs to be modified to relative synchronously.

---
 arch/riscv/net/bpf_jit_comp64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/net/bpf_jit_comp64.c +0 -0
index 69bab7e28f91..44c97535bc15 100644

arch/riscv/net/bpf_jit_comp64.c static int add_exception_handler(const struct bpf_insn *insn, · line 501

Quoted 5 lines
arch/riscv/net/bpf_jit_comp64.c +1 -1
@@ -498,7 +498,7 @@ static int add_exception_handler(const struct bpf_insn *insn,
 	offset = pc - (long)&ex->insn;
 	if (WARN_ON_ONCE(offset >= 0 || offset < INT_MIN))
 		return -ERANGE;
-	ex->insn = pc;
+	ex->insn = offset;

Hi Palmer,

Tong pointed out this issue but there was something wrong with my email forwarding address, so I didn't get his reply. Today, I searched on lore.kernel.org just found his reply, sorry for inconvenience.

Thanks

Quoted 11 lines
arch/riscv/net/bpf_jit_comp64.c +0 -0
 	/*
 	 * Since the extable follows the program, the fixup offset is always
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Acked-by
#2 lore raw

Jisheng/Palmer,

Quoted 6 lines · Jisheng Zhang
Quoted 4 lines · Jisheng Zhang

eBPF's exception tables needs to be modified to relative synchronously.

Nice catch, and apologies for the slow response.

Quoted 17 lines
Quoted 9 lines
---
 arch/riscv/net/bpf_jit_comp64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/net/bpf_jit_comp64.c +0 -0
index 69bab7e28f91..44c97535bc15 100644

arch/riscv/net/bpf_jit_comp64.c static int add_exception_handler(const struct bpf_insn *insn, · line 501

Quoted 5 lines
arch/riscv/net/bpf_jit_comp64.c +1 -1
@@ -498,7 +498,7 @@ static int add_exception_handler(const struct bpf_insn *insn,
      offset = pc - (long)&ex->insn;
      if (WARN_ON_ONCE(offset >= 0 || offset < INT_MIN))
              return -ERANGE;
-     ex->insn = pc;
+     ex->insn = offset;

Hi Palmer,

Quoted 4 lines

Tong pointed out this issue but there was something wrong with my email forwarding address, so I didn't get his reply. Today, I searched on lore.kernel.org just found his reply, sorry for inconvenience.

AFAIK, Jisheng's extable work is still in Palmer's for-next tree.

Daniel/Alexei: This eBPF must follow commit 1f77ed9422cb ("riscv:
switch to relative extable and other improvements"), which is in Palmer's tree. It cannot go via bpf-next.

Palmer, please pull this to your for-next tree.

Thanks,
Björn

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#3 lore raw
Quoted 32 lines · Björn Töpel
Quoted 5 lines · Jisheng Zhang
Quoted 4 lines · Jisheng Zhang

eBPF's exception tables needs to be modified to relative synchronously.

Nice catch, and apologies for the slow response.

Quoted 17 lines
Quoted 9 lines
---
  arch/riscv/net/bpf_jit_comp64.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/net/bpf_jit_comp64.c +0 -0
index 69bab7e28f91..44c97535bc15 100644

arch/riscv/net/bpf_jit_comp64.c static int add_exception_handler(const struct bpf_insn *insn, · line 501

Quoted 5 lines
arch/riscv/net/bpf_jit_comp64.c +1 -1
@@ -498,7 +498,7 @@ static int add_exception_handler(const struct bpf_insn *insn,
       offset = pc - (long)&ex->insn;
       if (WARN_ON_ONCE(offset >= 0 || offset < INT_MIN))
               return -ERANGE;
-     ex->insn = pc;
+     ex->insn = offset;

Hi Palmer,

Quoted 3 lines

Tong pointed out this issue but there was something wrong with my email forwarding address, so I didn't get his reply. Today, I searched on lore.kernel.org just found his reply, sorry for inconvenience.

Quoted 5 lines

AFAIK, Jisheng's extable work is still in Palmer's for-next tree.

Daniel/Alexei: This eBPF must follow commit 1f77ed9422cb ("riscv:
switch to relative extable and other improvements"), which is in Palmer's tree. It cannot go via bpf-next.

Thanks for letting us know, then lets route this fix via Palmer. Maybe he could also add Fixes tags when applying, so stable can pick it up later on.

Cheers,
Daniel

#4 lore raw
Quoted 1 line · Daniel Borkmann

[...]

Quoted 9 lines
Quoted 5 lines

AFAIK, Jisheng's extable work is still in Palmer's for-next tree.

Daniel/Alexei: This eBPF must follow commit 1f77ed9422cb ("riscv:
switch to relative extable and other improvements"), which is in Palmer's tree. It cannot go via bpf-next.

Thanks for letting us know, then lets route this fix via Palmer. Maybe he could also add Fixes tags when applying, so stable can pick it up later on.

It shouldn't have a fixes-tag, since it's a new feature for RV. This was adapting to that new feature. It hasn't made it upstream yet (I hope!).

Cheers,
Björn

#5 lore raw
Quoted 9 lines · Bjorn Topel
Quoted 1 line · Daniel Borkmann

[...]

Quoted 6 lines
Quoted 5 lines

AFAIK, Jisheng's extable work is still in Palmer's for-next tree.

Daniel/Alexei: This eBPF must follow commit 1f77ed9422cb ("riscv:
switch to relative extable and other improvements"), which is in Palmer's tree. It cannot go via bpf-next.

Quoted 7 lines
Quoted 3 lines

Thanks for letting us know, then lets route this fix via Palmer. Maybe he could also add Fixes tags when applying, so stable can pick it up later on.

It shouldn't have a fixes-tag, since it's a new feature for RV. This was adapting to that new feature. It hasn't made it upstream yet (I hope!).

That was actually just merged this morning into Linus' tree. I'm still happy to take the fix via my tree, but you're welcome to take it via a BPF tree as well. I'm juggling some other patches right now, just LMK what works on your end.

IMO it should have a fixes tag: it's a bit of a grey area, but one something's in I generally try and put those tags on it. That way folks who try and backport features at least have a shot at finding the fix (or at least, finding the fix without chasing around the bug ;)).

I also tried poking you guys on the BPF Slack, but I don't really use it and I'm not sure if anyone else does either.

maintainer
#6 lore raw
Quoted 23 lines · Palmer Dabbelt
Quoted 9 lines · Bjorn Topel
Quoted 1 line · Daniel Borkmann

[...]

Quoted 6 lines
Quoted 5 lines

AFAIK, Jisheng's extable work is still in Palmer's for-next tree.

Daniel/Alexei: This eBPF must follow commit 1f77ed9422cb ("riscv:
switch to relative extable and other improvements"), which is in Palmer's tree. It cannot go via bpf-next.

Quoted 7 lines
Quoted 3 lines

Thanks for letting us know, then lets route this fix via Palmer. Maybe he could also add Fixes tags when applying, so stable can pick it up later on.

It shouldn't have a fixes-tag, since it's a new feature for RV. This was adapting to that new feature. It hasn't made it upstream yet (I hope!).

That was actually just merged this morning into Linus' tree. I'm still happy to take the fix via my tree, but you're welcome to take it via a BPF tree as well. I'm juggling some other patches right now, just LMK what works on your end.

Quoted 7 lines

IMO it should have a fixes tag: it's a bit of a grey area, but one something's in I generally try and put those tags on it. That way folks who try and backport features at least have a shot at finding the fix (or at least, finding the fix without chasing around the bug ;)).

I also tried poking you guys on the BPF Slack, but I don't really use it and I'm not sure if anyone else does either.

As per the slack discussion with Daniel, I've put this into the RISC-V for-next tree.

Thanks!