Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1186063 > unrolled thread
| Started by | Nicolas Schichan <nschichan@freebox.fr> |
|---|---|
| First post | 2015-07-16 18:50 +0200 |
| Last post | 2015-07-16 19:40 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/6] BPF JIT fixes and features for ARM Nicolas Schichan <nschichan@freebox.fr> - 2015-07-16 18:50 +0200
[PATCH 2/6] ARM: net: handle negative offsets in BPF JIT. Nicolas Schichan <nschichan@freebox.fr> - 2015-07-16 18:50 +0200
[PATCH 5/6] ARM: net: add support for BPF_ANC | SKF_AD_PAY_OFFSET in ARM JIT. Nicolas Schichan <nschichan@freebox.fr> - 2015-07-16 18:50 +0200
Re: [PATCH 0/6] BPF JIT fixes and features for ARM Alexei Starovoitov <ast@plumgrid.com> - 2015-07-16 19:40 +0200
| From | Nicolas Schichan <nschichan@freebox.fr> |
|---|---|
| Date | 2015-07-16 18:50 +0200 |
| Subject | [PATCH 0/6] BPF JIT fixes and features for ARM |
| Message-ID | <pMUwa-3X1-3@gated-at.bofh.it> |
Hello,
This serie fixes issues with the ARM BPF JIT and adds support for more
instructions to the ARM BPF JIT.
The first three patches are fixing bugs in the ARM JIT and should
probably find their way to a stable kernel.
The last three patches add support to the ARM JIT for more BPF
instructions, namely skb netdevice type retrieval, skb payload offset
retrieval, and skb packet type retrieval.
With the first three patches, all 60 test_bpf tests in Linux 4.1 release
are now passing OK (was 54 out of 60 before).
The last three patches allow 35 tests to use the JIT instead of 29
before.
Like previous ARM JIT patches this should go via the net tree.
Regards,
Nicolas Schichan (6):
ARM: net: fix condition for load_order > 0 when translating load
instructions.
ARM: net: handle negative offsets in BPF JIT.
ARM: net: fix vlan access instructions in ARM JIT.
ARM: net: add support for BPF_ANC | SKF_AD_PKTTYPE in ARM JIT.
ARM: net: add support for BPF_ANC | SKF_AD_PAY_OFFSET in ARM JIT.
ARM: net: add support for BPF_ANC | SKF_AD_HATYPE in ARM JIT.
arch/arm/net/bpf_jit_32.c | 98 +++++++++++++++++++++++++++++++++++++++--------
arch/arm/net/bpf_jit_32.h | 3 ++
2 files changed, 86 insertions(+), 15 deletions(-)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Nicolas Schichan <nschichan@freebox.fr> |
|---|---|
| Date | 2015-07-16 18:50 +0200 |
| Subject | [PATCH 2/6] ARM: net: handle negative offsets in BPF JIT. |
| Message-ID | <pMUwa-3X1-19@gated-at.bofh.it> |
| In reply to | #1186063 |
Previously, the JIT would reject negative offsets known during code
generation and mishandle negative offsets provided at runtime.
Fix that by calling bpf_internal_load_pointer_neg_helper()
appropriately in the jit_get_skb_{b,h,w} slow path helpers and by forcing
the execution flow to the slow path helpers when the offset is
negative.
Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
---
arch/arm/net/bpf_jit_32.c | 47 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 9 deletions(-)
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index 21f5ace..d9b2524 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -74,32 +74,52 @@ struct jit_ctx {
int bpf_jit_enable __read_mostly;
-static u64 jit_get_skb_b(struct sk_buff *skb, unsigned offset)
+static inline int call_neg_helper(struct sk_buff *skb, int offset, void *ret,
+ unsigned int size)
+{
+ void *ptr = bpf_internal_load_pointer_neg_helper(skb, offset, size);
+
+ if (!ptr)
+ return -EFAULT;
+ memcpy(ret, ptr, size);
+ return 0;
+}
+
+static u64 jit_get_skb_b(struct sk_buff *skb, int offset)
{
u8 ret;
int err;
- err = skb_copy_bits(skb, offset, &ret, 1);
+ if (offset < 0)
+ err = call_neg_helper(skb, offset, &ret, 1);
+ else
+ err = skb_copy_bits(skb, offset, &ret, 1);
return (u64)err << 32 | ret;
}
-static u64 jit_get_skb_h(struct sk_buff *skb, unsigned offset)
+static u64 jit_get_skb_h(struct sk_buff *skb, int offset)
{
u16 ret;
int err;
- err = skb_copy_bits(skb, offset, &ret, 2);
+ if (offset < 0)
+ err = call_neg_helper(skb, offset, &ret, 2);
+ else
+ err = skb_copy_bits(skb, offset, &ret, 2);
return (u64)err << 32 | ntohs(ret);
}
-static u64 jit_get_skb_w(struct sk_buff *skb, unsigned offset)
+static u64 jit_get_skb_w(struct sk_buff *skb, int offset)
{
u32 ret;
int err;
- err = skb_copy_bits(skb, offset, &ret, 4);
+ if (offset < 0)
+ err = call_neg_helper(skb, offset, &ret, 4);
+ else
+ err = skb_copy_bits(skb, offset, &ret, 4);
return (u64)err << 32 | ntohl(ret);
}
@@ -536,9 +556,6 @@ static int build_body(struct jit_ctx *ctx)
case BPF_LD | BPF_B | BPF_ABS:
load_order = 0;
load:
- /* the interpreter will deal with the negative K */
- if ((int)k < 0)
- return -ENOTSUPP;
emit_mov_i(r_off, k, ctx);
load_common:
ctx->seen |= SEEN_DATA | SEEN_CALL;
@@ -553,6 +570,18 @@ load_common:
condt = ARM_COND_HI;
}
+ /*
+ * test for negative offset, only if we are
+ * currently scheduled to take the fast
+ * path. this will update the flags so that
+ * the slowpath instruction are ignored if the
+ * offset is negative.
+ *
+ * for loard_order == 0 the HI condition will
+ * make loads at offset 0 take the slow path too.
+ */
+ _emit(condt, ARM_CMP_I(r_off, 0), ctx);
+
_emit(condt, ARM_ADD_R(r_scratch, r_off, r_skb_data),
ctx);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Schichan <nschichan@freebox.fr> |
|---|---|
| Date | 2015-07-16 18:50 +0200 |
| Subject | [PATCH 5/6] ARM: net: add support for BPF_ANC | SKF_AD_PAY_OFFSET in ARM JIT. |
| Message-ID | <pMUwb-3X1-27@gated-at.bofh.it> |
| In reply to | #1186063 |
Signed-off-by: Nicolas Schichan <nschichan@freebox.fr> --- arch/arm/net/bpf_jit_32.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c index 6ff248c..3c73caf 100644 --- a/arch/arm/net/bpf_jit_32.c +++ b/arch/arm/net/bpf_jit_32.c @@ -915,6 +915,14 @@ b_epilogue: off = offsetof(struct sk_buff, queue_mapping); emit(ARM_LDRH_I(r_A, r_skb, off), ctx); break; + case BPF_ANC | SKF_AD_PAY_OFFSET: + ctx->seen |= SEEN_SKB | SEEN_CALL; + + emit(ARM_MOV_R(ARM_R0, r_skb), ctx); + emit_mov_i(ARM_R3, (unsigned int)skb_get_poff, ctx); + emit_blx_r(ARM_R3, ctx); + emit(ARM_MOV_R(r_A, ARM_R0), ctx); + break; case BPF_LDX | BPF_W | BPF_ABS: /* * load a 32bit word from struct seccomp_data. -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Alexei Starovoitov <ast@plumgrid.com> |
|---|---|
| Date | 2015-07-16 19:40 +0200 |
| Message-ID | <pMViA-57c-51@gated-at.bofh.it> |
| In reply to | #1186063 |
On 7/16/15 9:46 AM, Nicolas Schichan wrote: > This serie fixes issues with the ARM BPF JIT and adds support for more > instructions to the ARM BPF JIT. > > The first three patches are fixing bugs in the ARM JIT and should > probably find their way to a stable kernel. > > The last three patches add support to the ARM JIT for more BPF > instructions, namely skb netdevice type retrieval, skb payload offset > retrieval, and skb packet type retrieval. > > With the first three patches, all 60 test_bpf tests in Linux 4.1 release > are now passing OK (was 54 out of 60 before). > > The last three patches allow 35 tests to use the JIT instead of 29 > before. looks good to me. For the series: Acked-by: Alexei Starovoitov <ast@plumgrid.com> you might want to try the latest 4.2-rc, since it has 238 tests :) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web