All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/6] net/skbuff: add macros for VLAN_PRESENT bit
  2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
  2017-01-04  1:18   ` Michał Mirosław
@ 2017-01-04  1:18   ` Michał Mirosław
  2017-01-04  1:18   ` Michał Mirosław
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev
  Cc: Russell King, Ralf Baechle, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, David S. Miller,
	linux-arm-kernel, linux-mips, linuxppc-dev, sparclinux

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 include/linux/skbuff.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b53c0cfd417e..168c3e486bd4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -768,6 +768,12 @@ struct sk_buff {
 	__u32			priority;
 	int			skb_iif;
 	__u32			hash;
+#define PKT_VLAN_PRESENT_BIT	4	// CFI (12-th bit) in TCI
+#ifdef __BIG_ENDIAN
+#define PKT_VLAN_PRESENT_OFFSET()	offsetof(struct sk_buff, vlan_tci)
+#else
+#define PKT_VLAN_PRESENT_OFFSET()	(offsetof(struct sk_buff, vlan_tci) + 1)
+#endif
 	__be16			vlan_proto;
 	__u16			vlan_tci;
 #if defined(CONFIG_NET_RX_BUSY_POLL) || defined(CONFIG_XPS)
-- 
2.11.0

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

* [PATCH net-next 2/6] net/bpf_jit: ARM: split VLAN_PRESENT bit handling from VLAN_TCI
  2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
@ 2017-01-04  1:18   ` Michał Mirosław
  2017-01-04  1:18   ` Michał Mirosław
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev; +Cc: Russell King, linux-arm-kernel

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
v2: remove one insn for big-endians

 arch/arm/net/bpf_jit_32.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index 93d0b6d0b63e..0700cbbe4f14 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -915,17 +915,21 @@ static int build_body(struct jit_ctx *ctx)
 			emit(ARM_LDR_I(r_A, r_skb, off), ctx);
 			break;
 		case BPF_ANC | SKF_AD_VLAN_TAG:
-		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
 			ctx->seen |= SEEN_SKB;
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2);
 			off = offsetof(struct sk_buff, vlan_tci);
 			emit(ARM_LDRH_I(r_A, r_skb, off), ctx);
-			if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
-				OP_IMM3(ARM_AND, r_A, r_A, ~VLAN_TAG_PRESENT, ctx);
-			else {
-				OP_IMM3(ARM_LSR, r_A, r_A, 12, ctx);
+#ifdef VLAN_TAG_PRESENT
+			OP_IMM3(ARM_AND, r_A, r_A, ~VLAN_TAG_PRESENT, ctx);
+#endif
+			break;
+		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+			off = PKT_VLAN_PRESENT_OFFSET();
+			emit(ARM_LDRB_I(r_A, r_skb, off), ctx);
+			if (PKT_VLAN_PRESENT_BIT)
+				OP_IMM3(ARM_LSR, r_A, r_A, PKT_VLAN_PRESENT_BIT, ctx);
+			if (PKT_VLAN_PRESENT_BIT < 7)
 				OP_IMM3(ARM_AND, r_A, r_A, 0x1, ctx);
-			}
 			break;
 		case BPF_ANC | SKF_AD_PKTTYPE:
 			ctx->seen |= SEEN_SKB;
-- 
2.11.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup
@ 2017-01-04  1:18 Michał Mirosław
  2017-01-04  1:18   ` Michał Mirosław
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev

Those patches prepare BPF ant its JITs for removal of VLAN_TAG_PRESENT.
The set depends on "Preparation for VLAN_TAG_PRESENT cleanup" patchset.

The series is supposed to be bisect-friendly and that requires temporary
insertion of #define VLAN_TAG_PRESENT in BPF code to be able to split
JIT changes per architecture.

Michał Mirosław (6):
  net/skbuff: add macros for VLAN_PRESENT bit
  net/bpf_jit: ARM: split VLAN_PRESENT bit handling from VLAN_TCI
  net/bpf_jit: MIPS: split VLAN_PRESENT bit handling from VLAN_TCI
  net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI
  net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
  net/bpf: split VLAN_PRESENT bit handling from VLAN_TCI

 arch/arm/net/bpf_jit_32.c       | 16 ++++++++++------
 arch/mips/net/bpf_jit.c         | 18 ++++++++++--------
 arch/powerpc/net/bpf_jit_comp.c | 17 +++++++++--------
 arch/sparc/net/bpf_jit_comp.c   | 18 ++++++++++--------
 include/linux/skbuff.h          |  6 ++++++
 net/core/filter.c               | 19 +++++++++----------
 6 files changed, 54 insertions(+), 40 deletions(-)

