Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
bpf_jit.h File Reference

Go to the source code of this file.

Data Structures

struct  codegen_context
 

Macros

#define BPF_PPC_STACK_LOCALS   32
 
#define BPF_PPC_STACK_BASIC   (48+64)
 
#define BPF_PPC_STACK_SAVE   (18*8)
 
#define BPF_PPC_STACKFRAME
 
#define BPF_PPC_SLOWPATH_FRAME   (48+64)
 
#define r_skb   3
 
#define r_ret   3
 
#define r_A   4
 
#define r_X   5
 
#define r_addr   6
 
#define r_scratch1   7
 
#define r_D   14
 
#define r_HL   15
 
#define r_M   16
 
#define DECLARE_LOAD_FUNC(func)   extern u8 func[], func##_negative_offset[], func##_positive_offset[]
 
#define FUNCTION_DESCR_SIZE   24
 
#define IMM_H(i)   ((uintptr_t)(i)>>16)
 
#define IMM_HA(i)
 
#define IMM_L(i)   ((uintptr_t)(i) & 0xffff)
 
#define PLANT_INSTR(d, idx, instr)   do { if (d) { (d)[idx] = instr; } idx++; } while (0)
 
#define EMIT(instr)   PLANT_INSTR(image, ctx->idx, instr)
 
#define PPC_NOP()   EMIT(PPC_INST_NOP)
 
#define PPC_BLR()   EMIT(PPC_INST_BLR)
 
#define PPC_BLRL()   EMIT(PPC_INST_BLRL)
 
#define PPC_MTLR(r)   EMIT(PPC_INST_MTLR | ___PPC_RT(r))
 
#define PPC_ADDI(d, a, i)
 
#define PPC_MR(d, a)   PPC_OR(d, a, a)
 
#define PPC_LI(r, i)   PPC_ADDI(r, 0, i)
 
#define PPC_ADDIS(d, a, i)
 
#define PPC_LIS(r, i)   PPC_ADDIS(r, 0, i)
 
#define PPC_STD(r, base, i)
 
#define PPC_LD(r, base, i)
 
#define PPC_LWZ(r, base, i)
 
#define PPC_LHZ(r, base, i)
 
#define PPC_LD_OFFS(r, base, i)
 
#define PPC_LWZ_OFFS(r, base, i)
 
#define PPC_LHZ_OFFS(r, base, i)
 
#define PPC_CMPWI(a, i)   EMIT(PPC_INST_CMPWI | ___PPC_RA(a) | IMM_L(i))
 
#define PPC_CMPDI(a, i)   EMIT(PPC_INST_CMPDI | ___PPC_RA(a) | IMM_L(i))
 
#define PPC_CMPLWI(a, i)   EMIT(PPC_INST_CMPLWI | ___PPC_RA(a) | IMM_L(i))
 
#define PPC_CMPLW(a, b)   EMIT(PPC_INST_CMPLW | ___PPC_RA(a) | ___PPC_RB(b))
 
#define PPC_SUB(d, a, b)
 
#define PPC_ADD(d, a, b)
 
#define PPC_MUL(d, a, b)
 
#define PPC_MULHWU(d, a, b)
 
#define PPC_MULI(d, a, i)
 
#define PPC_DIVWU(d, a, b)
 
#define PPC_AND(d, a, b)
 
#define PPC_ANDI(d, a, i)
 
#define PPC_AND_DOT(d, a, b)
 
#define PPC_OR(d, a, b)
 
#define PPC_ORI(d, a, i)
 
#define PPC_ORIS(d, a, i)
 
#define PPC_SLW(d, a, s)
 
#define PPC_SRW(d, a, s)
 
#define PPC_SLWI(d, a, i)
 
#define PPC_SRWI(d, a, i)
 
#define PPC_SLDI(d, a, i)
 
#define PPC_NEG(d, a)   EMIT(PPC_INST_NEG | ___PPC_RT(d) | ___PPC_RA(a))
 
#define PPC_JMP(dest)
 
#define PPC_BCC_SHORT(cond, dest)
 
#define PPC_LI32(d, i)
 
#define PPC_LI64(d, i)
 
#define PPC_BCC(cond, dest)
 
#define CR0_LT   0
 
#define CR0_GT   1
 
#define CR0_EQ   2
 
#define COND_CMP_TRUE   0x100
 
#define COND_CMP_FALSE   0x000
 
#define COND_GT   (CR0_GT | COND_CMP_TRUE)
 
