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

Go to the source code of this file.

Data Structures

struct  bpf_jit
 

Macros

#define BPF_SIZE_MAX   4096 /* Max size for program */
 
#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 SEEN_RET0   8 /* pc_ret0 points to a valid return 0 */
 
#define SEEN_LITERAL   16 /* code uses literals */
 
#define SEEN_LOAD_WORD   32 /* code uses sk_load_word */
 
#define SEEN_LOAD_HALF   64 /* code uses sk_load_half */
 
#define SEEN_LOAD_BYTE   128 /* code uses sk_load_byte */
 
#define SEEN_LOAD_BMSH   256 /* code uses sk_load_byte_msh */
 
#define SEEN_LOAD_IWORD   512 /* code uses sk_load_word_ind */
 
#define SEEN_LOAD_IHALF   1024 /* code uses sk_load_half_ind */
 
#define SEEN_LOAD_IBYTE   2048 /* code uses sk_load_byte_ind */
 
#define EMIT2(op)
 
#define EMIT4(op)
 
#define EMIT4_DISP(op, disp)
 
#define EMIT4_IMM(op, imm)
 
#define EMIT4_PCREL(op, pcrel)
 
#define EMIT6(op1, op2)
 
#define EMIT6_DISP(op1, op2, disp)
 
#define EMIT6_IMM(op, imm)
 
#define EMIT_CONST(val)
 
#define EMIT_FN_CONST(bit, fn)
 

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_ind []
 
u8 sk_load_half_ind []
 
u8 sk_load_byte_ind []
 

Macro Definition Documentation

#define BPF_SIZE_MAX   4096 /* Max size for program */

Definition at line 56 of file bpf_jit_comp.c.

#define EMIT2 (   op)
Value:
({ \
if (jit->prg + 2 <= jit->mid) \
*(u16 *) jit->prg = op; \
jit->prg += 2; \
})

Definition at line 71 of file bpf_jit_comp.c.

#define EMIT4 (   op)
Value:
({ \
if (jit->prg + 4 <= jit->mid) \
*(u32 *) jit->prg = op; \
jit->prg += 4; \
})

Definition at line 78 of file bpf_jit_comp.c.

#define EMIT4_DISP (   op,
  disp 
)
Value:
({ \
unsigned int __disp = (disp) & 0xfff; \
EMIT4(op | __disp); \
})

Definition at line 85 of file bpf_jit_comp.c.

#define EMIT4_IMM (   op,
  imm 
)
Value:
({ \
unsigned int __imm = (imm) & 0xffff; \
EMIT4(op | __imm); \
})

Definition at line 91 of file bpf_jit_comp.c.

#define EMIT4_PCREL (   op,
  pcrel 
)
Value:
({ \
long __pcrel = ((pcrel) >> 1) & 0xffff; \
EMIT4(op | __pcrel); \
})

Definition at line 97 of file bpf_jit_comp.c.

#define EMIT6 (   op1,
  op2 
)
Value:
({ \
if (jit->prg + 6 <= jit->mid) { \
*(u32 *) jit->prg = op1; \
*(u16 *) (jit->prg + 4) = op2; \
} \
jit->prg += 6; \
})

Definition at line 103 of file bpf_jit_comp.c.

#define EMIT6_DISP (   op1,
  op2,
  disp 
)
Value:
({ \
unsigned int __disp = (disp) & 0xfff; \
EMIT6(op1 | __disp, op2); \
})

Definition at line 112 of file bpf_jit_comp.c.

#define EMIT6_IMM (   op,
  imm 
)
Value:
({ \
unsigned int __imm = (imm); \
EMIT6(op | (__imm >> 16), __imm & 0xffff); \
})

Definition at line 118 of file bpf_jit_comp.c.

#define EMIT_CONST (   val)
Value:
({ \
unsigned int ret; \
ret = (unsigned int) (jit->lit - jit->base_ip); \
jit->seen |= SEEN_LITERAL; \
if (jit->lit + 4 <= jit->end) \
*(u32 *) jit->lit = val; \
jit->lit += 4; \
ret; \
})

Definition at line 124 of file bpf_jit_comp.c.

#define EMIT_FN_CONST (   bit,
  fn 
)
Value:
({ \
unsigned int ret; \
ret = (unsigned int) (jit->lit - jit->base_ip); \
if (jit->seen & bit) { \
jit->seen |= SEEN_LITERAL; \
if (jit->lit + 8 <= jit->end) \
*(void **) jit->lit = fn; \
jit->lit += 8; \
} \
ret; \
})

Definition at line 135 of file bpf_jit_comp.c.

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

Definition at line 58 of file bpf_jit_comp.c.

#define SEEN_LITERAL   16 /* code uses literals */

Definition at line 62 of file bpf_jit_comp.c.

#define SEEN_LOAD_BMSH   256 /* code uses sk_load_byte_msh */

Definition at line 66 of file bpf_jit_comp.c.

#define SEEN_LOAD_BYTE   128 /* code uses sk_load_byte */

Definition at line 65 of file bpf_jit_comp.c.

#define SEEN_LOAD_HALF   64 /* code uses sk_load_half */

Definition at line 64 of file bpf_jit_comp.c.

#define SEEN_LOAD_IBYTE   2048 /* code uses sk_load_byte_ind */

Definition at line 69 of file bpf_jit_comp.c.

#define SEEN_LOAD_IHALF   1024 /* code uses sk_load_half_ind */

Definition at line 68 of file bpf_jit_comp.c.

#define SEEN_LOAD_IWORD   512 /* code uses sk_load_word_ind */

Definition at line 67 of file bpf_jit_comp.c.

#define SEEN_LOAD_WORD   32 /* code uses sk_load_word */

Definition at line 63 of file bpf_jit_comp.c.

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

Definition at line 60 of file bpf_jit_comp.c.

#define SEEN_RET0   8 /* pc_ret0 points to a valid return 0 */

Definition at line 61 of file bpf_jit_comp.c.

#define SEEN_XREG   2 /* ebx is used */

Definition at line 59 of file bpf_jit_comp.c.

Function Documentation

void bpf_jit_compile ( struct sk_filter fp)

Definition at line 692 of file bpf_jit_comp.c.

void bpf_jit_free ( struct sk_filter fp)

Definition at line 767 of file bpf_jit_comp.c.

Variable Documentation

int bpf_jit_enable __read_mostly

Definition at line 29 of file bpf_jit_comp.c.

u8 sk_load_byte[]
u8 sk_load_byte_ind[]
u8 sk_load_byte_msh[]
u8 sk_load_half[]
u8 sk_load_half_ind[]
u8 sk_load_word[]
u8 sk_load_word_ind[]