-- 
2.11.0

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

* [PATCH net-next 1/6] net/skbuff: add macros for VLAN_PRESENT bit
@ 2017-01-04  1:18   ` Michał Mirosław
  0 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 include/linux/skbuff.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b53c0cfd417e..168c3e486bd4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -768,6 +768,12 @@ struct sk_buff {
 	__u32			priority;
 	int			skb_iif;
 	__u32			hash;
+#define PKT_VLAN_PRESENT_BIT	4	// CFI (12-th bit) in TCI
+#ifdef __BIG_ENDIAN
+#define PKT_VLAN_PRESENT_OFFSET()	offsetof(struct sk_buff, vlan_tci)
+#else
+#define PKT_VLAN_PRESENT_OFFSET()	(offsetof(struct sk_buff, vlan_tci) + 1)
+#endif
 	__be16			vlan_proto;
 	__u16			vlan_tci;
 #if defined(CONFIG_NET_RX_BUSY_POLL) || defined(CONFIG_XPS)
-- 
2.11.0


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

* [PATCH net-next 2/6] net/bpf_jit: ARM: split VLAN_PRESENT bit handling from VLAN_TCI
@ 2017-01-04  1:18   ` Michał Mirosław
  0 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Micha? Miros?aw <mirq-linux@rere.qmqm.pl>
---
v2: remove one insn for big-endians

 arch/arm/net/bpf_jit_32.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index 93d0b6d0b63e..0700cbbe4f14 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -915,17 +915,21 @@ static int build_body(struct jit_ctx *ctx)
 			emit(ARM_LDR_I(r_A, r_skb, off), ctx);
 			break;
 		case BPF_ANC | SKF_AD_VLAN_TAG:
-		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
 			ctx->seen |= SEEN_SKB;
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2);
 			off = offsetof(struct sk_buff, vlan_tci);
 			emit(ARM_LDRH_I(r_A, r_skb, off), ctx);
-			if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
-				OP_IMM3(ARM_AND, r_A, r_A, ~VLAN_TAG_PRESENT, ctx);
-			else {
-				OP_IMM3(ARM_LSR, r_A, r_A, 12, ctx);
+#ifdef VLAN_TAG_PRESENT
+			OP_IMM3(ARM_AND, r_A, r_A, ~VLAN_TAG_PRESENT, ctx);
+#endif
+			break;
+		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+			off = PKT_VLAN_PRESENT_OFFSET();
+			emit(ARM_LDRB_I(r_A, r_skb, off), ctx);
+			if (PKT_VLAN_PRESENT_BIT)
+				OP_IMM3(ARM_LSR, r_A, r_A, PKT_VLAN_PRESENT_BIT, ctx);
+			if (PKT_VLAN_PRESENT_BIT < 7)
 				OP_IMM3(ARM_AND, r_A, r_A, 0x1, ctx);
-			}
 			break;
 		case BPF_ANC | SKF_AD_PKTTYPE:
 			ctx->seen |= SEEN_SKB;
-- 
2.11.0

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

