Skip to content

Commit ea9722e

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Alexei Starovoitov says: ==================== pull-request: bpf-next 2018-01-19 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) bpf array map HW offload, from Jakub. 2) support for bpf_get_next_key() for LPM map, from Yonghong. 3) test_verifier now runs loaded programs, from Alexei. 4) xdp cpumap monitoring, from Jesper. 5) variety of tests, cleanups and small x64 JIT optimization, from Daniel. 6) user space can now retrieve HW JITed program, from Jiong. Note there is a minor conflict between Russell's arm32 JIT fixes and removal of bpf_jit_enable variable by Daniel which should be resolved by keeping Russell's comment and removing that variable. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 8565d26 + 1391040 commit ea9722e

44 files changed

Lines changed: 1828 additions & 222 deletions

Some content is hidden

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

‎arch/arm/net/bpf_jit_32.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
#include "bpf_jit_32.h"
2727

28-
int bpf_jit_enable __read_mostly;
29-
3028
/*
3129
* eBPF prog stack layout:
3230
*

‎arch/arm64/net/bpf_jit_comp.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
#include "bpf_jit.h"
3333

34-
int bpf_jit_enable __read_mostly;
35-
3634
#define TMP_REG_1 (MAX_BPF_JIT_REG + 0)
3735
#define TMP_REG_2 (MAX_BPF_JIT_REG + 1)
3836
#define TCALL_CNT (MAX_BPF_JIT_REG + 2)

‎arch/mips/net/bpf_jit.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,6 @@ static int build_body(struct jit_ctx *ctx)
12071207
return 0;
12081208
}
12091209

1210-
int bpf_jit_enable __read_mostly;
1211-
12121210
void bpf_jit_compile(struct bpf_prog *fp)
12131211
{
12141212
struct jit_ctx ctx;

‎arch/mips/net/ebpf_jit.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ static u32 b_imm(unsigned int tgt, struct jit_ctx *ctx)
177177
(ctx->idx * 4) - 4;
178178
}
179179

180-
int bpf_jit_enable __read_mostly;
181-
182180
enum which_ebpf_reg {
183181
src_reg,
184182
src_reg_no_fp,

‎arch/powerpc/net/bpf_jit_comp.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
#include "bpf_jit32.h"
2020

21-
int bpf_jit_enable __read_mostly;
22-
2321
static inline void bpf_flush_icache(void *start, void *end)
2422
{
2523
smp_wmb();

‎arch/powerpc/net/bpf_jit_comp64.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
#include "bpf_jit64.h"
2323

24-
int bpf_jit_enable __read_mostly;
25-
2624
static void bpf_jit_fill_ill_insns(void *area, unsigned int size)
2725
{
2826
memset32(area, BREAKPOINT_INSTRUCTION, size/4);

‎arch/s390/net/bpf_jit_comp.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include <asm/set_memory.h>
2929
#include "bpf_jit.h"
3030

31-
int bpf_jit_enable __read_mostly;
32-
3331
struct bpf_jit {
3432
u32 seen; /* Flags to remember seen eBPF instructions */
3533
u32 seen_reg[16]; /* Array to remember which registers are used */

‎arch/sparc/net/bpf_jit_comp_32.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
#include "bpf_jit_32.h"
1313

14-
int bpf_jit_enable __read_mostly;
15-
1614
static inline bool is_simm13(unsigned int value)
1715
{
1816
return value + 0x1000 < 0x2000;

‎arch/sparc/net/bpf_jit_comp_64.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
#include "bpf_jit_64.h"
1414

15-
int bpf_jit_enable __read_mostly;
16-
1715
static inline bool is_simm13(unsigned int value)
1816
{
1917
return value + 0x1000 < 0x2000;

‎arch/x86/net/bpf_jit_comp.c‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <asm/set_memory.h>
1616
#include <linux/bpf.h>
1717

18-
int bpf_jit_enable __read_mostly;
19-
2018
/*
2119
* assembly code in arch/x86/net/bpf_jit.S
2220
*/
@@ -154,6 +152,11 @@ static bool is_ereg(u32 reg)
154152
BIT(BPF_REG_AX));
155153
}
156154

155+
static bool is_axreg(u32 reg)
156+
{
157+
return reg == BPF_REG_0;
158+
}
159+
157160
/* add modifiers if 'reg' maps to x64 registers r8..r15 */
158161
static u8 add_1mod(u8 byte, u32 reg)
159162
{
@@ -447,16 +450,36 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
447450
else if (is_ereg(dst_reg))
448451
EMIT1(add_1mod(0x40, dst_reg));
449452

453+
/* b3 holds 'normal' opcode, b2 short form only valid
454+
* in case dst is eax/rax.
455+
*/
450456
switch (BPF_OP(insn->code)) {
451-
case BPF_ADD: b3 = 0xC0; break;
452-
case BPF_SUB: b3 = 0xE8; break;
453-
case BPF_AND: b3 = 0xE0; break;
454-
case BPF_OR: b3 = 0xC8; break;
455-
case BPF_XOR: b3 = 0xF0; break;
457+
case BPF_ADD:
458+
b3 = 0xC0;
459+
b2 = 0x05;
460+
break;
461+
case BPF_SUB:
462+
b3 = 0xE8;
463+
b2 = 0x2D;
464+
break;
465+
case BPF_AND:
466+
b3 = 0xE0;
467+
b2 = 0x25;
468+
break;
469+
case BPF_OR:
470+
b3 = 0xC8;
471+
b2 = 0x0D;
472+
break;
473+
case BPF_XOR:
474+
b3 = 0xF0;
475+
b2 = 0x35;
476+
break;
456477
}
457478

458479
if (is_imm8(imm32))
459480
EMIT3(0x83, add_1reg(b3, dst_reg), imm32);
481+
else if (is_axreg(dst_reg))
482+
EMIT1_off32(b2, imm32);
460483
else
461484
EMIT2_off32(0x81, add_1reg(b3, dst_reg), imm32);
462485
break;

0 commit comments

Comments
 (0)