Prepare BPF for VLAN_TAG_PRESENT cleanup
Subsystems (12)
PATCH 1/6 net/skbuff: add macros for VLAN_PRESENT bit
In reply to Michał Mirosław--- include/linux/skbuff.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/linux/skbuff.h +6 -0
@@ -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 )
Signature · 1 line
2.11.0
PATCH 2/6 net/bpf_jit: ARM: split VLAN_PRESENT bit handling from VLAN_TCI
In reply to Michał Mirosław---
v2: remove one insn for big-endians
arch/arm/net/bpf_jit_32.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
arch/arm/net/bpf_jit_32.c +10 -6
@@ -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 ;
Signature · 1 line
2.11.0
PATCH 3/6 net/bpf_jit: MIPS: split VLAN_PRESENT bit handling from VLAN_TCI
In reply to Michał Mirosław--- arch/mips/net/bpf_jit.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
arch/mips/net/bpf_jit.c +10 -8
@@ -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 ;
Signature · 1 line
2.11.0
PATCH 4/6 net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI
In reply to Michał Mirosław--- arch/powerpc/net/bpf_jit_comp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
arch/powerpc/net/bpf_jit_comp.c +9 -8
@@ -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,
Signature · 1 line
2.11.0
PATCH 5/6 net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
In reply to Michał Mirosław--- arch/sparc/net/bpf_jit_comp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
arch/sparc/net/bpf_jit_comp.c +10 -8
@@ -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);
Signature · 1 line
2.11.0
PATCH 6/6 net/bpf: split VLAN_PRESENT bit handling from VLAN_TCI
In reply to Michał Mirosław---
v2: save an insn on big-endiands
net/core/filter.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
net/core/filter.c +9 -10
@@ -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 ; }
Signature · 1 line
2.11.0
cover Prepare BPF for VLAN_TAG_PRESENT cleanup
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(-)
Signature · 1 line
2.11.0
kbuild test robot
build botRe: [PATCH net-next 5/6] net/bpf_jit: SPARC: split VLAN_PRESENT bit handling from VLAN_TCI
In reply to Michał Mirosławurl: 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…
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 <[email protected]>
:::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Daniel Borkmann
maintainerQuoted 7 lines · Michał Mirosław
Those patches prepare BPF ant its JITs for removal of
VLAN_TAG_PRESENT. The set depends on "Preparation forVLAN_TAG_PRESENTcleanup" patchset.The series is supposed to be bisect-friendly and that requires temporary insertion of #define
VLAN_TAG_PRESENTin BPF code to be able to split JIT changes per architecture.
Quoted 7 lines
Michał Mirosław (6):
net/skbuff: add macros forVLAN_PRESENTbitnet/bpf_jit: ARM: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf_jit: MIPS: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf_jit: PPC: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf_jit: SPARC: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf: splitVLAN_PRESENTbit handling fromVLAN_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 ...
Quoted 8 lines
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(-)
Quoted 16 lines · Daniel Borkmann
Quoted 7 lines · Michał Mirosław
Those patches prepare BPF ant its JITs for removal of
VLAN_TAG_PRESENT. The set depends on "Preparation forVLAN_TAG_PRESENTcleanup" patchset.The series is supposed to be bisect-friendly and that requires temporary insertion of #define
VLAN_TAG_PRESENTin BPF code to be able to split JIT changes per architecture.Quoted 7 lines
Michał Mirosław (6):
net/skbuff: add macros forVLAN_PRESENTbitnet/bpf_jit: ARM: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf_jit: MIPS: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf_jit: PPC: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf_jit: SPARC: splitVLAN_PRESENTbit handling fromVLAN_TCInet/bpf: splitVLAN_PRESENTbit handling fromVLAN_TCI
Quoted 4 lines
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