* [PATCH net-next 1/6] net/skbuff: add macros for VLAN_PRESENT bit
@ 2017-01-04  1:18   ` Michał Mirosław
  0 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Micha? Miros?aw <mirq-linux@rere.qmqm.pl>
---
 include/linux/skbuff.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b53c0cfd417e..168c3e486bd4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -768,6 +768,12 @@ struct sk_buff {
 	__u32			priority;
 	int			skb_iif;
 	__u32			hash;
+#define PKT_VLAN_PRESENT_BIT	4	// CFI (12-th bit) in TCI
+#ifdef __BIG_ENDIAN
+#define PKT_VLAN_PRESENT_OFFSET()	offsetof(struct sk_buff, vlan_tci)
+#else
+#define PKT_VLAN_PRESENT_OFFSET()	(offsetof(struct sk_buff, vlan_tci) + 1)
+#endif
 	__be16			vlan_proto;
 	__u16			vlan_tci;
 #if defined(CONFIG_NET_RX_BUSY_POLL) || defined(CONFIG_XPS)
-- 
2.11.0

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

* [PATCH net-next 4/6] net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI
  2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
@ 2017-01-04  1:18   ` Michał Mirosław
  2017-01-04  1:18   ` Michał Mirosław
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev; +Cc: Paul Mackerras, linuxppc-dev

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 arch/powerpc/net/bpf_jit_comp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 7e706f36e364..22ae63fb9b7d 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -377,18 +377,19 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
 							  hash));
 			break;
 		case BPF_ANC | SKF_AD_VLAN_TAG:
-		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2);
-			BUILD_BUG_ON(VLAN_TAG_PRESENT != 0x1000);
 
 			PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff,
 							  vlan_tci));
-			if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) {
-				PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
-			} else {
-				PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
-				PPC_SRWI(r_A, r_A, 12);
-			}
+#ifdef VLAN_TAG_PRESENT
+			PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
+#endif
+			break;
+		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+			PPC_LBZ_OFFS(r_A, r_skb, PKT_VLAN_PRESENT_OFFSET());
+			if (PKT_VLAN_PRESENT_BIT)
+				PPC_SRWI(r_A, r_A, PKT_VLAN_PRESENT_BIT);
+			PPC_ANDI(r_A, r_A, 1);
 			break;
 		case BPF_ANC | SKF_AD_QUEUE:
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
-- 
2.11.0

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

* [PATCH net-next 3/6] net/bpf_jit: MIPS: split VLAN_PRESENT bit handling from VLAN_TCI
  2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
                   ` (3 preceding siblings ...)
  2017-01-04  1:18 ` [PATCH net-next 6/6] net/bpf: " Michał Mirosław
@ 2017-01-04  1:18 ` Michał Mirosław
  2017-01-04  1:18   ` Michał Mirosław
  2017-01-04 20:11 ` [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Daniel Borkmann
  6 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev; +Cc: Ralf Baechle, linux-mips

Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 arch/mips/net/bpf_jit.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
index 49a2e2226fee..d06722294ede 100644
--- a/arch/mips/net/bpf_jit.c
+++ b/arch/mips/net/bpf_jit.c
@@ -1138,19 +1138,21 @@ static int build_body(struct jit_ctx *ctx)
 			emit_load(r_A, r_skb, off, ctx);
 			break;
 		case BPF_ANC | SKF_AD_VLAN_TAG:
-		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
 			ctx->flags |= SEEN_SKB | SEEN_A;
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
 						  vlan_tci) != 2);
 			off = offsetof(struct sk_buff, vlan_tci);
 			emit_half_load(r_s0, r_skb, off, ctx);
-			if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) {
-				emit_andi(r_A, r_s0, (u16)~VLAN_TAG_PRESENT, ctx);
-			} else {
-				emit_andi(r_A, r_s0, VLAN_TAG_PRESENT, ctx);
-				/* return 1 if present */
-				emit_sltu(r_A, r_zero, r_A, ctx);
-			}
+#ifdef VLAN_TAG_PRESENT
+			emit_andi(r_A, r_s0, (u16)~VLAN_TAG_PRESENT, ctx);
+#endif
+			break;
+		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+			ctx->flags |= SEEN_SKB | SEEN_A;
+			emit_load_byte(r_A, r_skb, PKT_VLAN_PRESENT_OFFSET(), ctx);
+			if (PKT_VLAN_PRESENT_BIT)
+				emit_srl(r_A, r_A, PKT_VLAN_PRESENT_BIT, ctx);
+			emit_andi(r_A, r_s0, 1, ctx);
 			break;
 		case BPF_ANC | SKF_AD_PKTTYPE:
 			ctx->flags |= SEEN_SKB;
-- 
2.11.0

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

* [PATCH net-next 5/6] net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
  2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
@ 2017-01-04  1:18   ` Michał Mirosław
  2017-01-04  1:18   ` Michał Mirosław
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, sparclinux

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 arch/sparc/net/bpf_jit_comp.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index a6d9204a6a0b..61cc15dc86f7 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -601,15 +601,17 @@ void bpf_jit_compile(struct bpf_prog *fp)
 				emit_skb_load32(hash, r_A);
 				break;
 			case BPF_ANC | SKF_AD_VLAN_TAG:
