|
Linux Kernel
3.7.1
|
#include <linux/moduleloader.h>#include <linux/workqueue.h>#include <linux/netdevice.h>#include <linux/filter.h>#include <linux/cache.h>#include <asm/cacheflush.h>#include <asm/ptrace.h>#include "bpf_jit.h"Go to the source code of this file.
Macros | |
| #define | SEEN_DATAREF 1 /* might call external helpers */ |
| #define | SEEN_XREG 2 /* ebx is used */ |
| #define | SEEN_MEM 4 /* use mem[] for temporary storage */ |
| #define | S13(X) ((X) & 0x1fff) |
| #define | IMMED 0x00002000 |
| #define | RD(X) ((X) << 25) |
| #define | RS1(X) ((X) << 14) |
| #define | RS2(X) ((X)) |
| #define | OP(X) ((X) << 30) |
| #define | OP2(X) ((X) << 22) |
| #define | OP3(X) ((X) << 19) |
| #define | COND(X) ((X) << 25) |
| #define | F1(X) OP(X) |
| #define | F2(X, Y) (OP(X) | OP2(Y)) |
| #define | F3(X, Y) (OP(X) | OP3(Y)) |
| #define | CONDN COND(0x0) |
| #define | CONDE COND(0x1) |
| #define | CONDLE COND(0x2) |
| #define | CONDL COND(0x3) |
| #define | CONDLEU COND(0x4) |
| #define | CONDCS COND(0x5) |
| #define | CONDNEG COND(0x6) |
| #define | CONDVC COND(0x7) |
| #define | CONDA COND(0x8) |
| #define | CONDNE COND(0x9) |
| #define | CONDG COND(0xa) |
| #define | CONDGE COND(0xb) |
| #define | CONDGU COND(0xc) |
| #define | CONDCC COND(0xd) |
| #define | CONDPOS COND(0xe) |
| #define | CONDVS COND(0xf) |
| #define | CONDGEU CONDCC |
| #define | CONDLU CONDCS |
| #define | WDISP22(X) (((X) >> 2) & 0x3fffff) |
| #define | BA (F2(0, 2) | CONDA) |
| #define | BGU (F2(0, 2) | CONDGU) |
| #define | BLEU (F2(0, 2) | CONDLEU) |
| #define | BGEU (F2(0, 2) | CONDGEU) |
| #define | BLU (F2(0, 2) | CONDLU) |
| #define | BE (F2(0, 2) | CONDE) |
| #define | BNE (F2(0, 2) | CONDNE) |
| #define | BNE_PTR BNE |
| #define | SETHI(K, REG) (F2(0, 0x4) | RD(REG) | (((K) >> 10) & 0x3fffff)) |
| #define | OR_LO(K, REG) (F3(2, 0x02) | IMMED | RS1(REG) | ((K) & 0x3ff) | RD(REG)) |
| #define | ADD F3(2, 0x00) |
| #define | AND F3(2, 0x01) |
| #define | ANDCC F3(2, 0x11) |
| #define | OR F3(2, 0x02) |
| #define | XOR F3(2, 0x03) |
| #define | SUB F3(2, 0x04) |
| #define | SUBCC F3(2, 0x14) |
| #define | MUL F3(2, 0x0a) /* umul */ |
| #define | DIV F3(2, 0x0e) /* udiv */ |
| #define | SLL F3(2, 0x25) |
| #define | SRL F3(2, 0x26) |
| #define | JMPL F3(2, 0x38) |
| #define | CALL F1(1) |
| #define | BR F2(0, 0x01) |
| #define | RD_Y F3(2, 0x28) |
| #define | WR_Y F3(2, 0x30) |
| #define | LD32 F3(3, 0x00) |
| #define | LD8 F3(3, 0x01) |
| #define | LD16 F3(3, 0x02) |
| #define | LD64 F3(3, 0x0b) |
| #define | ST32 F3(3, 0x04) |
| #define | LDPTR LD32 |
| #define | BASE_STACKFRAME 96 |
| #define | LD32I (LD32 | IMMED) |
| #define | LD8I (LD8 | IMMED) |
| #define | LD16I (LD16 | IMMED) |
| #define | LD64I (LD64 | IMMED) |
| #define | LDPTRI (LDPTR | IMMED) |
| #define | ST32I (ST32 | IMMED) |
| #define | emit_nop() |
| #define | emit_neg() |
| #define | emit_reg_move(FROM, TO) |
| #define | emit_clear(REG) |
| #define | emit_set_const(K, REG) |
| #define | emit_alu_X(OPCODE) |
| #define | emit_alu_K(OPCODE, K) |
| #define | emit_loadimm(K, DEST) |
| #define | emit_loadptr(BASE, STRUCT, FIELD, DEST) |
| #define | emit_load32(BASE, STRUCT, FIELD, DEST) |
| #define | emit_load16(BASE, STRUCT, FIELD, DEST) |
| #define | __emit_load8(BASE, STRUCT, FIELD, DEST) |
| #define | emit_load8(BASE, STRUCT, FIELD, DEST) |
| #define | emit_ldmem(OFF, DEST) |
| #define | emit_stmem(OFF, SRC) |
| #define | emit_load_cpu(REG) emit_clear(REG) |
| #define | emit_skb_loadptr(FIELD, DEST) emit_loadptr(r_SKB, struct sk_buff, FIELD, DEST) |
| #define | emit_skb_load32(FIELD, DEST) emit_load32(r_SKB, struct sk_buff, FIELD, DEST) |
| #define | emit_skb_load16(FIELD, DEST) emit_load16(r_SKB, struct sk_buff, FIELD, DEST) |
| #define | __emit_skb_load8(FIELD, DEST) __emit_load8(r_SKB, struct sk_buff, FIELD, DEST) |
| #define | emit_skb_load8(FIELD, DEST) emit_load8(r_SKB, struct sk_buff, FIELD, DEST) |
| #define | emit_jmpl(BASE, IMM_OFF, LREG) *prog++ = (JMPL | IMMED | RS1(BASE) | S13(IMM_OFF) | RD(LREG)) |
| #define | emit_call(FUNC) |
| #define | emit_branch(BR_OPC, DEST) |
| #define | emit_branch_off(BR_OPC, OFF) |
| #define | emit_jump(DEST) emit_branch(BA, DEST) |
| #define | emit_read_y(REG) *prog++ = RD_Y | RD(REG) |
| #define | emit_write_y(REG) *prog++ = WR_Y | IMMED | RS1(REG) | S13(0) |
| #define | emit_cmp(R1, R2) *prog++ = (SUBCC | RS1(R1) | RS2(R2) | RD(G0)) |
| #define | emit_cmpi(R1, IMM) *prog++ = (SUBCC | IMMED | RS1(R1) | S13(IMM) | RD(G0)); |
| #define | emit_btst(R1, R2) *prog++ = (ANDCC | RS1(R1) | RS2(R2) | RD(G0)) |
| #define | emit_btsti(R1, IMM) *prog++ = (ANDCC | IMMED | RS1(R1) | S13(IMM) | RD(G0)); |
| #define | emit_sub(R1, R2, R3) *prog++ = (SUB | RS1(R1) | RS2(R2) | RD(R3)) |
| #define | emit_subi(R1, IMM, R3) *prog++ = (SUB | IMMED | RS1(R1) | S13(IMM) | RD(R3)) |
| #define | emit_add(R1, R2, R3) *prog++ = (ADD | RS1(R1) | RS2(R2) | RD(R3)) |
| #define | emit_addi(R1, IMM, R3) *prog++ = (ADD | IMMED | RS1(R1) | S13(IMM) | RD(R3)) |
| #define | emit_alloc_stack(SZ) *prog++ = (SUB | IMMED | RS1(SP) | S13(SZ) | RD(SP)) |
| #define | emit_release_stack(SZ) *prog++ = (ADD | IMMED | RS1(SP) | S13(SZ) | RD(SP)) |
| #define | CHOOSE_LOAD_FUNC(K, func) ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset) |
| #define | COND_SEL(CODE, TOP, FOP) |
Functions | |
| void | bpf_jit_compile (struct sk_filter *fp) |
| void | bpf_jit_free (struct sk_filter *fp) |
Variables | |
| int bpf_jit_enable | __read_mostly |
Definition at line 262 of file bpf_jit_comp.c.
| #define ADD F3(2, 0x00) |
Definition at line 95 of file bpf_jit_comp.c.
| #define AND F3(2, 0x01) |
Definition at line 96 of file bpf_jit_comp.c.
| #define ANDCC F3(2, 0x11) |
Definition at line 97 of file bpf_jit_comp.c.
Definition at line 76 of file bpf_jit_comp.c.
| #define BASE_STACKFRAME 96 |
Definition at line 123 of file bpf_jit_comp.c.
Definition at line 81 of file bpf_jit_comp.c.
Definition at line 79 of file bpf_jit_comp.c.
Definition at line 77 of file bpf_jit_comp.c.
Definition at line 78 of file bpf_jit_comp.c.
Definition at line 80 of file bpf_jit_comp.c.
Definition at line 82 of file bpf_jit_comp.c.
| #define BNE_PTR BNE |
Definition at line 87 of file bpf_jit_comp.c.
| #define BR F2(0, 0x01) |
Definition at line 108 of file bpf_jit_comp.c.
| #define CALL F1(1) |
Definition at line 107 of file bpf_jit_comp.c.
| #define CHOOSE_LOAD_FUNC | ( | K, | |
| func | |||
| ) | ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset) |
Definition at line 49 of file bpf_jit_comp.c.
| #define COND_SEL | ( | CODE, | |
| TOP, | |||
| FOP | |||
| ) |
| #define CONDA COND(0x8) |
Definition at line 62 of file bpf_jit_comp.c.
| #define CONDCC COND(0xd) |
Definition at line 67 of file bpf_jit_comp.c.
| #define CONDCS COND(0x5) |
Definition at line 59 of file bpf_jit_comp.c.
| #define CONDE COND(0x1) |
Definition at line 55 of file bpf_jit_comp.c.
| #define CONDG COND(0xa) |
Definition at line 64 of file bpf_jit_comp.c.
| #define CONDGE COND(0xb) |
Definition at line 65 of file bpf_jit_comp.c.
| #define CONDGEU CONDCC |
Definition at line 71 of file bpf_jit_comp.c.
| #define CONDGU COND(0xc) |
Definition at line 66 of file bpf_jit_comp.c.
| #define CONDL COND(0x3) |
Definition at line 57 of file bpf_jit_comp.c.
| #define CONDLE COND(0x2) |
Definition at line 56 of file bpf_jit_comp.c.
| #define CONDLEU COND(0x4) |
Definition at line 58 of file bpf_jit_comp.c.
| #define CONDLU CONDCS |
Definition at line 72 of file bpf_jit_comp.c.
| #define CONDN COND(0x0) |
Definition at line 54 of file bpf_jit_comp.c.
| #define CONDNE COND(0x9) |
Definition at line 63 of file bpf_jit_comp.c.
| #define CONDNEG COND(0x6) |
Definition at line 60 of file bpf_jit_comp.c.
| #define CONDPOS COND(0xe) |
Definition at line 68 of file bpf_jit_comp.c.
| #define CONDVC COND(0x7) |
Definition at line 61 of file bpf_jit_comp.c.
| #define CONDVS COND(0xf) |
Definition at line 69 of file bpf_jit_comp.c.
| #define DIV F3(2, 0x0e) /* udiv */ |
Definition at line 103 of file bpf_jit_comp.c.
Definition at line 309 of file bpf_jit_comp.c.
Definition at line 312 of file bpf_jit_comp.c.
Definition at line 315 of file bpf_jit_comp.c.
| #define emit_alu_X | ( | OPCODE | ) |
| #define emit_branch | ( | BR_OPC, | |
| DEST | |||
| ) |
| #define emit_branch_off | ( | BR_OPC, | |
| OFF | |||
| ) |
Definition at line 282 of file bpf_jit_comp.c.
Definition at line 297 of file bpf_jit_comp.c.
Definition at line 300 of file bpf_jit_comp.c.
| #define emit_call | ( | FUNC | ) |
| #define emit_clear | ( | REG | ) |
Definition at line 291 of file bpf_jit_comp.c.
Definition at line 294 of file bpf_jit_comp.c.
| #define emit_jmpl | ( | BASE, | |
| IMM_OFF, | |||
| LREG | |||
| ) | *prog++ = (JMPL | IMMED | RS1(BASE) | S13(IMM_OFF) | RD(LREG)) |
Definition at line 267 of file bpf_jit_comp.c.
| #define emit_jump | ( | DEST | ) | emit_branch(BA, DEST) |
Definition at line 286 of file bpf_jit_comp.c.
Definition at line 231 of file bpf_jit_comp.c.
| #define emit_load_cpu | ( | REG | ) | emit_clear(REG) |
Definition at line 253 of file bpf_jit_comp.c.
| #define emit_neg | ( | ) |
| #define emit_nop | ( | ) |
Definition at line 133 of file bpf_jit_comp.c.
| #define emit_reg_move | ( | FROM, | |
| TO | |||
| ) |
Definition at line 318 of file bpf_jit_comp.c.
Definition at line 260 of file bpf_jit_comp.c.
Definition at line 258 of file bpf_jit_comp.c.
Definition at line 264 of file bpf_jit_comp.c.
Definition at line 256 of file bpf_jit_comp.c.
Definition at line 303 of file bpf_jit_comp.c.
Definition at line 306 of file bpf_jit_comp.c.
Definition at line 289 of file bpf_jit_comp.c.
Definition at line 50 of file bpf_jit_comp.c.
| #define IMMED 0x00002000 |
Definition at line 42 of file bpf_jit_comp.c.
| #define JMPL F3(2, 0x38) |
Definition at line 106 of file bpf_jit_comp.c.
| #define LD16 F3(3, 0x02) |
Definition at line 114 of file bpf_jit_comp.c.
Definition at line 128 of file bpf_jit_comp.c.
| #define LD32 F3(3, 0x00) |
Definition at line 112 of file bpf_jit_comp.c.
Definition at line 126 of file bpf_jit_comp.c.
| #define LD64 F3(3, 0x0b) |
Definition at line 115 of file bpf_jit_comp.c.
Definition at line 129 of file bpf_jit_comp.c.
| #define LD8 F3(3, 0x01) |
Definition at line 113 of file bpf_jit_comp.c.
Definition at line 127 of file bpf_jit_comp.c.
| #define LDPTR LD32 |
Definition at line 122 of file bpf_jit_comp.c.
Definition at line 130 of file bpf_jit_comp.c.
| #define MUL F3(2, 0x0a) /* umul */ |
Definition at line 102 of file bpf_jit_comp.c.
Definition at line 46 of file bpf_jit_comp.c.
Definition at line 47 of file bpf_jit_comp.c.
Definition at line 48 of file bpf_jit_comp.c.
| #define OR F3(2, 0x02) |
Definition at line 98 of file bpf_jit_comp.c.
Definition at line 92 of file bpf_jit_comp.c.
Definition at line 43 of file bpf_jit_comp.c.
| #define RD_Y F3(2, 0x28) |
Definition at line 109 of file bpf_jit_comp.c.
Definition at line 44 of file bpf_jit_comp.c.
Definition at line 45 of file bpf_jit_comp.c.
Definition at line 41 of file bpf_jit_comp.c.
| #define SEEN_DATAREF 1 /* might call external helpers */ |
Definition at line 37 of file bpf_jit_comp.c.
Definition at line 39 of file bpf_jit_comp.c.
Definition at line 38 of file bpf_jit_comp.c.
Definition at line 90 of file bpf_jit_comp.c.
| #define SLL F3(2, 0x25) |
Definition at line 104 of file bpf_jit_comp.c.
| #define SRL F3(2, 0x26) |
Definition at line 105 of file bpf_jit_comp.c.
| #define ST32 F3(3, 0x04) |
Definition at line 116 of file bpf_jit_comp.c.
Definition at line 131 of file bpf_jit_comp.c.
| #define SUB F3(2, 0x04) |
Definition at line 100 of file bpf_jit_comp.c.
| #define SUBCC F3(2, 0x14) |
Definition at line 101 of file bpf_jit_comp.c.
Definition at line 74 of file bpf_jit_comp.c.
| #define WR_Y F3(2, 0x30) |
Definition at line 110 of file bpf_jit_comp.c.
| #define XOR F3(2, 0x03) |
Definition at line 99 of file bpf_jit_comp.c.
Definition at line 350 of file bpf_jit_comp.c.
Definition at line 802 of file bpf_jit_comp.c.
| int bpf_jit_enable __read_mostly |
Definition at line 12 of file bpf_jit_comp.c.
1.8.2