#define COND_GE   (CR0_LT | COND_CMP_FALSE)
 
#define COND_EQ   (CR0_EQ | COND_CMP_TRUE)
 
#define COND_NE   (CR0_EQ | COND_CMP_FALSE)
 
#define COND_LT   (CR0_LT | COND_CMP_TRUE)
 
#define SEEN_DATAREF   0x10000 /* might call external helpers */
 
#define SEEN_XREG   0x20000 /* X reg is used */
 
#define SEEN_MEM
 
#define SEEN_MEM_MSK   0x0ffff
 

Functions

 DECLARE_LOAD_FUNC (sk_load_word)
 
 DECLARE_LOAD_FUNC (sk_load_half)
 
 DECLARE_LOAD_FUNC (sk_load_byte)
 
 DECLARE_LOAD_FUNC (sk_load_byte_msh)
 

Macro Definition Documentation

#define BPF_PPC_SLOWPATH_FRAME   (48+64)

Definition at line 18 of file bpf_jit.h.

#define BPF_PPC_STACK_BASIC   (48+64)

Definition at line 14 of file bpf_jit.h.

#define BPF_PPC_STACK_LOCALS   32

Definition at line 13 of file bpf_jit.h.

#define BPF_PPC_STACK_SAVE   (18*8)

Definition at line 15 of file bpf_jit.h.

#define BPF_PPC_STACKFRAME
Value:
BPF_PPC_STACK_SAVE)

Definition at line 16 of file bpf_jit.h.

#define COND_CMP_FALSE   0x000

Definition at line 211 of file bpf_jit.h.

#define COND_CMP_TRUE   0x100

Definition at line 210 of file bpf_jit.h.

#define COND_EQ   (CR0_EQ | COND_CMP_TRUE)

Definition at line 215 of file bpf_jit.h.

#define COND_GE   (CR0_LT | COND_CMP_FALSE)

Definition at line 214 of file bpf_jit.h.

#define COND_GT   (CR0_GT | COND_CMP_TRUE)

Definition at line 213 of file bpf_jit.h.

#define COND_LT   (CR0_LT | COND_CMP_TRUE)

Definition at line 217 of file bpf_jit.h.

#define COND_NE   (CR0_EQ | COND_CMP_FALSE)

Definition at line 216 of file bpf_jit.h.

#define CR0_EQ   2

Definition at line 208 of file bpf_jit.h.

#define CR0_GT   1

Definition at line 207 of file bpf_jit.h.

#define CR0_LT   0

Definition at line 206 of file bpf_jit.h.

#define DECLARE_LOAD_FUNC (   func)    extern u8 func[], func##_negative_offset[], func##_positive_offset[]

Definition at line 51 of file bpf_jit.h.

#define EMIT (   instr)    PLANT_INSTR(image, ctx->idx, instr)

Definition at line 73 of file bpf_jit.h.

#define FUNCTION_DESCR_SIZE   24

Definition at line 59 of file bpf_jit.h.

#define IMM_H (   i)    ((uintptr_t)(i)>>16)

Definition at line 66 of file bpf_jit.h.

#define IMM_HA (   i)
Value:
(((uintptr_t)(i)>>16) + \
(((uintptr_t)(i) & 0x8000) >> 15))

Definition at line 67 of file bpf_jit.h.

#define IMM_L (   i)    ((uintptr_t)(i) & 0xffff)

Definition at line 69 of file bpf_jit.h.

#define PLANT_INSTR (   d,
  idx,
  instr 
)    do { if (d) { (d)[idx] = instr; } idx++; } while (0)

Definition at line 71 of file bpf_jit.h.

#define PPC_ADD (   d,
  a,
  b 
)
Value:

Definition at line 115 of file bpf_jit.h.

#define PPC_ADDI (   d,
  a,
  i 
)
Value:

Definition at line 79 of file bpf_jit.h.

#define PPC_ADDIS (   d,
  a,
  i 
)
Value:

Definition at line 83 of file bpf_jit.h.

#define PPC_AND (   d,
  a,
  b 
)
Value:

Definition at line 125 of file bpf_jit.h.

#define PPC_AND_DOT (   d,
  a,
  b 
)
Value:

Definition at line 129 of file bpf_jit.h.

#define PPC_ANDI (   d,
  a,
  i 
)
Value:

Definition at line 127 of file bpf_jit.h.