-			case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
 				emit_skb_load16(vlan_tci, r_A);
-				if (code != (BPF_ANC | SKF_AD_VLAN_TAG)) {
-					emit_alu_K(SRL, 12);
-					emit_andi(r_A, 1, r_A);
-				} else {
-					emit_loadimm(~VLAN_TAG_PRESENT, r_TMP);
-					emit_and(r_A, r_TMP, r_A);
-				}
+#ifdef VLAN_TAG_PRESENT
+				emit_loadimm(~VLAN_TAG_PRESENT, r_TMP);
+				emit_and(r_A, r_TMP, r_A);
+#endif
+				break;
+			case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+				__emit_skb_load8(__pkt_vlan_present_offset, r_A);
+				if (PKT_VLAN_PRESENT_BIT)
+					emit_alu_K(SRL, PKT_VLAN_PRESENT_BIT);
+				emit_andi(r_A, 1, r_A);
 				break;
 			case BPF_LD | BPF_W | BPF_LEN:
 				emit_skb_load32(len, r_A);
-- 
2.11.0

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

* [PATCH net-next 6/6] net/bpf: split VLAN_PRESENT bit handling from VLAN_TCI
  2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
                   ` (2 preceding siblings ...)
  2017-01-04  1:18   ` Michał Mirosław
@ 2017-01-04  1:18 ` Michał Mirosław
  2017-01-04  1:18 ` [PATCH net-next 3/6] net/bpf_jit: MIPS: " Michał Mirosław
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Alexei Starovoitov, Daniel Borkmann,
	Thomas Graf, Martin KaFai Lau, Craig Gallek

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
v2: save an insn on big-endiands

 net/core/filter.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 1969b3f118c1..7caf0bbbd092 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -188,22 +188,21 @@ static u32 convert_skb_access(int skb_field, int dst_reg, int src_reg,
 		break;
 
 	case SKF_AD_VLAN_TAG:
-	case SKF_AD_VLAN_TAG_PRESENT:
 		BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2);
-		BUILD_BUG_ON(VLAN_TAG_PRESENT != 0x1000);
 
 		/* dst_reg = *(u16 *) (src_reg + offsetof(vlan_tci)) */
 		*insn++ = BPF_LDX_MEM(BPF_H, dst_reg, src_reg,
 				      offsetof(struct sk_buff, vlan_tci));
-		if (skb_field == SKF_AD_VLAN_TAG) {
-			*insn++ = BPF_ALU32_IMM(BPF_AND, dst_reg,
-						~VLAN_TAG_PRESENT);
-		} else {
-			/* dst_reg >>= 12 */
-			*insn++ = BPF_ALU32_IMM(BPF_RSH, dst_reg, 12);
-			/* dst_reg &= 1 */
+#ifdef VLAN_TAG_PRESENT
+		*insn++ = BPF_ALU32_IMM(BPF_AND, dst_reg, ~VLAN_TAG_PRESENT);
+#endif
+		break;
+	case SKF_AD_VLAN_TAG_PRESENT:
+		*insn++ = BPF_LDX_MEM(BPF_B, dst_reg, src_reg, PKT_VLAN_PRESENT_OFFSET());
+		if (PKT_VLAN_PRESENT_BIT)
+			*insn++ = BPF_ALU32_IMM(BPF_RSH, dst_reg, PKT_VLAN_PRESENT_BIT);
+		if (PKT_VLAN_PRESENT_BIT < 7)
 			*insn++ = BPF_ALU32_IMM(BPF_AND, dst_reg, 1);
-		}
 		break;
 	}
 
-- 
2.11.0

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

