Skip to content

Commit 2bbc078

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Daniel Borkmann says: ==================== pull-request: bpf-next 2019-12-27 The following pull-request contains BPF updates for your *net-next* tree. We've added 127 non-merge commits during the last 17 day(s) which contain a total of 110 files changed, 6901 insertions(+), 2721 deletions(-). There are three merge conflicts. Conflicts and resolution looks as follows: 1) Merge conflict in net/bpf/test_run.c: There was a tree-wide cleanup c593642 ("treewide: Use sizeof_field() macro") which gets in the way with b590cb5 ("bpf: Switch to offsetofend in BPF_PROG_TEST_RUN"): <<<<<<< HEAD if (!range_is_zero(__skb, offsetof(struct __sk_buff, priority) + sizeof_field(struct __sk_buff, priority), ======= if (!range_is_zero(__skb, offsetofend(struct __sk_buff, priority), >>>>>>> 7c8dce4 There are a few occasions that look similar to this. Always take the chunk with offsetofend(). Note that there is one where the fields differ in here: <<<<<<< HEAD if (!range_is_zero(__skb, offsetof(struct __sk_buff, tstamp) + sizeof_field(struct __sk_buff, tstamp), ======= if (!range_is_zero(__skb, offsetofend(struct __sk_buff, gso_segs), >>>>>>> 7c8dce4 Just take the one with offsetofend() /and/ gso_segs. Latter is correct due to 850a88c ("bpf: Expose __sk_buff wire_len/gso_segs to BPF_PROG_TEST_RUN"). 2) Merge conflict in arch/riscv/net/bpf_jit_comp.c: (I'm keeping Bjorn in Cc here for a double-check in case I got it wrong.) <<<<<<< HEAD if (is_13b_check(off, insn)) return -1; emit(rv_blt(tcc, RV_REG_ZERO, off >> 1), ctx); ======= emit_branch(BPF_JSLT, RV_REG_T1, RV_REG_ZERO, off, ctx); >>>>>>> 7c8dce4 Result should look like: emit_branch(BPF_JSLT, tcc, RV_REG_ZERO, off, ctx); 3) Merge conflict in arch/riscv/include/asm/pgtable.h: <<<<<<< HEAD ======= #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) #define VMALLOC_END (PAGE_OFFSET - 1) #define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) #define BPF_JIT_REGION_SIZE (SZ_128M) #define BPF_JIT_REGION_START (PAGE_OFFSET - BPF_JIT_REGION_SIZE) #define BPF_JIT_REGION_END (VMALLOC_END) /* * Roughly size the vmemmap space to be large enough to fit enough * struct pages to map half the virtual address space. Then * position vmemmap directly below the VMALLOC region. */ #define VMEMMAP_SHIFT \ (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) #define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT) #define VMEMMAP_END (VMALLOC_START - 1) #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) #define vmemmap ((struct page *)VMEMMAP_START) >>>>>>> 7c8dce4 Only take the BPF_* defines from there and move them higher up in the same file. Remove the rest from the chunk. The VMALLOC_* etc defines got moved via 01f52e1 ("riscv: define vmemmap before pfn_to_page calls"). Result: [...] #define __S101 PAGE_READ_EXEC #define __S110 PAGE_SHARED_EXEC #define __S111 PAGE_SHARED_EXEC #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) #define VMALLOC_END (PAGE_OFFSET - 1) #define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) #define BPF_JIT_REGION_SIZE (SZ_128M) #define BPF_JIT_REGION_START (PAGE_OFFSET - BPF_JIT_REGION_SIZE) #define BPF_JIT_REGION_END (VMALLOC_END) /* * Roughly size the vmemmap space to be large enough to fit enough * struct pages to map half the virtual address space. Then * position vmemmap directly below the VMALLOC region. */ #define VMEMMAP_SHIFT \ (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) #define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT) #define VMEMMAP_END (VMALLOC_START - 1) #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) [...] Let me know if there are any other issues. Anyway, the main changes are: 1) Extend bpftool to produce a struct (aka "skeleton") tailored and specific to a provided BPF object file. This provides an alternative, simplified API compared to standard libbpf interaction. Also, add libbpf extern variable resolution for .kconfig section to import Kconfig data, from Andrii Nakryiko. 2) Add BPF dispatcher for XDP which is a mechanism to avoid indirect calls by generating a branch funnel as discussed back in bpfconf'19 at LSF/MM. Also, add various BPF riscv JIT improvements, from Björn Töpel. 3) Extend bpftool to allow matching BPF programs and maps by name, from Paul Chaignon. 4) Support for replacing cgroup BPF programs attached with BPF_F_ALLOW_MULTI flag for allowing updates without service interruption, from Andrey Ignatov. 5) Cleanup and simplification of ring access functions for AF_XDP with a bonus of 0-5% performance improvement, from Magnus Karlsson. 6) Enable BPF JITs for x86-64 and arm64 by default. Also, final version of audit support for BPF, from Daniel Borkmann and latter with Jiri Olsa. 7) Move and extend test_select_reuseport into BPF program tests under BPF selftests, from Jakub Sitnicki. 8) Various BPF sample improvements for xdpsock for customizing parameters to set up and benchmark AF_XDP, from Jay Jayatheerthan. 9) Improve libbpf to provide a ulimit hint on permission denied errors. Also change XDP sample programs to attach in driver mode by default, from Toke Høiland-Jørgensen. 10) Extend BPF test infrastructure to allow changing skb mark from tc BPF programs, from Nikita V. Shirokov. 11) Optimize prologue code sequence in BPF arm32 JIT, from Russell King. 12) Fix xdp_redirect_cpu BPF sample to manually attach to tracepoints after libbpf conversion, from Jesper Dangaard Brouer. 13) Minor misc improvements from various others. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9e41fbf + 7c8dce4 commit 2bbc078

