linux/arch/x86/net/bpf_jit_comp.c
<<
>>
Prefs
   1/* bpf_jit_comp.c : BPF JIT compiler
   2 *
   3 * Copyright (C) 2011 Eric Dumazet (eric.dumazet@gmail.com)
   4 *
   5 * This program is free software; you can redistribute it and/or
   6 * modify it under the terms of the GNU General Public License
   7 * as published by the Free Software Foundation; version 2
   8 * of the License.
   9 */
  10#include <linux/moduleloader.h>
  11#include <asm/cacheflush.h>
  12#include <linux/netdevice.h>
  13#include <linux/filter.h>
  14
  15/*
  16 * Conventions :
  17 *  EAX : BPF A accumulator
  18 *  EBX : BPF X accumulator
  19 *  RDI : pointer to skb   (first argument given to JIT function)
  20 *  RBP : frame pointer (even if CONFIG_FRAME_POINTER=n)
  21 *  ECX,EDX,ESI : scratch registers
  22 *  r9d : skb->len - skb->data_len (headlen)
  23 *  r8  : skb->data
  24 * -8(RBP) : saved RBX value
  25 * -16(RBP)..-80(RBP) : BPF_MEMWORDS values
  26 */
  27int bpf_jit_enable __read_mostly;
  28
  29/*
  30 * assembly code in arch/x86/net/bpf_jit.S
  31 */
  32extern u8 sk_load_word[], sk_load_half[], sk_load_byte[], sk_load_byte_msh[];
  33extern u8 sk_load_word_positive_offset[], sk_load_half_positive_offset[];
  34extern u8 sk_load_byte_positive_offset[], sk_load_byte_msh_positive_offset[];
  35extern u8 sk_load_word_negative_offset[], sk_load_half_negative_offset[];
  36extern u8 sk_load_byte_negative_offset[], sk_load_byte_msh_negative_offset[];
  37
  38static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
  39{
  40        if (len == 1)
  41                *ptr = bytes;
  42        else if (len == 2)
  43                *(u16 *)ptr = bytes;
  44        else {
  45                *(u32 *)ptr = bytes;
  46                barrier();
  47        }
  48        return ptr + len;
  49}
  50
  51#define EMIT(bytes, len)        do { prog = emit_code(prog, bytes, len); } while (0)
  52
  53#define EMIT1(b1)               EMIT(b1, 1)
  54#define EMIT2(b1, b2)           EMIT((b1) + ((b2) << 8), 2)
  55#define EMIT3(b1, b2, b3)       EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
  56#define EMIT4(b1, b2, b3, b4)   EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
  57#define EMIT1_off32(b1, off)    do { EMIT1(b1); EMIT(off, 4);} while (0)
  58
  59#define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
  60#define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
  61
  62static inline bool is_imm8(int value)
  63{
  64        return value <= 127 && value >= -128;
  65}
  66
  67static inline bool is_near(int offset)
  68{
  69        return offset <= 127 && offset >= -128;
  70}
  71
  72#define EMIT_JMP(offset)                                                \
  73do {                                                                    \
  74        if (offset) {                                                   \
  75                if (is_near(offset))                                    \
  76                        EMIT2(0xeb, offset); /* jmp .+off8 */           \
  77                else                                                    \
  78                        EMIT1_off32(0xe9, offset); /* jmp .+off32 */    \
  79        }                                                               \
  80} while (0)
  81
  82/* list of x86 cond jumps opcodes (. + s8)
  83 * Add 0x10 (and an extra 0x0f) to generate far jumps (. + s32)
  84 */
  85#define X86_JB  0x72
  86#define X86_JAE 0x73
  87#define X86_JE  0x74
  88#define X86_JNE 0x75
  89#define X86_JBE 0x76
  90#define X86_JA  0x77
  91
  92#define EMIT_COND_JMP(op, offset)                               \
  93do {                                                            \
  94        if (is_near(offset))                                    \
  95                EMIT2(op, offset); /* jxx .+off8 */             \
  96        else {                                                  \
  97                EMIT2(0x0f, op + 0x10);                         \
  98                EMIT(offset, 4); /* jxx .+off32 */              \
  99        }                                                       \
 100} while (0)
 101
 102#define COND_SEL(CODE, TOP, FOP)        \
 103        case CODE:                      \
 104                t_op = TOP;             \
 105                f_op = FOP;             \
 106                goto cond_branch
 107
 108
 109#define SEEN_DATAREF 1 /* might call external helpers */
 110#define SEEN_XREG    2 /* ebx is used */
 111#define SEEN_MEM     4 /* use mem[] for temporary storage */
 112
 113static inline void bpf_flush_icache(void *start, void *end)
 114{
 115        mm_segment_t old_fs = get_fs();
 116
 117        set_fs(KERNEL_DS);
 118        smp_wmb();
 119        flush_icache_range((unsigned long)start, (unsigned long)end);
 120        set_fs(old_fs);
 121}
 122
 123#define CHOOSE_LOAD_FUNC(K, func) \
 124        ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
 125
 126void bpf_jit_compile(struct sk_filter *fp)
 127{
 128        u8 temp[64];
 129        u8 *prog;
 130        unsigned int proglen, oldproglen = 0;
 131        int ilen, i;
 132        int t_offset, f_offset;
 133        u8 t_op, f_op, seen = 0, pass;
 134        u8 *image = NULL;
 135        u8 *func;
 136        int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
 137        unsigned int cleanup_addr; /* epilogue code offset */
 138        unsigned int *addrs;
 139        const struct sock_filter *filter = fp->insns;
 140        int flen = fp->len;
 141
 142        if (!bpf_jit_enable)
 143                return;
 144
 145        addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
 146        if (addrs == NULL)
 147                return;
 148
 149        /* Before first pass, make a rough estimation of addrs[]
 150         * each bpf instruction is translated to less than 64 bytes
 151         */
 152        for (proglen = 0, i = 0; i < flen; i++) {
 153                proglen += 64;
 154                addrs[i] = proglen;
 155        }
 156        cleanup_addr = proglen; /* epilogue address */
 157
 158        for (pass = 0; pass < 10; pass++) {
 159                u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen;
 160                /* no prologue/epilogue for trivial filters (RET something) */
 161                proglen = 0;
 162                prog = temp;
 163
 164                if (seen_or_pass0) {
 165                        EMIT4(0x55, 0x48, 0x89, 0xe5); /* push %rbp; mov %rsp,%rbp */
 166                        EMIT4(0x48, 0x83, 0xec, 96);    /* subq  $96,%rsp       */
 167                        /* note : must save %rbx in case bpf_error is hit */
 168                        if (seen_or_pass0 & (SEEN_XREG | SEEN_DATAREF))
 169                                EMIT4(0x48, 0x89, 0x5d, 0xf8); /* mov %rbx, -8(%rbp) */
 170                        if (seen_or_pass0 & SEEN_XREG)
 171                                CLEAR_X(); /* make sure we dont leek kernel memory */
 172
 173                        /*
 174                         * If this filter needs to access skb data,
 175                         * loads r9 and r8 with :
 176                         *  r9 = skb->len - skb->data_len
 177                         *  r8 = skb->data
 178                         */
 179                        if (seen_or_pass0 & SEEN_DATAREF) {
 180                                if (offsetof(struct sk_buff, len) <= 127)
 181                                        /* mov    off8(%rdi),%r9d */
 182                                        EMIT4(0x44, 0x8b, 0x4f, offsetof(struct sk_buff, len));
 183                                else {
 184                                        /* mov    off32(%rdi),%r9d */
 185                                        EMIT3(0x44, 0x8b, 0x8f);
 186                                        EMIT(offsetof(struct sk_buff, len), 4);
 187                                }
 188                                if (is_imm8(offsetof(struct sk_buff, data_len)))
 189                                        /* sub    off8(%rdi),%r9d */
 190                                        EMIT4(0x44, 0x2b, 0x4f, offsetof(struct sk_buff, data_len));
 191                                else {
 192                                        EMIT3(0x44, 0x2b, 0x8f);
 193                                        EMIT(offsetof(struct sk_buff, data_len), 4);
 194                                }
 195
 196                                if (is_imm8(offsetof(struct sk_buff, data)))
 197                                        /* mov off8(%rdi),%r8 */
 198                                        EMIT4(0x4c, 0x8b, 0x47, offsetof(struct sk_buff, data));
 199                                else {
 200                                        /* mov off32(%rdi),%r8 */
 201                                        EMIT3(0x4c, 0x8b, 0x87);
 202                                        EMIT(offsetof(struct sk_buff, data), 4);
 203                                }
 204                        }
 205                }
 206
 207                switch (filter[0].code) {
 208                case BPF_S_RET_K:
 209                case BPF_S_LD_W_LEN:
 210                case BPF_S_ANC_PROTOCOL:
 211                case BPF_S_ANC_IFINDEX:
 212                case BPF_S_ANC_MARK:
 213                case BPF_S_ANC_RXHASH:
 214                case BPF_S_ANC_CPU:
 215                case BPF_S_ANC_QUEUE:
 216                case BPF_S_LD_W_ABS:
 217                case BPF_S_LD_H_ABS:
 218                case BPF_S_LD_B_ABS:
 219                        /* first instruction sets A register (or is RET 'constant') */
 220                        break;
 221                default:
 222                        /* make sure we dont leak kernel information to user */
 223                        CLEAR_A(); /* A = 0 */
 224                }
 225
 226                for (i = 0; i < flen; i++) {
 227                        unsigned int K = filter[i].k;
 228
 229                        switch (filter[i].code) {
 230                        case BPF_S_ALU_ADD_X: /* A += X; */
 231                                seen |= SEEN_XREG;
 232                                EMIT2(0x01, 0xd8);              /* add %ebx,%eax */
 233                                break;
 234                        case BPF_S_ALU_ADD_K: /* A += K; */
 235                                if (!K)
 236                                        break;
 237                                if (is_imm8(K))
 238                                        EMIT3(0x83, 0xc0, K);   /* add imm8,%eax */
 239                                else
 240                                        EMIT1_off32(0x05, K);   /* add imm32,%eax */
 241                                break;
 242                        case BPF_S_ALU_SUB_X: /* A -= X; */
 243                                seen |= SEEN_XREG;
 244                                EMIT2(0x29, 0xd8);              /* sub    %ebx,%eax */
 245                                break;
 246                        case BPF_S_ALU_SUB_K: /* A -= K */
 247                                if (!K)
 248                                        break;
 249                                if (is_imm8(K))
 250                                        EMIT3(0x83, 0xe8, K); /* sub imm8,%eax */
 251                                else
 252                                        EMIT1_off32(0x2d, K); /* sub imm32,%eax */
 253                                break;
 254                        case BPF_S_ALU_MUL_X: /* A *= X; */
 255                                seen |= SEEN_XREG;
 256                                EMIT3(0x0f, 0xaf, 0xc3);        /* imul %ebx,%eax */
 257                                break;
 258                        case BPF_S_ALU_MUL_K: /* A *= K */
 259                                if (is_imm8(K))
 260                                        EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
 261                                else {
 262                                        EMIT2(0x69, 0xc0);              /* imul imm32,%eax */
 263                                        EMIT(K, 4);
 264                                }
 265                                break;
 266                        case BPF_S_ALU_DIV_X: /* A /= X; */
 267                                seen |= SEEN_XREG;
 268                                EMIT2(0x85, 0xdb);      /* test %ebx,%ebx */
 269                                if (pc_ret0 > 0) {
 270                                        /* addrs[pc_ret0 - 1] is start address of target
 271                                         * (addrs[i] - 4) is the address following this jmp
 272                                         * ("xor %edx,%edx; div %ebx" being 4 bytes long)
 273                                         */
 274                                        EMIT_COND_JMP(X86_JE, addrs[pc_ret0 - 1] -
 275                                                                (addrs[i] - 4));
 276                                } else {
 277                                        EMIT_COND_JMP(X86_JNE, 2 + 5);
 278                                        CLEAR_A();
 279                                        EMIT1_off32(0xe9, cleanup_addr - (addrs[i] - 4)); /* jmp .+off32 */
 280                                }
 281                                EMIT4(0x31, 0xd2, 0xf7, 0xf3); /* xor %edx,%edx; div %ebx */
 282                                break;
 283                        case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
 284                                EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
 285                                EMIT(K, 4);
 286                                EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
 287                                break;
 288                        case BPF_S_ALU_AND_X:
 289                                seen |= SEEN_XREG;
 290                                EMIT2(0x21, 0xd8);              /* and %ebx,%eax */
 291                                break;
 292                        case BPF_S_ALU_AND_K:
 293                                if (K >= 0xFFFFFF00) {
 294                                        EMIT2(0x24, K & 0xFF); /* and imm8,%al */
 295                                } else if (K >= 0xFFFF0000) {
 296                                        EMIT2(0x66, 0x25);      /* and imm16,%ax */
 297                                        EMIT(K, 2);
 298                                } else {
 299                                        EMIT1_off32(0x25, K);   /* and imm32,%eax */
 300                                }
 301                                break;
 302                        case BPF_S_ALU_OR_X:
 303                                seen |= SEEN_XREG;
 304                                EMIT2(0x09, 0xd8);              /* or %ebx,%eax */
 305                                break;
 306                        case BPF_S_ALU_OR_K:
 307                                if (is_imm8(K))
 308                                        EMIT3(0x83, 0xc8, K); /* or imm8,%eax */
 309                                else
 310                                        EMIT1_off32(0x0d, K);   /* or imm32,%eax */
 311                                break;
 312                        case BPF_S_ANC_ALU_XOR_X: /* A ^= X; */
 313                                seen |= SEEN_XREG;
 314                                EMIT2(0x31, 0xd8);              /* xor %ebx,%eax */
 315                                break;
 316                        case BPF_S_ALU_LSH_X: /* A <<= X; */
 317                                seen |= SEEN_XREG;
 318                                EMIT4(0x89, 0xd9, 0xd3, 0xe0);  /* mov %ebx,%ecx; shl %cl,%eax */
 319                                break;
 320                        case BPF_S_ALU_LSH_K:
 321                                if (K == 0)
 322                                        break;
 323                                else if (K == 1)
 324                                        EMIT2(0xd1, 0xe0); /* shl %eax */
 325                                else
 326                                        EMIT3(0xc1, 0xe0, K);
 327                                break;
 328                        case BPF_S_ALU_RSH_X: /* A >>= X; */
 329                                seen |= SEEN_XREG;
 330                                EMIT4(0x89, 0xd9, 0xd3, 0xe8);  /* mov %ebx,%ecx; shr %cl,%eax */
 331                                break;
 332                        case BPF_S_ALU_RSH_K: /* A >>= K; */
 333                                if (K == 0)
 334                                        break;
 335                                else if (K == 1)
 336                                        EMIT2(0xd1, 0xe8); /* shr %eax */
 337                                else
 338                                        EMIT3(0xc1, 0xe8, K);
 339                                break;
 340                        case BPF_S_ALU_NEG:
 341                                EMIT2(0xf7, 0xd8);              /* neg %eax */
 342                                break;
 343                        case BPF_S_RET_K:
 344                                if (!K) {
 345                                        if (pc_ret0 == -1)
 346                                                pc_ret0 = i;
 347                                        CLEAR_A();
 348                                } else {
 349                                        EMIT1_off32(0xb8, K);   /* mov $imm32,%eax */
 350                                }
 351                                /* fallinto */
 352                        case BPF_S_RET_A:
 353                                if (seen_or_pass0) {
 354                                        if (i != flen - 1) {
 355                                                EMIT_JMP(cleanup_addr - addrs[i]);
 356                                                break;
 357                                        }
 358                                        if (seen_or_pass0 & SEEN_XREG)
 359                                                EMIT4(0x48, 0x8b, 0x5d, 0xf8);  /* mov  -8(%rbp),%rbx */
 360                                        EMIT1(0xc9);            /* leaveq */
 361                                }
 362                                EMIT1(0xc3);            /* ret */
 363                                break;
 364                        case BPF_S_MISC_TAX: /* X = A */
 365                                seen |= SEEN_XREG;
 366                                EMIT2(0x89, 0xc3);      /* mov    %eax,%ebx */
 367                                break;
 368                        case BPF_S_MISC_TXA: /* A = X */
 369                                seen |= SEEN_XREG;
 370                                EMIT2(0x89, 0xd8);      /* mov    %ebx,%eax */
 371                                break;
 372                        case BPF_S_LD_IMM: /* A = K */
 373                                if (!K)
 374                                        CLEAR_A();
 375                                else
 376                                        EMIT1_off32(0xb8, K); /* mov $imm32,%eax */
 377                                break;
 378                        case BPF_S_LDX_IMM: /* X = K */
 379                                seen |= SEEN_XREG;
 380                                if (!K)
 381                                        CLEAR_X();
 382                                else
 383                                        EMIT1_off32(0xbb, K); /* mov $imm32,%ebx */
 384                                break;
 385                        case BPF_S_LD_MEM: /* A = mem[K] : mov off8(%rbp),%eax */
 386                                seen |= SEEN_MEM;
 387                                EMIT3(0x8b, 0x45, 0xf0 - K*4);
 388                                break;
 389                        case BPF_S_LDX_MEM: /* X = mem[K] : mov off8(%rbp),%ebx */
 390                                seen |= SEEN_XREG | SEEN_MEM;
 391                                EMIT3(0x8b, 0x5d, 0xf0 - K*4);
 392                                break;
 393                        case BPF_S_ST: /* mem[K] = A : mov %eax,off8(%rbp) */
 394                                seen |= SEEN_MEM;
 395                                EMIT3(0x89, 0x45, 0xf0 - K*4);
 396                                break;
 397                        case BPF_S_STX: /* mem[K] = X : mov %ebx,off8(%rbp) */
 398                                seen |= SEEN_XREG | SEEN_MEM;
 399                                EMIT3(0x89, 0x5d, 0xf0 - K*4);
 400                                break;
 401                        case BPF_S_LD_W_LEN: /* A = skb->len; */
 402                                BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, len) != 4);
 403                                if (is_imm8(offsetof(struct sk_buff, len)))
 404                                        /* mov    off8(%rdi),%eax */
 405                                        EMIT3(0x8b, 0x47, offsetof(struct sk_buff, len));
 406                                else {
 407                                        EMIT2(0x8b, 0x87);
 408                                        EMIT(offsetof(struct sk_buff, len), 4);
 409                                }
 410                                break;
 411                        case BPF_S_LDX_W_LEN: /* X = skb->len; */
 412                                seen |= SEEN_XREG;
 413                                if (is_imm8(offsetof(struct sk_buff, len)))
 414                                        /* mov off8(%rdi),%ebx */
 415                                        EMIT3(0x8b, 0x5f, offsetof(struct sk_buff, len));
 416                                else {
 417                                        EMIT2(0x8b, 0x9f);
 418                                        EMIT(offsetof(struct sk_buff, len), 4);
 419                                }
 420                                break;
 421                        case BPF_S_ANC_PROTOCOL: /* A = ntohs(skb->protocol); */
 422                                BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, protocol) != 2);
 423                                if (is_imm8(offsetof(struct sk_buff, protocol))) {
 424                                        /* movzwl off8(%rdi),%eax */
 425                                        EMIT4(0x0f, 0xb7, 0x47, offsetof(struct sk_buff, protocol));
 426                                } else {
 427                                        EMIT3(0x0f, 0xb7, 0x87); /* movzwl off32(%rdi),%eax */
 428                                        EMIT(offsetof(struct sk_buff, protocol), 4);
 429                                }
 430                                EMIT2(0x86, 0xc4); /* ntohs() : xchg   %al,%ah */
 431                                break;
 432                        case BPF_S_ANC_IFINDEX:
 433                                if (is_imm8(offsetof(struct sk_buff, dev))) {
BPF_S_ANC_IFINDEX:
EMIT3(0x0f, 0x="sref">offsetof(struct                                      f">BPF_S_ALU_LSH_X: K == 1)
/* 4hr /eax */
BPF_S_ANC_IFINDEX:
 337              4     4           else
 428                                        EMIT(sk_buff, 3(0xc4, 0xe8, K);
                4     4         break;
EMIT3(0x48, 0x69, 0xc0); BP4_S_ALU_NEG:
 35CONDs="lme="L428"> 428  X86_JEine" name="L355X86_JEf="+code=offsetof" cl                               428  "sref">EMIT_JMP(cleane=E6efit_comp.c#L431" id="L431" class="line" na         4span class="comment">/* 4eg /eax */
 422                                BUL43_e findexa>(struct sk_bume="L342"4 342                4     4         break;
 407 370                            linhref="+coax=EMIT3" class="sref">EMIT3(0x0f, 0xb7, 0x87); 4PF_S_RET_K:
 428                                        findexa>(stef="+code=sk_buff" class="sref">sk_buff,          4  if (!K) {
pc4ret0 == -1)
pc_r4t0 = i;
 422                                BU class="sref">EMIT(EMITmarka>(struct sk_bum="commentef="+code=CLEAR_A" class4"sref4>CLEAR_A();
 433                                if (is_imm8(EMITmarka>(struct sk="L348"> 448                  4     4       } else {
 4class="sref">EMIT3(0x0f, 0xb7, 0x87); /* mov $im432,/eax */
 405                                        EMIT3(0x8b, 0x47, EMITmarka>(stra href="+code=sk_buff" class="sref">sk_bue" name="4350"> 350           4     4              }

 407                                        4PF_S_RET_A:
 428                                        EMIT(EMITmarka>(stef="+code=sk_buff" class="sref">sk_buff, ="+code=s4en_or_pass0" class="sref4>seen4or_pass0) {
 - 1) {
ad4rs[i]);
       4                        4     4         break;
 422                                BU class="sref">EMIT(EMITrxhasha>(struct sk_bu"L357"> 347                   4     4              }
 433                                if (is_imm8(EMITrxhasha>(struct skp; SEEN_XREG)
 4class="sref">EMIT3(0x0f, 0xb7, 0x87); /* mov  -8(%r4p),/rbx */
 405                                        EMIT3(0x8b, 0x47, EMITrxhasha>(stra href="+code=sk_buff" class="sref">sk_bu9);      4     /* 4eaveq */
 361           4     4              }
 407                                        <0xc3);   4        4* ret */
 428                                        EMIT(EMITrxhasha>(stef="+code=sk_buff" class="sref">sk_buff, me="L363"4 363                4     4         break;
sk_buff, ma> != : /*4X = A */
SEEN_XREG;
                        case /* mov    %4ax,/ebx */
 422                                BU class="sref">EMIT(EMITqueue_mappinga>(struct+code=sk_buff" class="sref">sk_buff,                 4     4         break;
 433                                if (is_imm8(EMITqueue_mappinga>(struct skS_MISC_TX4: /*4A = X */
 424                                        SEEN_XREG;
 425                                        EMIT4(0x0f, 0xb7, 0x47, EMITqueue_mappinga>(strode=sk_buff" class="sref">sk_buff, /* mov    %4bx,/eax */
                4     4         break;
 427                                        EMIT3(0x0f, 0xb7, 0x87); : /*4A = K */
 428                                        EMIT(EMITqueue_mappinga>(stef="+code=sk_buff" class="sref">sk_buff,          4    if (!K)
sk_buff,      CLEAR_A();
 375              4     4           else
                        case /* mov $im432,/eax #ifdefnet/bpf_jit_compCONFIG_S"line" name="L355CONFIG_S"leax                       case                 4     4         break;
 407<04407<25href="+code=EMIT1_off32" class="MIT3"gs:EMIT3(0x0f, 0xb7, 0x87); : /*4X = K */
 428  ulass="line" name=u      )(unsigned long)     de=offsetof" cl pu_numbe                 pu_numbe f="+co"> 430                     casmp_processor_id(OTOCOL" class="sref">BPF_S_ANC_PROTOCOL: SEEN_#bpf_jit_comp.c#L382" id="L382" class="line"4         4    if (!K)
 374                                  4     CLEAR#endif4                                  4 _S_LD_IM4"> 382              4     4           else
/* mov $im432,/ebx */
                        case                 4     4         break;
 412 428                   EMIT(   href="arch/x86/net/et/bpf_jit_compL412" id="L412" class="line" name="L412"> 412  DATARE             DATARE lineit_comp.c#L431" id="L431" class="line" na; SEEN_MEM;
 412 428  image           412<"sref">EMIT_JMP(cleanup_addr - K*4);
 383    e                                   EMIT1_osiOCOL" class="sref">BPF_S_ANC_PROTOCOL:                 4     4         break;
 383   e                  t_                BPF_S_ANC_PROTOCOL: /* X =4mem[K] : mov off8(%r4p),/ebx */
 | SEEN_MEM;
                        case K*4);
 412 428                   EMIT(                4     4         break;
 it_comp.c#L431" id="L431" class="line" nam 
                        case SEEN_MEM;
 412 428                   K*4);
 it_comp.c#L431" id="L431" class="line" nam                 4     4         break;

 412 428                   EMIT(SEEN_MEM;
 412  DATARE             DATARE line href="+code=seen" clas                              seen59, 0x5d, 5xf0 - K*4);
 412 428  image           412<"sref">EMIT_JMP(cleanup_addr - seen591 0x5d, 5xf="+code=SEEN_MEM" clas5     5         break;
 383    e                                   EMIT1_osiOCOL" class="sref">BPF_S_ANC_PROTOCOL: : /* A = 5kb-&g5;len; */
 383   e                  t_                BPF_S_ANC_PROTOCOL: :                 5sref"5len) != 4);
, len)))
                        case /* mov    off8(%r5i),9eax */
 412<(EMIT(   href="arch/x86/bpf_jit_comp.c#L412" id="L412" class="line" name="L412"> 412  DATARE             DATARE line href="+code=seen" clas                              seen597="comme5t396                5     5         else {
 412 428  image           412<"sref">EMIT_JMP(cleanup_addr - seen598="comme5t] = X : mov %ebx,of5MIT2<5a>(0x8b, 0x87);
,5len), 4);
 433                       409           5     5              }
"> 3973                                   BPF_S_ANC_PROTOCOL:                 5     5         break;
: /* X = 5kb-&g5;len; */
"> 39b3href="+code=EMIT1_off32" clalea=refhref="+cobx=EMIT3" siOCOL" class="sref">BPF_S_ANC_PROTOCOL: : SEEN_XREG;
 428                   sk_buff,5sk_buff, len)))
sk_buff,5class="co5ment">/* mov off8(%r5i),9ebx */
len));
9,0xdehref="+code=EMIT1_off32" class="MIT3"ef="MIT3" siOCOL" class="sref">BPF_S_ANC_PROTOCOL: sk_buff,5c8="comme5ode=EMIT2" class="sref">5MIT2<5a>(0x8b, 0x9f);
 383   e                  t_                BPF_S_ANC_PROTOCOL: ,5len), 4);
 419           5     5              }
                        case                 5     5         break;
 412<(EMIT(: /* A = ntohs(skb-&g5;prot5col); */
 it_comp.c#L431" id="L431" class="line" n5e3>:                         case p5otocol))) {
 412<(/* movzwl off8(%r5i),9eax */
 it_comp.c#L431" id="L431" class="line" n5e6="comme5="+code=protocol" class=5sref"5protocol));
                        case                   5     5       } else {
 412<"sref">EMIT_JMP(clea +ame="L412"> 412<                                "sref">EMIT_JMP(cleanit_comp.c#L431" id="L431" class="line" n5e8="comme5">/* movzwl off32(%r5i),9eax */
 35="lme="L428"> 428  t_                ,5code=protocol" class="sr5f">pr5tocol), 4);
 429           5     5              }
 412 428  .c#L40JMP_JGT_332" class="line" nameJMP_JGT_3 412 428  .c#L40JMP_JGE_332" class="line" nameJMP_JGE_3:                 5     5         break;
 412 428  .c#L40JMP_JEQ_332" class="line" nameJMP_JEQ_3f="+code=offsetof" clX86_JEine" name="L355X86_JEf="+code=offsetof" clX86_JNEine" name="L355X86_JNE    hrt_comp.c#L431" id="L431" class="line" n5=3>: 5PF_S_5NC_IFINDEX:
 412 428  .c#L40JMP_JSET_332" class="line" nameJMP_JSET_3f="+cde=offsetof" clX86_JNEine" name="L355X86_JNE    code=offsetof" clX86_JEine" name="L355X86_JEf="+hrt_comp.c#L431" id="L431" class="line" n5=k_buffdev))) {
 412 428  .c#L40JMP_JGT_2" class="line" name="JMP_JGT_2offsetof 412 428  .c#L40JMP_JGE_2" class="line" name="JMP_JGE_2K == 1)
 412 428  .c#L40JMP_JEQ_2" class="line" name="JMP_JEQ_2f="+code=offsetof" clX86_JEine" name="L355X86_JEf="+code=offsetof" clX86_JNEine" name="L355X86_JNE    hrt_comp.c#L431" id="L431" class="line" n5=7="comme5span class="comment">/* 5hr 9eax */
 412 428  .c#L40JMP_JSET_2" class="line" name="JMP_JSET_2f="+cde=offsetof" clX86_JNEine" name="L355X86_JNE    code=offsetof" clX86_JEine" name="L355X86_JEf="+hrt_comp.c#L431" id="L431" class="line" n5=8="comme5"> 337              5     5      t_comp.c#L431" id="L431" class="line" n5=uff,5, 0xe8, EMIT  nd_branch/a>   href="arch/x86/rch/me="L412"> 412 412<"sref">EMIT_JMP(clea +ame="L412"> 412clean.code=cleanup_adj="sref">EMITjf               "sref">EMIT_JMP(cleanit_comp.c#L431" id="L431" class="line" n5me="L339"5 339                5     5         break;
 412<"sref">EMIT_JMP(clea +ame="L412"> 412clean.code=cleanup_adj                          "sref">EMIT_JMP(cleanit_comp.c#L431" id="L431" class="line" n5m"comment5BPF_S_ALU_NEG" class="sr5f">BP5_S_ALUt_comp.c#L431" id="L431" class="line" n5ma>: /* 5eg 9eax */
 targets, cp.cavoid doing theltest :)OCOL" class="sref">BPF_S_ANC_PROTOCOL:                 5     5         break;
clean.code=cleanup_adj            412clean.code=cleanup_adj="sref">EMITjf5PF_S_RET_K:
 35="lme="L428"> 428  t_                K) {
pc5ret0 == -1)
sk_buff,5ref">pc_r5t0 = sk_buff,5r8="comme5ef="+code=CLEAR_A" class5"sref5>CLEAR_A();
clean.code=cleanup_adup_a"sref">EMIT  de,548                  5     5       } else {
/* mov $im532,9eax */
 350           5     5              }

 412                                seen5a href="+5ode=BPF_S_RET_A" class="5ref">5PF_S_RET_A:
 39d8href="+code=EMIT1_off32" clacmp"MIT3"ef="MIT3" class="sref">EMIT3(0x0f, 0xb7, 0x87);  !=  - 1) {
i]);
 412                                seen5aef">pc_r5                        5     5         break;
5> 39d8href="+code=EMIT1_off32" clatest ref="ef="MIT3" class="sref">EMIT3(0x0f, 0xb7, 0x87);                    5     5              }
,5="+code=SEEN_XREG" class5"sref5>SEEN_XREG)
/* mov  -8(%r5p),9rbx */
/* 5eaveq */
5> 394f="+code=EMIT1_off32" clatest  href="ea="MIT3" class="sref">EMIT3(0x0f, 0xb7, 0x87);  361           5     5              }
5* ret */
sk_buff,5me="L363"5 363                5     5         break;
/*5X = A */
SEEN_XREG;
pc_r5comment">/* mov    %5ax,9ebx */
3> 39f                                    EMIT3(0x0f, 0xb7, 0x87); : /*5A = X */
 383   3d                                   EMIT3(0x0f, 0xb7, 0x87); SEEN_XREG;
/* mov    %5bx,9eax */
                5     5         break;
: /*5A = K */
BPF_S_ANC_PROTOCOL: K)
 != CLEAR_A();
 3944                                   BPF_S_ANC_PROTOCOL:  375              5     5           else
/* mov $im532,9ebx */
 39a9href="+code=EMIT1_off32" clatest ref16"MIT3"alass="sref">EMIT3(0x0f, 0xb7, 0x87);  428                   sk_buff, <5F_MISC_TX5: /*5X = K */
 383   a9                                   EMIT3(0x0f, 0xb7, 0x87); K)
 382              5     5           else
/* mov $im532,9ebx */
clean.code=cleanup_adj                           5     5         break;
clean.code=cleanup_adj="sref">EMITjf 412 412 428  f_                SEEN_MEM;
 35CONDs="line" name="L355"> 35CONDs="lme="L428"> 428  t_ p          K*4);
clean.code=cleanup_adj="sref">EMITjf 35="line" name="L355"> 35="lme="L428"> 428  f_                /* X =5mem[K] : mov off8(%r5p),9ebx */
 | SEEN_MEM;
K*4);
 35CONDs="line" name="L355"> 35CONDs="lme="L428"> 428  f_ p                          5     5         break;

SEEN_MEM;
EMIT3(0x0f, 0xb7, 0x87); K*4);
seen5m                 5     5         break;
EMITprog                temp          seen5m_MISC_TX5ef="+code=SEEN_MEM" clas5="sre5">SEEN_MEM;
K*4);
 428  progl12" id="L412" claprogl12     +/code=cleanup_addl12" id="L412" cladl12 "bpbss="line"dl1 fatal er or\n"="sref")rt_comp.c#L431" id="L431" class="line" n6/a>: /* A = 6kb-&g6;len; */
 428  "sref">EMIT_JMP(:                 6sref"6len) != 4);
 428  NUL" class="line" nNUL"    code=offsetof" cl"mage          : len)))
: 
K*4);
 428  image           412EMIT3(0x0f, 0xb7, 0x87);  428  progl12" id="L412" claprogl12     +name="L412"> 412len), 4);
 428  "sref">EMIT_JMP(clean =/code=cleanup_adprogl12" id="L412" claprogl12    rt_comp.c#L431" id="L431" class="line" n6e" name="6409"> 409           6     6              }
EMITprog seen6me="L410"6 410                6     6         break;
EMIT3(0x0f, 0xb7, 0x87); : /* X = 6kb-&g6;len; */
EMIT3(0x0f, 0xb7, 0x87); : SEEN_f="+code=EMIT1_off32"  }
EMIT3(0x0f, 0xb7, 0x87); : , lf="+code=EMIT1_off32"  }
EMIT3(0x0f, 0xb7, 0x87); /* mov off8(%r6i),Cebx */
EMIT3(0x0f, 0xb7, 0x87); len));
EMIT3(0x0f, 0xb7, 0x87); 6MIT2<6a>(0x8b, 0x9f);
 412                                len), 4);
EMIT3(0x0f, 0xb7, 0x87);  419           6     6      >EMIT3(0x0f, 0xb7, 0x87);                 6     6         break;
: /* A = ntohs(skb-&g6;prot6col); */
: "bpbss="line"dl1 progl12=MIT3"u !=/oldprogl12=MIT3"u\n"="sref"code=offsetof" clprogl12" id="L412" claprogl12    code=offsetof" cloldprogl12" id="L412" claoldprogl12    h href="+code=seen" class="sref">seen6mk_buffp6otocol))) {
/* movzwl off8(%r6i),Ceax */
EMIT3(0x0f, 0xb7, 0x87); ));
 412 428  image           412 428  max_           /* movzwl off32(%r6i),Ceax */