* [PATCH net-next 5/6] net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
@ 2017-01-04  1:18   ` Michał Mirosław
  0 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, sparclinux

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 arch/sparc/net/bpf_jit_comp.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index a6d9204a6a0b..61cc15dc86f7 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -601,15 +601,17 @@ void bpf_jit_compile(struct bpf_prog *fp)
 				emit_skb_load32(hash, r_A);
 				break;
 			case BPF_ANC | SKF_AD_VLAN_TAG:
-			case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
 				emit_skb_load16(vlan_tci, r_A);
-				if (code != (BPF_ANC | SKF_AD_VLAN_TAG)) {
-					emit_alu_K(SRL, 12);
-					emit_andi(r_A, 1, r_A);
-				} else {
-					emit_loadimm(~VLAN_TAG_PRESENT, r_TMP);
-					emit_and(r_A, r_TMP, r_A);
-				}
+#ifdef VLAN_TAG_PRESENT
+				emit_loadimm(~VLAN_TAG_PRESENT, r_TMP);
+				emit_and(r_A, r_TMP, r_A);
+#endif
+				break;
+			case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+				__emit_skb_load8(__pkt_vlan_present_offset, r_A);
+				if (PKT_VLAN_PRESENT_BIT)
+					emit_alu_K(SRL, PKT_VLAN_PRESENT_BIT);
+				emit_andi(r_A, 1, r_A);
 				break;
 			case BPF_LD | BPF_W | BPF_LEN:
 				emit_skb_load32(len, r_A);
-- 
2.11.0


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

* [PATCH net-next 4/6] net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI
@ 2017-01-04  1:18   ` Michał Mirosław
  0 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04  1:18 UTC (permalink / raw)
  To: netdev
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, linuxppc-dev

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 arch/powerpc/net/bpf_jit_comp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 7e706f36e364..22ae63fb9b7d 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -377,18 +377,19 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
 							  hash));
 			break;
 		case BPF_ANC | SKF_AD_VLAN_TAG:
-		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2);
-			BUILD_BUG_ON(VLAN_TAG_PRESENT != 0x1000);
 
 			PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff,
 							  vlan_tci));
-			if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) {
-				PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
-			} else {
-				PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
-				PPC_SRWI(r_A, r_A, 12);
-			}
+#ifdef VLAN_TAG_PRESENT
+			PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
+#endif
+			break;
+		case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+			PPC_LBZ_OFFS(r_A, r_skb, PKT_VLAN_PRESENT_OFFSET());
+			if (PKT_VLAN_PRESENT_BIT)
+				PPC_SRWI(r_A, r_A, PKT_VLAN_PRESENT_BIT);
+			PPC_ANDI(r_A, r_A, 1);
 			break;
 		case BPF_ANC | SKF_AD_QUEUE:
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
-- 
2.11.0

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

* Re: [PATCH net-next 5/6] net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
  2017-01-04  1:18   ` Michał Mirosław
@ 2017-01-04 12:59     ` kbuild test robot
  -1 siblings, 0 replies; 16+ messages in thread
From: kbuild test robot @ 2017-01-04 12:59 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: kbuild-all, netdev, David S. Miller, sparclinux

[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]

Hi Michał,

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Micha-Miros-aw/Prepare-BPF-for-VLAN_TAG_PRESENT-cleanup/20170104-190258
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/compiler.h:58:0,
                    from include/uapi/linux/stddef.h:1,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from include/linux/module.h:9,
                    from include/linux/moduleloader.h:5,
                    from arch/sparc/net/bpf_jit_comp.c:1:
   arch/sparc/net/bpf_jit_comp.c: In function 'bpf_jit_compile':
>> include/linux/compiler-gcc.h:159:2: error: 'struct sk_buff' has no member named '__pkt_vlan_present_offset'; did you mean '__pkt_type_offset'?
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
>> arch/sparc/net/bpf_jit_comp.c:228:26: note: in expansion of macro 'offsetof'
    do { unsigned int _off = offsetof(STRUCT, FIELD);   \
                             ^~~~~~~~
>> arch/sparc/net/bpf_jit_comp.c:270:2: note: in expansion of macro '__emit_load8'
     __emit_load8(r_SKB, struct sk_buff, FIELD, DEST)
     ^~~~~~~~~~~~
>> arch/sparc/net/bpf_jit_comp.c:611:5: note: in expansion of macro '__emit_skb_load8'
        __emit_skb_load8(__pkt_vlan_present_offset, r_A);
        ^~~~~~~~~~~~~~~~

vim +159 include/linux/compiler-gcc.h

cb984d10 Joe Perches    2015-06-25  153  #  error Your version of gcc miscompiles the __weak directive
cb984d10 Joe Perches    2015-06-25  154  # endif
cb984d10 Joe Perches    2015-06-25  155  #endif
cb984d10 Joe Perches    2015-06-25  156  
cb984d10 Joe Perches    2015-06-25  157  #define __used			__attribute__((__used__))
cb984d10 Joe Perches    2015-06-25  158  #define __compiler_offsetof(a, b)					\
cb984d10 Joe Perches    2015-06-25 @159  	__builtin_offsetof(a, b)
cb984d10 Joe Perches    2015-06-25  160  
0d025d27 Josh Poimboeuf 2016-08-30  161  #if GCC_VERSION >= 40100
cb984d10 Joe Perches    2015-06-25  162  # define __compiletime_object_size(obj) __builtin_object_size(obj, 0)

:::::: The code at line 159 was first introduced by commit
:::::: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the various compiler-gcc[345].h files

:::::: TO: Joe Perches <joe@perches.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 48625 bytes --]

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