File tree

110 files changed

+6901
-2721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+6901
-2721
lines changed

arch/arm/net/bpf_jit_32.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,12 +1260,9 @@ static inline void emit_push_r64(const s8 src[], struct jit_ctx *ctx)
12601260

12611261
static void build_prologue(struct jit_ctx *ctx)
12621262
{
1263-
const s8 r0 = bpf2a32[BPF_REG_0][1];
1264-
const s8 r2 = bpf2a32[BPF_REG_1][1];
1265-
const s8 r3 = bpf2a32[BPF_REG_1][0];
1266-
const s8 r4 = bpf2a32[BPF_REG_6][1];
1267-
const s8 fplo = bpf2a32[BPF_REG_FP][1];
1268-
const s8 fphi = bpf2a32[BPF_REG_FP][0];
1263+
const s8 arm_r0 = bpf2a32[BPF_REG_0][1];
1264+
const s8 *bpf_r1 = bpf2a32[BPF_REG_1];
1265+
const s8 *bpf_fp = bpf2a32[BPF_REG_FP];
12691266
const s8 *tcc = bpf2a32[TCALL_CNT];
12701267

12711268
/* Save callee saved registers. */
@@ -1278,27 +1275,26 @@ static void build_prologue(struct jit_ctx *ctx)
12781275
emit(ARM_PUSH(CALLEE_PUSH_MASK), ctx);
12791276
emit(ARM_MOV_R(ARM_FP, ARM_SP), ctx);
12801277
#endif
1281-
/* Save frame pointer for later */
1282-
emit(ARM_SUB_I(ARM_IP, ARM_SP, SCRATCH_SIZE), ctx);
1278+
/* mov r3, #0 */
1279+
/* sub r2, sp, #SCRATCH_SIZE */
1280+
emit(ARM_MOV_I(bpf_r1[0], 0), ctx);
1281+
emit(ARM_SUB_I(bpf_r1[1], ARM_SP, SCRATCH_SIZE), ctx);
12831282

12841283
ctx->stack_size = imm8m(STACK_SIZE);
12851284

12861285
/* Set up function call stack */
12871286
emit(ARM_SUB_I(ARM_SP, ARM_SP, ctx->stack_size), ctx);
12881287

12891288
/* Set up BPF prog stack base register */
1290-
emit_a32_mov_r(fplo, ARM_IP, ctx);
1291-
emit_a32_mov_i(fphi, 0, ctx);
1289+
emit_a32_mov_r64(true, bpf_fp, bpf_r1, ctx);
12921290

1293-
/* mov r4, 0 */
1294-
emit(ARM_MOV_I(r4, 0), ctx);
1291+
/* Initialize Tail Count */
1292+
emit(ARM_MOV_I(bpf_r1[1], 0), ctx);
1293+
emit_a32_mov_r64(true, tcc, bpf_r1, ctx);
12951294

12961295
/* Move BPF_CTX to BPF_R1 */
1297-
emit(ARM_MOV_R(r3, r4), ctx);
1298-
emit(ARM_MOV_R(r2, r0), ctx);
1299-
/* Initialize Tail Count */
1300-
emit(ARM_STR_I(r4, ARM_FP, EBPF_SCRATCH_TO_ARM_FP(tcc[0])), ctx);
1301-
emit(ARM_STR_I(r4, ARM_FP, EBPF_SCRATCH_TO_ARM_FP(tcc[1])), ctx);
1296+
emit(ARM_MOV_R(bpf_r1[1], arm_r0), ctx);
1297+
13021298
/* end of prologue */
13031299
}
13041300

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ config ARM64
6969
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && (GCC_VERSION >= 50000 || CC_IS_CLANG)
7070
select ARCH_SUPPORTS_NUMA_BALANCING
7171
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT
72+
select ARCH_WANT_DEFAULT_BPF_JIT
7273
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
7374
select ARCH_WANT_FRAME_POINTERS
7475
select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)

arch/riscv/include/asm/perf_event.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ struct riscv_pmu {
8282
int irq;
8383
};
8484

85+
#ifdef CONFIG_PERF_EVENTS
86+
#define perf_arch_bpf_user_pt_regs(regs) (struct user_regs_struct *)regs
87+
#endif
88+
8589
#endif /* _ASM_RISCV_PERF_EVENT_H */

arch/riscv/include/asm/pgtable.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ extern pgd_t swapper_pg_dir[];
9494
#define VMALLOC_END (PAGE_OFFSET - 1)
9595
#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
9696

97+
#define BPF_JIT_REGION_SIZE (SZ_128M)
98+
#define BPF_JIT_REGION_START (PAGE_OFFSET - BPF_JIT_REGION_SIZE)
99+
#define BPF_JIT_REGION_END (VMALLOC_END)
100+
97101
/*
98102
* Roughly size the vmemmap space to be large enough to fit enough
99103
* struct pages to map half the virtual address space. Then
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
3+
#define _UAPI__ASM_BPF_PERF_EVENT_H__
4+
5+
#include <asm/ptrace.h>
6+
7+
typedef struct user_regs_struct bpf_user_pt_regs_t;
8+
9+
#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */

0 commit comments

Comments
 (0)