pr6tocol), 4);
seen6e" name="6429"> 429           6     6              }
seen6ee="L410"6>/* ntohs() : xchg   $al,&637;ah */
seen6=a>:                 6     6         break;
EMIT3(0x0f, 0xb7, 0x87); : 6PF_S_6NC_IFINDEX:
 412dev))) b>EMIT3(0x0f, 0xb7, 0x87); seen6e6="comme6if (K == 1)
"fl12=MIT3"d progl12=MIT3"u phre=MIT3"d image=MIT3"p\n"="sref"chref="+code=seen" class="sref">seen6e7="comme6span class="comment">/* 6hr Ceax */
 337              6     6      t_comp.c#L431" id="L431" class="line" n6=uff,6, 0xe8,                 6     6         break;
seen6m"comment6BPF_S_ALU_NEG" class="sr6f">BP647;ah */
 412 428  KERN_ERR          "JIT /a> : "="sref"code=offsetof" clDUMP_PREFIX_ADDRESSine" name="L355DUMP_PREFIX_ADDRESS    ccomp.c#L426" id="L426" class="line" nam6ma>: /* 6eg Ceax */
                6     6      t_comp.c#L431" id="L431" class="line" n6mk_buff6PF_S_RET_K:
 428  image           412pc6ret0 == -1)