* Re: [PATCH net-next 5/6] net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
@ 2017-01-04 12:59     ` kbuild test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kbuild test robot @ 2017-01-04 12:59 UTC (permalink / raw)
  To: sparclinux

[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]

Hi Michał,

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Micha-Miros-aw/Prepare-BPF-for-VLAN_TAG_PRESENT-cleanup/20170104-190258
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/compiler.h:58:0,
                    from include/uapi/linux/stddef.h:1,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from include/linux/module.h:9,
                    from include/linux/moduleloader.h:5,
                    from arch/sparc/net/bpf_jit_comp.c:1:
   arch/sparc/net/bpf_jit_comp.c: In function 'bpf_jit_compile':
>> include/linux/compiler-gcc.h:159:2: error: 'struct sk_buff' has no member named '__pkt_vlan_present_offset'; did you mean '__pkt_type_offset'?
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
>> arch/sparc/net/bpf_jit_comp.c:228:26: note: in expansion of macro 'offsetof'
    do { unsigned int _off = offsetof(STRUCT, FIELD);   \
                             ^~~~~~~~
>> arch/sparc/net/bpf_jit_comp.c:270:2: note: in expansion of macro '__emit_load8'
     __emit_load8(r_SKB, struct sk_buff, FIELD, DEST)
     ^~~~~~~~~~~~
>> arch/sparc/net/bpf_jit_comp.c:611:5: note: in expansion of macro '__emit_skb_load8'
        __emit_skb_load8(__pkt_vlan_present_offset, r_A);
        ^~~~~~~~~~~~~~~~

vim +159 include/linux/compiler-gcc.h

cb984d10 Joe Perches    2015-06-25  153  #  error Your version of gcc miscompiles the __weak directive
cb984d10 Joe Perches    2015-06-25  154  # endif
cb984d10 Joe Perches    2015-06-25  155  #endif
cb984d10 Joe Perches    2015-06-25  156  
cb984d10 Joe Perches    2015-06-25  157  #define __used			__attribute__((__used__))
cb984d10 Joe Perches    2015-06-25  158  #define __compiler_offsetof(a, b)					\
cb984d10 Joe Perches    2015-06-25 @159  	__builtin_offsetof(a, b)
cb984d10 Joe Perches    2015-06-25  160  
0d025d27 Josh Poimboeuf 2016-08-30  161  #if GCC_VERSION >= 40100
cb984d10 Joe Perches    2015-06-25  162  # define __compiletime_object_size(obj) __builtin_object_size(obj, 0)

:::::: The code at line 159 was first introduced by commit
:::::: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the various compiler-gcc[345].h files

:::::: TO: Joe Perches <joe@perches.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 48625 bytes --]

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

* Re: [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup
  2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
                   ` (5 preceding siblings ...)
  2017-01-04  1:18   ` Michał Mirosław
@ 2017-01-04 20:11 ` Daniel Borkmann
  2017-01-04 21:30   ` Michał Mirosław
  6 siblings, 1 reply; 16+ messages in thread
From: Daniel Borkmann @ 2017-01-04 20:11 UTC (permalink / raw)
  To: Michał Mirosław, netdev; +Cc: alexei.starovoitov

On 01/04/2017 02:18 AM, Michał Mirosław wrote:
> Those patches prepare BPF ant its JITs for removal of VLAN_TAG_PRESENT.
> The set depends on "Preparation for VLAN_TAG_PRESENT cleanup" patchset.
>
> The series is supposed to be bisect-friendly and that requires temporary
> insertion of #define VLAN_TAG_PRESENT in BPF code to be able to split
> JIT changes per architecture.
>
> Michał Mirosław (6):
>    net/skbuff: add macros for VLAN_PRESENT bit
>    net/bpf_jit: ARM: split VLAN_PRESENT bit handling from VLAN_TCI
>    net/bpf_jit: MIPS: split VLAN_PRESENT bit handling from VLAN_TCI
>    net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI
>    net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
>    net/bpf: split VLAN_PRESENT bit handling from VLAN_TCI

Please add a proper changelog to all the individual patches, right now
they have none. Also, how was this runtime tested? Did you run BPF selftest
suite with them? Seems like they weren't even compile tested properly
given the kbuild bot barking on sparc ...

>   arch/arm/net/bpf_jit_32.c       | 16 ++++++++++------
>   arch/mips/net/bpf_jit.c         | 18 ++++++++++--------
>   arch/powerpc/net/bpf_jit_comp.c | 17 +++++++++--------
>   arch/sparc/net/bpf_jit_comp.c   | 18 ++++++++++--------
>   include/linux/skbuff.h          |  6 ++++++
>   net/core/filter.c               | 19 +++++++++----------
>   6 files changed, 54 insertions(+), 40 deletions(-)
>

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

* Re: [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup
  2017-01-04 20:11 ` [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Daniel Borkmann
@ 2017-01-04 21:30   ` Michał Mirosław
  0 siblings, 0 replies; 16+ messages in thread
From: Michał Mirosław @ 2017-01-04 21:30 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: netdev, alexei.starovoitov

On Wed, Jan 04, 2017 at 09:11:57PM +0100, Daniel Borkmann wrote:
> On 01/04/2017 02:18 AM, Michał Mirosław wrote:
> > Those patches prepare BPF ant its JITs for removal of VLAN_TAG_PRESENT.
> > The set depends on "Preparation for VLAN_TAG_PRESENT cleanup" patchset.
> > 
> > The series is supposed to be bisect-friendly and that requires temporary
> > insertion of #define VLAN_TAG_PRESENT in BPF code to be able to split
> > JIT changes per architecture.
> > 
> > Michał Mirosław (6):
> >    net/skbuff: add macros for VLAN_PRESENT bit
> >    net/bpf_jit: ARM: split VLAN_PRESENT bit handling from VLAN_TCI
> >    net/bpf_jit: MIPS: split VLAN_PRESENT bit handling from VLAN_TCI
> >    net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI
> >    net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
> >    net/bpf: split VLAN_PRESENT bit handling from VLAN_TCI
> 
> Please add a proper changelog to all the individual patches, right now
> they have none. Also, how was this runtime tested? Did you run BPF selftest
> suite with them? Seems like they weren't even compile tested properly
> given the kbuild bot barking on sparc ...

Compile bot is barking because it doesn't have patches, which this set depends on.
Sorry about that.

Best Regards,
Michał Mirosław

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

end of thread, other threads:[~2017-01-04 21:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-04  1:18 [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Michał Mirosław
2017-01-04  1:18 ` [PATCH net-next 2/6] net/bpf_jit: ARM: split VLAN_PRESENT bit handling from VLAN_TCI Michał Mirosław
2017-01-04  1:18   ` Michał Mirosław
2017-01-04  1:18 ` [PATCH net-next 1/6] net/skbuff: add macros for VLAN_PRESENT bit Michał Mirosław
2017-01-04  1:18   ` Michał Mirosław
2017-01-04  1:18   ` Michał Mirosław
2017-01-04  1:18 ` [PATCH net-next 4/6] net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI Michał Mirosław
2017-01-04  1:18   ` Michał Mirosław
2017-01-04  1:18 ` [PATCH net-next 6/6] net/bpf: " Michał Mirosław
2017-01-04  1:18 ` [PATCH net-next 3/6] net/bpf_jit: MIPS: " Michał Mirosław
2017-01-04  1:18 ` [PATCH net-next 5/6] net/bpf_jit: SPARC: " Michał Mirosław
2017-01-04  1:18   ` Michał Mirosław
2017-01-04 12:59   ` kbuild test robot
2017-01-04 12:59     ` kbuild test robot
2017-01-04 20:11 ` [PATCH net-next 0/6] Prepare BPF for VLAN_TAG_PRESENT cleanup Daniel Borkmann
2017-01-04 21:30   ` Michał Mirosław

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.