Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
bpf_jit_comp.c File Reference
#include <linux/moduleloader.h>
#include <asm/cacheflush.h>
#include <linux/netdevice.h>
#include <linux/filter.h>

Go to the source code of this file.

Macros

#define EMIT(bytes, len)   do { prog = emit_code(prog, bytes, len); } while (0)
 
#define EMIT1(b1)   EMIT(b1, 1)
 
#define EMIT2(b1, b2)   EMIT((b1) + ((b2) << 8), 2)
 
#define EMIT3(b1, b2, b3)   EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
 
#define EMIT4(b1, b2, b3, b4)   EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
 
#define EMIT1_off32(b1, off)   do { EMIT1(b1); EMIT(off, 4);} while (0)
 
#define CLEAR_A()   EMIT2(0x31, 0xc0) /* xor %eax,%eax */
 
#define CLEAR_X()   EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
 
#define EMIT_JMP(offset)
 
#define X86_JB   0x72
 
#define X86_JAE   0x73
 
#define X86_JE   0x74
 
#define X86_JNE   0x75
 
#define X86_JBE   0x76
 
#define X86_JA   0x77
 
#define EMIT_COND_JMP(op, offset)
 
#define COND_SEL(CODE, TOP, FOP)
 
#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 CHOOSE_LOAD_FUNC(K, func)   ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
 

Functions

void bpf_jit_compile (struct sk_filter *fp)
 
void bpf_jit_free (struct sk_filter *fp)
 

Variables

int bpf_jit_enable __read_mostly
 
u8 sk_load_word []
 
u8 sk_load_half []
 
u8 sk_load_byte []
 
u8 sk_load_byte_msh []
 
u8 sk_load_word_positive_offset []
 
u8 sk_load_half_positive_offset []
 
u8 sk_load_byte_positive_offset []
 
u8 sk_load_byte_msh_positive_offset []
 
u8 sk_load_word_negative_offset []
 
u8 sk_load_half_negative_offset []
 
u8 sk_load_byte_negative_offset []
 
u8 sk_load_byte_msh_negative_offset []
 

Macro Definition Documentation

#define CHOOSE_LOAD_FUNC (   K,
  func 
)    ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)

Definition at line 123 of file bpf_jit_comp.c.

#define CLEAR_A ( )    EMIT2(0x31, 0xc0) /* xor %eax,%eax */

Definition at line 59 of file bpf_jit_comp.c.

#define CLEAR_X ( )    EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */

Definition at line 60 of file bpf_jit_comp.c.

#define COND_SEL (   CODE,
  TOP,
  FOP 
)
Value:
case CODE: \
t_op = TOP; \
f_op = FOP; \
goto cond_branch

Definition at line 102 of file bpf_jit_comp.c.

#define EMIT (   bytes,
  len 
)    do { prog = emit_code(prog, bytes, len); } while (0)

Definition at line 51 of file bpf_jit_comp.c.

#define EMIT1 (   b1)    EMIT(b1, 1)

Definition at line 53 of file bpf_jit_comp.c.

#define EMIT1_off32 (   b1,
  off 
)    do { EMIT1(b1); EMIT(off, 4);} while (0)

Definition at line 57 of file bpf_jit_comp.c.

#define EMIT2 (   b1,
  b2 
)    EMIT((b1) + ((b2) << 8), 2)

Definition at line 54 of file bpf_jit_comp.c.

#define EMIT3 (   b1,
  b2,
  b3 
)    EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)

Definition at line 55 of file bpf_jit_comp.c.

#define EMIT4 (   b1,
  b2,
  b3,
  b4 
)    EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)

Definition at line 56 of file bpf_jit_comp.c.

#define EMIT_COND_JMP (   op,
  offset 
)
Value:
do { \
if (is_near(offset)) \
EMIT2(op, offset); /* jxx .+off8 */ \
else { \
EMIT2(0x0f, op + 0x10); \
EMIT(offset, 4); /* jxx .+off32 */ \
} \
} while (0)

Definition at line 92 of file bpf_jit_comp.c.

#define EMIT_JMP (   offset)
Value:
do { \
if (offset) { \
if (is_near(offset)) \
EMIT2(0xeb, offset); /* jmp .+off8 */ \
EMIT1_off32(0xe9, offset); /* jmp .+off32 */ \
} \
} while (0)

Definition at line 72 of file bpf_jit_comp.c.

#define SEEN_DATAREF   1 /* might call external helpers */

Definition at line 109 of file bpf_jit_comp.c.

#define SEEN_MEM   4 /* use mem[] for temporary storage */

Definition at line 111 of file bpf_jit_comp.c.

#define SEEN_XREG   2 /* ebx is used */

Definition at line 110 of file bpf_jit_comp.c.

#define X86_JA   0x77

Definition at line 90 of file bpf_jit_comp.c.

#define X86_JAE   0x73

Definition at line 86 of file bpf_jit_comp.c.

#define X86_JB   0x72

Definition at line 85 of file bpf_jit_comp.c.

#define X86_JBE   0x76

Definition at line 89 of file bpf_jit_comp.c.

#define X86_JE   0x74

Definition at line 87 of file bpf_jit_comp.c.

#define X86_JNE   0x75

Definition at line 88 of file bpf_jit_comp.c.

Function Documentation

void bpf_jit_compile ( struct sk_filter fp)

Definition at line 126 of file bpf_jit_comp.c.

void bpf_jit_free ( struct sk_filter fp)

Definition at line 695 of file bpf_jit_comp.c.

Variable Documentation

int bpf_jit_enable __read_mostly

Definition at line 27 of file bpf_jit_comp.c.

u8 sk_load_byte[]
u8 sk_load_byte_msh[]
u8 sk_load_byte_msh_negative_offset[]
u8 sk_load_byte_msh_positive_offset[]
u8 sk_load_byte_negative_offset[]
u8 sk_load_byte_positive_offset[]
u8 sk_load_half[]
u8 sk_load_half_negative_offset[]
u8 sk_load_half_positive_offset[]
u8 sk_load_word[]
u8 sk_load_word_negative_offset[]
u8 sk_load_word_positive_offset[]