EMIT3(0x0f, 0xb7, 0x87); CLEARde=offsetof" clou            428  "sref">EMIT_JMP(/* mov $im632,Ceax */ 350           6     6      b>EMIT3(0x0f, 0xb7, 0x87); : EMIT3(0x0f, 0xb7, 0x87); 6PF_S_Rstatic void 428"> 428  );  428  "rg"sref">EMIT"rg    hhref="+code=seen" class="sref">seen6="+code=s6en_or_pass0" class="sref6>seen6or_pas_comp.c#L426" id="L426" class="line" nam6/a> !=  - 1) code=cleanup_admodule_free           428  NUL" class="line" nNUL"    code=offsetof" cl"rg"sref">EMIT"rg    hrt_comp.c#L431" id="L431" class="line" n6 6="comme6rs[EMIT3(0x0f, 0xb7, 0x87); sk_buff,6=8="comme67                   6     6      f="+code=EMIT1_off32" clarun from softirq, we must ujita work_  EMIT3(0x0f, 0xb7, 0x87); ,6="+code=SEEN_XREG" class6"sref6>SEEN_f="+code=EMIT1_off32"  lassdule_free() from process /antext="sref">EMIT3(0x0f, 0xb7, 0x87); /* mov  -8(%r6p),Crbx f="+code=EMIT1_off32"  ls="sref">EMIT3(0x0f, 0xb7, 0x87); /* 6eaveq void 428"> 428  0x87);  428  fp          seen6e" name="6361"> 361           6     6      _comp.c#L426" id="L426" class="line" nam60xc3);   6        6* ret */                6     6         break;
 428  work" id="L412" clawork     =/(   != : /*66sref"t_comp.c#L431" id="L431" class="line" n6 SEEN_XREG;
 428  work" id="L412" clawork    code=offsetof" cl); pc_r6comment">/* mov    %6ax,Cebx */
 428  work" id="L412" clawork    hrt_comp.c#L431" id="L431" class="line" n6 8="comme6 367                6     6         breakb>EMIT3(0x0f, 0xb7, 0x87); : /*6A = X b>EMIT3(0x0f, 0xb7, 0x87); SEEN_


The original LXR software by thelEMIT3http://sourceforge.b7, projects/lx >LXR 1_ofunity cothis experiff32al version by EMIT3mailto:lx @N_Xux.no">lx @N_Xux.no .
lx .N_Xux.no kindly hosted by EMIT3http://www.redpill-N_Xpro.no">Redpill L_Xpro AS c provider of L_Xux /ansulting and operahions services since 1995.