#define PPC_BCC (   cond,
  dest 
)
Value:
do { \
if (is_nearbranch((dest) - (ctx->idx * 4))) { \
PPC_BCC_SHORT(cond, dest); \
PPC_NOP(); \
} else { \
/* Flip the 'T or F' bit to invert comparison */ \
PPC_BCC_SHORT(cond ^ COND_CMP_TRUE, (ctx->idx+2)*4); \
PPC_JMP(dest); \
} } while(0)

Definition at line 195 of file bpf_jit.h.

#define PPC_BCC_SHORT (   cond,
  dest 
)
Value:
(((cond) & 0x3ff) << 16) | \
(((dest) - (ctx->idx * 4)) & \
0xfffc))

Definition at line 159 of file bpf_jit.h.

#define PPC_BLR ( )    EMIT(PPC_INST_BLR)

Definition at line 76 of file bpf_jit.h.

#define PPC_BLRL ( )    EMIT(PPC_INST_BLRL)

Definition at line 77 of file bpf_jit.h.

#define PPC_CMPDI (   a,
  i 
)    EMIT(PPC_INST_CMPDI | ___PPC_RA(a) | IMM_L(i))

Definition at line 109 of file bpf_jit.h.

#define PPC_CMPLW (   a,
  b 
)    EMIT(PPC_INST_CMPLW | ___PPC_RA(a) | ___PPC_RB(b))

Definition at line 111 of file bpf_jit.h.

#define PPC_CMPLWI (   a,
  i 
)    EMIT(PPC_INST_CMPLWI | ___PPC_RA(a) | IMM_L(i))

Definition at line 110 of file bpf_jit.h.

#define PPC_CMPWI (   a,
  i 
)    EMIT(PPC_INST_CMPWI | ___PPC_RA(a) | IMM_L(i))

Definition at line 108 of file bpf_jit.h.

#define PPC_DIVWU (   d,
  a,
  b 
)
Value:

Definition at line 123 of file bpf_jit.h.

#define PPC_JMP (   dest)
Value:
(((dest) - (ctx->idx * 4)) & 0x03fffffc))

Definition at line 156 of file bpf_jit.h.

#define PPC_LD (   r,
  base,
  i 
)
Value:

Definition at line 89 of file bpf_jit.h.

#define PPC_LD_OFFS (   r,
  base,
  i 
)
Value:
do { if ((i) < 32768) PPC_LD(r, base, i); \
else { PPC_ADDIS(r, base, IMM_HA(i)); \
PPC_LD(r, r, IMM_L(i)); } } while(0)

Definition at line 96 of file bpf_jit.h.

#define PPC_LHZ (   r,
  base,
  i 
)
Value:

Definition at line 93 of file bpf_jit.h.

#define PPC_LHZ_OFFS (   r,
  base,
  i 
)
Value:
do { if ((i) < 32768) PPC_LHZ(r, base, i); \
else { PPC_ADDIS(r, base, IMM_HA(i)); \
PPC_LHZ(r, r, IMM_L(i)); } } while(0)

Definition at line 104 of file bpf_jit.h.

#define PPC_LI (   r,
  i 
)    PPC_ADDI(r, 0, i)

Definition at line 82 of file bpf_jit.h.

#define PPC_LI32 (   d,
  i 
)
Value:
do { PPC_LI(d, IMM_L(i)); \
if ((u32)(uintptr_t)(i) >= 32768) { \
PPC_ADDIS(d, d, IMM_HA(i)); \
} } while(0)

Definition at line 163 of file bpf_jit.h.

#define PPC_LI64 (   d,
  i 
)
Value:
do { \
if (!((uintptr_t)(i) & 0xffffffff00000000ULL)) \
PPC_LI32(d, i); \
else { \
PPC_LIS(d, ((uintptr_t)(i) >> 48)); \
if ((uintptr_t)(i) & 0x0000ffff00000000ULL) \
PPC_ORI(d, d, \
((uintptr_t)(i) >> 32) & 0xffff); \
PPC_SLDI(d, d, 32); \
if ((uintptr_t)(i) & 0x00000000ffff0000ULL) \
PPC_ORIS(d, d, \
((uintptr_t)(i) >> 16) & 0xffff); \
if ((uintptr_t)(i) & 0x000000000000ffffULL) \
PPC_ORI(d, d, (uintptr_t)(i) & 0xffff); \
} } while (0);

Definition at line 167 of file bpf_jit.h.

#define PPC_LIS (   r,
  i 
)    PPC_ADDIS(r, 0, i)

Definition at line 85 of file bpf_jit.h.

#define PPC_LWZ (   r,
  base,
  i 
)
Value:

Definition at line 91 of file bpf_jit.h.

#define PPC_LWZ_OFFS (   r,
  base,
  i 
)
Value:
do { if ((i) < 32768) PPC_LWZ(r, base, i); \
else { PPC_ADDIS(r, base, IMM_HA(i)); \
PPC_LWZ(r, r, IMM_L(i)); } } while(0)

Definition at line 100 of file bpf_jit.h.

#define PPC_MR (   d,
  a 
)    PPC_OR(d, a, a)

Definition at line 81 of file bpf_jit.h.

#define PPC_MTLR (   r)    EMIT(PPC_INST_MTLR | ___PPC_RT(r))

Definition at line 78 of file bpf_jit.h.

#define PPC_MUL (   d,
  a,
  b 
)
Value:

Definition at line 117 of file bpf_jit.h.

#define PPC_MULHWU (   d,
  a,
  b 
)
Value:

Definition at line 119 of file bpf_jit.h.

#define PPC_MULI (   d,
  a,
  i 
)
Value:

Definition at line 121 of file bpf_jit.h.

#define PPC_NEG (   d,
  a 
)    EMIT(PPC_INST_NEG | ___PPC_RT(d) | ___PPC_RA(a))

Definition at line 153 of file bpf_jit.h.

#define PPC_NOP ( )    EMIT(PPC_INST_NOP)

Definition at line 75 of file bpf_jit.h.

#define PPC_OR (   d,
  a,
  b 
)
Value:

Definition at line 131 of file bpf_jit.h.

#define PPC_ORI (   d,
  a,
  i 
)
Value:

Definition at line 133 of file bpf_jit.h.

#define PPC_ORIS (   d,
  a,
  i 
)
Value:

Definition at line 135 of file bpf_jit.h.

#define PPC_SLDI (   d,
  a,
  i 
)
Value:
__PPC_MB(63-(i)) | (((i) & 0x20) >> 4))

Definition at line 150 of file bpf_jit.h.

#define PPC_SLW (   d,
  a,
  s 
)
Value:

Definition at line 137 of file bpf_jit.h.

#define PPC_SLWI (   d,
  a,
  i 
)
Value:

Definition at line 142 of file bpf_jit.h.

#define PPC_SRW (   d,
  a,
  s 
)
Value:

Definition at line 139 of file bpf_jit.h.

#define PPC_SRWI (   d,
  a,
  i 
)
Value:

Definition at line 146 of file bpf_jit.h.

#define PPC_STD (   r,
  base,
  i 
)
Value:
___PPC_RA(base) | ((i) & 0xfffc))

Definition at line 86 of file bpf_jit.h.

#define PPC_SUB (   d,
  a,
  b 
)
Value:

Definition at line 113 of file bpf_jit.h.

#define r_A   4

Definition at line 38 of file bpf_jit.h.

#define r_addr   6

Definition at line 40 of file bpf_jit.h.

#define r_D   14

Definition at line 42 of file bpf_jit.h.

#define r_HL   15

Definition at line 43 of file bpf_jit.h.

#define r_M   16

Definition at line 44 of file bpf_jit.h.

#define r_ret   3

Definition at line 37 of file bpf_jit.h.

#define r_scratch1   7

Definition at line 41 of file bpf_jit.h.

#define r_skb   3

Definition at line 36 of file bpf_jit.h.

#define r_X   5

Definition at line 39 of file bpf_jit.h.

#define SEEN_DATAREF   0x10000 /* might call external helpers */

Definition at line 219 of file bpf_jit.h.

#define SEEN_MEM
Value:
0x40000 /* SEEN_MEM+(1<<n) = use mem[n] for temporary
* storage */

Definition at line 221 of file bpf_jit.h.

#define SEEN_MEM_MSK   0x0ffff

Definition at line 222 of file bpf_jit.h.

#define SEEN_XREG   0x20000 /* X reg is used */

Definition at line 220 of file bpf_jit.h.

Function Documentation

DECLARE_LOAD_FUNC ( sk_load_word  )
DECLARE_LOAD_FUNC ( sk_load_half  )
DECLARE_LOAD_FUNC ( sk_load_byte  )
DECLARE_LOAD_FUNC ( sk_load_byte_msh  )