Module Name: src Committed By: alnsn Date: Sun May 29 17:20:22 UTC 2016
Modified Files: src/sys/net: bpfjit.c Log Message: Adapt to the new version of sljit@r313. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/net/bpfjit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/bpfjit.c diff -u src/sys/net/bpfjit.c:1.44 src/sys/net/bpfjit.c:1.45 --- src/sys/net/bpfjit.c:1.44 Tue Dec 29 21:49:58 2015 +++ src/sys/net/bpfjit.c Sun May 29 17:20:22 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $ */ +/* $NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $ */ /*- * Copyright (c) 2011-2015 Alexander Nasonov. @@ -31,9 +31,9 @@ #include <sys/cdefs.h> #ifdef _KERNEL -__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $"); #else -__RCSID("$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $"); +__RCSID("$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $"); #endif #include <sys/types.h> @@ -85,20 +85,20 @@ __RCSID("$NetBSD: bpfjit.c,v 1.44 2015/1 * The first argument is reassigned upon entry * to a more frequently used buf argument. */ -#define BJ_CTX_ARG SLJIT_SAVED_REG1 -#define BJ_ARGS SLJIT_SAVED_REG2 +#define BJ_CTX_ARG SLJIT_S0 +#define BJ_ARGS SLJIT_S1 /* * Permanent register assignments. */ -#define BJ_BUF SLJIT_SAVED_REG1 -//#define BJ_ARGS SLJIT_SAVED_REG2 -#define BJ_BUFLEN SLJIT_SAVED_REG3 -#define BJ_AREG SLJIT_SCRATCH_REG1 -#define BJ_TMP1REG SLJIT_SCRATCH_REG2 -#define BJ_TMP2REG SLJIT_SCRATCH_REG3 -#define BJ_XREG SLJIT_TEMPORARY_EREG1 -#define BJ_TMP3REG SLJIT_TEMPORARY_EREG2 +#define BJ_BUF SLJIT_S0 +//#define BJ_ARGS SLJIT_S1 +#define BJ_BUFLEN SLJIT_S2 +#define BJ_AREG SLJIT_R0 +#define BJ_TMP1REG SLJIT_R1 +#define BJ_TMP2REG SLJIT_R2 +#define BJ_XREG SLJIT_R3 +#define BJ_TMP3REG SLJIT_R4 #ifdef _KERNEL #define MAX_MEMWORDS BPF_MAX_MEMWORDS @@ -248,10 +248,10 @@ bpfjit_modcmd(modcmd_t cmd, void *arg) * Return a number of scratch registers to pass * to sljit_emit_enter() function. */ -static sljit_si +static sljit_s32 nscratches(bpfjit_hint_t hints) { - sljit_si rv = 2; + sljit_s32 rv = 2; #ifdef _KERNEL if (hints & BJ_HINT_PKT) @@ -354,11 +354,11 @@ append_jump(struct sljit_jump *jump, str * Emit code for BPF_LD+BPF_B+BPF_ABS A <- P[k:1]. */ static int -emit_read8(struct sljit_compiler *compiler, sljit_si src, uint32_t k) +emit_read8(struct sljit_compiler *compiler, sljit_s32 src, uint32_t k) { return sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_AREG, 0, SLJIT_MEM1(src), k); } @@ -367,7 +367,7 @@ emit_read8(struct sljit_compiler *compil * Emit code for BPF_LD+BPF_H+BPF_ABS A <- P[k:2]. */ static int -emit_read16(struct sljit_compiler *compiler, sljit_si src, uint32_t k) +emit_read16(struct sljit_compiler *compiler, sljit_s32 src, uint32_t k) { int status; @@ -375,7 +375,7 @@ emit_read16(struct sljit_compiler *compi /* A = buf[k]; */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_AREG, 0, SLJIT_MEM1(src), k); if (status != SLJIT_SUCCESS) @@ -383,7 +383,7 @@ emit_read16(struct sljit_compiler *compi /* tmp1 = buf[k+1]; */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_TMP1REG, 0, SLJIT_MEM1(src), k+1); if (status != SLJIT_SUCCESS) @@ -411,7 +411,7 @@ emit_read16(struct sljit_compiler *compi * Emit code for BPF_LD+BPF_W+BPF_ABS A <- P[k:4]. */ static int -emit_read32(struct sljit_compiler *compiler, sljit_si src, uint32_t k) +emit_read32(struct sljit_compiler *compiler, sljit_s32 src, uint32_t k) { int status; @@ -419,7 +419,7 @@ emit_read32(struct sljit_compiler *compi /* A = buf[k]; */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_AREG, 0, SLJIT_MEM1(src), k); if (status != SLJIT_SUCCESS) @@ -427,7 +427,7 @@ emit_read32(struct sljit_compiler *compi /* tmp1 = buf[k+1]; */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_TMP1REG, 0, SLJIT_MEM1(src), k+1); if (status != SLJIT_SUCCESS) @@ -453,7 +453,7 @@ emit_read32(struct sljit_compiler *compi /* tmp1 = buf[k+2]; */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_TMP1REG, 0, SLJIT_MEM1(src), k+2); if (status != SLJIT_SUCCESS) @@ -479,7 +479,7 @@ emit_read32(struct sljit_compiler *compi /* tmp1 = buf[k+3]; */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_TMP1REG, 0, SLJIT_MEM1(src), k+3); if (status != SLJIT_SUCCESS) @@ -522,13 +522,13 @@ emit_xcall(struct sljit_compiler *compil uint32_t (*fn)(const struct mbuf *, uint32_t, int *)) { #if BJ_XREG == SLJIT_RETURN_REG || \ - BJ_XREG == SLJIT_SCRATCH_REG1 || \ - BJ_XREG == SLJIT_SCRATCH_REG2 || \ - BJ_XREG == SLJIT_SCRATCH_REG3 + BJ_XREG == SLJIT_R0 || \ + BJ_XREG == SLJIT_R1 || \ + BJ_XREG == SLJIT_R2 #error "Not supported assignment of registers." #endif struct sljit_jump *jump; - sljit_si save_reg; + sljit_s32 save_reg; int status; save_reg = (BPF_CLASS(pc->code) == BPF_LDX) ? BJ_AREG : BJ_XREG; @@ -536,8 +536,8 @@ emit_xcall(struct sljit_compiler *compil if (save_reg == BJ_AREG || (hints & BJ_HINT_XREG)) { /* save A or X */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UI, /* uint32_t destination */ - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MOV_U32, + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, reg), save_reg, 0); if (status != SLJIT_SUCCESS) @@ -549,7 +549,7 @@ emit_xcall(struct sljit_compiler *compil */ status = sljit_emit_op1(compiler, SLJIT_MOV, - SLJIT_SCRATCH_REG1, 0, + SLJIT_R0, 0, BJ_BUF, 0); if (status != SLJIT_SUCCESS) return status; @@ -559,14 +559,14 @@ emit_xcall(struct sljit_compiler *compil /* k = X; */ status = sljit_emit_op1(compiler, SLJIT_MOV, - SLJIT_SCRATCH_REG2, 0, + SLJIT_R1, 0, BJ_XREG, 0); if (status != SLJIT_SUCCESS) return status; } else { /* if (X > UINT32_MAX - pc->k) return 0; */ jump = sljit_emit_cmp(compiler, - SLJIT_C_GREATER, + SLJIT_GREATER, BJ_XREG, 0, SLJIT_IMM, UINT32_MAX - pc->k); if (jump == NULL) @@ -577,7 +577,7 @@ emit_xcall(struct sljit_compiler *compil /* k = X + pc->k; */ status = sljit_emit_op2(compiler, SLJIT_ADD, - SLJIT_SCRATCH_REG2, 0, + SLJIT_R1, 0, BJ_XREG, 0, SLJIT_IMM, (uint32_t)pc->k); if (status != SLJIT_SUCCESS) @@ -587,7 +587,7 @@ emit_xcall(struct sljit_compiler *compil /* k = pc->k */ status = sljit_emit_op1(compiler, SLJIT_MOV, - SLJIT_SCRATCH_REG2, 0, + SLJIT_R1, 0, SLJIT_IMM, (uint32_t)pc->k); if (status != SLJIT_SUCCESS) return status; @@ -597,7 +597,7 @@ emit_xcall(struct sljit_compiler *compil * The third argument of fn is an address on stack. */ status = sljit_get_local_base(compiler, - SLJIT_SCRATCH_REG3, 0, + SLJIT_R2, 0, offsetof(struct bpfjit_stack, err)); if (status != SLJIT_SUCCESS) return status; @@ -621,8 +621,8 @@ emit_xcall(struct sljit_compiler *compil /* if (*err != 0) return 0; */ jump = sljit_emit_cmp(compiler, - SLJIT_C_NOT_EQUAL|SLJIT_INT_OP, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_NOT_EQUAL|SLJIT_I32_OP, + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, err), SLJIT_IMM, 0); if (jump == NULL) @@ -634,9 +634,9 @@ emit_xcall(struct sljit_compiler *compil if (save_reg == BJ_AREG || (hints & BJ_HINT_XREG)) { /* restore A or X */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UI, /* uint32_t source */ + SLJIT_MOV_U32, save_reg, 0, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, reg)); if (status != SLJIT_SUCCESS) return status; @@ -655,17 +655,17 @@ emit_cop(struct sljit_compiler *compiler struct sljit_jump ***ret0, size_t *ret0_size, size_t *ret0_maxsize) { #if BJ_XREG == SLJIT_RETURN_REG || \ - BJ_XREG == SLJIT_SCRATCH_REG1 || \ - BJ_XREG == SLJIT_SCRATCH_REG2 || \ - BJ_XREG == SLJIT_SCRATCH_REG3 || \ - BJ_TMP3REG == SLJIT_SCRATCH_REG1 || \ - BJ_TMP3REG == SLJIT_SCRATCH_REG2 || \ - BJ_TMP3REG == SLJIT_SCRATCH_REG3 + BJ_XREG == SLJIT_R0 || \ + BJ_XREG == SLJIT_R1 || \ + BJ_XREG == SLJIT_R2 || \ + BJ_TMP3REG == SLJIT_R0 || \ + BJ_TMP3REG == SLJIT_R1 || \ + BJ_TMP3REG == SLJIT_R2 #error "Not supported assignment of registers." #endif struct sljit_jump *jump; - sljit_si call_reg; + sljit_s32 call_reg; sljit_sw call_off; int status; @@ -674,8 +674,8 @@ emit_cop(struct sljit_compiler *compiler if (hints & BJ_HINT_LDX) { /* save X */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UI, /* uint32_t destination */ - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MOV_U32, + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, reg), BJ_XREG, 0); if (status != SLJIT_SUCCESS) @@ -688,7 +688,7 @@ emit_cop(struct sljit_compiler *compiler } else { /* if (X >= bc->nfuncs) return 0; */ jump = sljit_emit_cmp(compiler, - SLJIT_C_GREATER_EQUAL, + SLJIT_GREATER_EQUAL, BJ_XREG, 0, SLJIT_IMM, bc->nfuncs); if (jump == NULL) @@ -700,7 +700,7 @@ emit_cop(struct sljit_compiler *compiler status = sljit_emit_op1(compiler, SLJIT_MOV_P, BJ_TMP1REG, 0, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, ctx)); if (status != SLJIT_SUCCESS) return status; @@ -737,10 +737,10 @@ emit_cop(struct sljit_compiler *compiler /* * Copy bpf_copfunc_t arguments to registers. */ -#if BJ_AREG != SLJIT_SCRATCH_REG3 +#if BJ_AREG != SLJIT_R2 status = sljit_emit_op1(compiler, - SLJIT_MOV_UI, - SLJIT_SCRATCH_REG3, 0, + SLJIT_MOV_U32, + SLJIT_R2, 0, BJ_AREG, 0); if (status != SLJIT_SUCCESS) return status; @@ -748,15 +748,15 @@ emit_cop(struct sljit_compiler *compiler status = sljit_emit_op1(compiler, SLJIT_MOV_P, - SLJIT_SCRATCH_REG1, 0, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_R0, 0, + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, ctx)); if (status != SLJIT_SUCCESS) return status; status = sljit_emit_op1(compiler, SLJIT_MOV_P, - SLJIT_SCRATCH_REG2, 0, + SLJIT_R1, 0, BJ_ARGS, 0); if (status != SLJIT_SUCCESS) return status; @@ -778,9 +778,9 @@ emit_cop(struct sljit_compiler *compiler if (hints & BJ_HINT_LDX) { /* restore X */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UI, /* uint32_t source */ + SLJIT_MOV_U32, BJ_XREG, 0, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, reg)); if (status != SLJIT_SUCCESS) return status; @@ -805,7 +805,7 @@ emit_pkt_read(struct sljit_compiler *com { int status = SLJIT_ERR_ALLOC_FAILED; uint32_t width; - sljit_si ld_reg; + sljit_s32 ld_reg; struct sljit_jump *jump; #ifdef _KERNEL struct sljit_label *label; @@ -817,7 +817,7 @@ emit_pkt_read(struct sljit_compiler *com #ifdef _KERNEL if (to_mchain_jump == NULL) { to_mchain_jump = sljit_emit_cmp(compiler, - SLJIT_C_EQUAL, + SLJIT_EQUAL, BJ_BUFLEN, 0, SLJIT_IMM, 0); if (to_mchain_jump == NULL) @@ -852,7 +852,7 @@ emit_pkt_read(struct sljit_compiler *com /* if (tmp1 < X) return 0; */ jump = sljit_emit_cmp(compiler, - SLJIT_C_LESS, + SLJIT_LESS, BJ_TMP1REG, 0, BJ_XREG, 0); if (jump == NULL) @@ -897,7 +897,7 @@ emit_pkt_read(struct sljit_compiler *com if (check_zero_buflen) { /* if (buflen != 0) return 0; */ jump = sljit_emit_cmp(compiler, - SLJIT_C_NOT_EQUAL, + SLJIT_NOT_EQUAL, BJ_BUFLEN, 0, SLJIT_IMM, 0); if (jump == NULL) @@ -935,58 +935,58 @@ emit_pkt_read(struct sljit_compiler *com static int emit_memload(struct sljit_compiler *compiler, - sljit_si dst, uint32_t k, size_t extwords) + sljit_s32 dst, uint32_t k, size_t extwords) { int status; - sljit_si src; + sljit_s32 src; sljit_sw srcw; srcw = k * sizeof(uint32_t); if (extwords == 0) { - src = SLJIT_MEM1(SLJIT_LOCALS_REG); + src = SLJIT_MEM1(SLJIT_SP); srcw += offsetof(struct bpfjit_stack, mem); } else { /* copy extmem pointer to the tmp1 register */ status = sljit_emit_op1(compiler, SLJIT_MOV_P, BJ_TMP1REG, 0, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, extmem)); if (status != SLJIT_SUCCESS) return status; src = SLJIT_MEM1(BJ_TMP1REG); } - return sljit_emit_op1(compiler, SLJIT_MOV_UI, dst, 0, src, srcw); + return sljit_emit_op1(compiler, SLJIT_MOV_U32, dst, 0, src, srcw); } static int emit_memstore(struct sljit_compiler *compiler, - sljit_si src, uint32_t k, size_t extwords) + sljit_s32 src, uint32_t k, size_t extwords) { int status; - sljit_si dst; + sljit_s32 dst; sljit_sw dstw; dstw = k * sizeof(uint32_t); if (extwords == 0) { - dst = SLJIT_MEM1(SLJIT_LOCALS_REG); + dst = SLJIT_MEM1(SLJIT_SP); dstw += offsetof(struct bpfjit_stack, mem); } else { /* copy extmem pointer to the tmp1 register */ status = sljit_emit_op1(compiler, SLJIT_MOV_P, BJ_TMP1REG, 0, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, extmem)); if (status != SLJIT_SUCCESS) return status; dst = SLJIT_MEM1(BJ_TMP1REG); } - return sljit_emit_op1(compiler, SLJIT_MOV_UI, dst, dstw, src, 0); + return sljit_emit_op1(compiler, SLJIT_MOV_U32, dst, dstw, src, 0); } /* @@ -1008,7 +1008,7 @@ emit_msh(struct sljit_compiler *compiler #ifdef _KERNEL if (to_mchain_jump == NULL) { to_mchain_jump = sljit_emit_cmp(compiler, - SLJIT_C_EQUAL, + SLJIT_EQUAL, BJ_BUFLEN, 0, SLJIT_IMM, 0); if (to_mchain_jump == NULL) @@ -1018,7 +1018,7 @@ emit_msh(struct sljit_compiler *compiler /* tmp1 = buf[k] */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UB, + SLJIT_MOV_U8, BJ_TMP1REG, 0, SLJIT_MEM1(BJ_BUF), k); if (status != SLJIT_SUCCESS) @@ -1038,7 +1038,7 @@ emit_msh(struct sljit_compiler *compiler if (check_zero_buflen) { /* if (buflen != 0) return 0; */ jump = sljit_emit_cmp(compiler, - SLJIT_C_NOT_EQUAL, + SLJIT_NOT_EQUAL, BJ_BUFLEN, 0, SLJIT_IMM, 0); if (jump == NULL) @@ -1111,7 +1111,7 @@ emit_pow2_moddiv(struct sljit_compiler * if (shift != 0) { status = sljit_emit_op2(compiler, - SLJIT_LSHR|SLJIT_INT_OP, + SLJIT_LSHR|SLJIT_I32_OP, BJ_AREG, 0, BJ_AREG, 0, SLJIT_IMM, shift); @@ -1149,16 +1149,16 @@ emit_moddiv(struct sljit_compiler *compi const bool xreg = BPF_SRC(pc->code) == BPF_X; #if BJ_XREG == SLJIT_RETURN_REG || \ - BJ_XREG == SLJIT_SCRATCH_REG1 || \ - BJ_XREG == SLJIT_SCRATCH_REG2 || \ - BJ_AREG == SLJIT_SCRATCH_REG2 + BJ_XREG == SLJIT_R0 || \ + BJ_XREG == SLJIT_R1 || \ + BJ_AREG == SLJIT_R1 #error "Not supported assignment of registers." #endif -#if BJ_AREG != SLJIT_SCRATCH_REG1 +#if BJ_AREG != SLJIT_R0 status = sljit_emit_op1(compiler, SLJIT_MOV, - SLJIT_SCRATCH_REG1, 0, + SLJIT_R0, 0, BJ_AREG, 0); if (status != SLJIT_SUCCESS) return status; @@ -1166,29 +1166,29 @@ emit_moddiv(struct sljit_compiler *compi status = sljit_emit_op1(compiler, SLJIT_MOV, - SLJIT_SCRATCH_REG2, 0, + SLJIT_R1, 0, xreg ? BJ_XREG : SLJIT_IMM, xreg ? 0 : (uint32_t)pc->k); if (status != SLJIT_SUCCESS) return status; #if defined(BPFJIT_USE_UDIV) - status = sljit_emit_op0(compiler, SLJIT_UDIV|SLJIT_INT_OP); + status = sljit_emit_op0(compiler, SLJIT_UDIV|SLJIT_I32_OP); if (BPF_OP(pc->code) == BPF_DIV) { -#if BJ_AREG != SLJIT_SCRATCH_REG1 +#if BJ_AREG != SLJIT_R0 status = sljit_emit_op1(compiler, SLJIT_MOV, BJ_AREG, 0, - SLJIT_SCRATCH_REG1, 0); + SLJIT_R0, 0); #endif } else { -#if BJ_AREG != SLJIT_SCRATCH_REG2 - /* Remainder is in SLJIT_SCRATCH_REG2. */ +#if BJ_AREG != SLJIT_R1 + /* Remainder is in SLJIT_R1. */ status = sljit_emit_op1(compiler, SLJIT_MOV, BJ_AREG, 0, - SLJIT_SCRATCH_REG2, 0); + SLJIT_R1, 0); #endif } @@ -1602,17 +1602,17 @@ bpf_alu_to_sljit_op(const struct bpf_ins /* * Note: all supported 64bit arches have 32bit multiply - * instruction so SLJIT_INT_OP doesn't have any overhead. + * instruction so SLJIT_I32_OP doesn't have any overhead. */ switch (BPF_OP(pc->code)) { case BPF_ADD: return SLJIT_ADD; case BPF_SUB: return SLJIT_SUB; - case BPF_MUL: return SLJIT_MUL|SLJIT_INT_OP; + case BPF_MUL: return SLJIT_MUL|SLJIT_I32_OP; case BPF_OR: return SLJIT_OR; case BPF_XOR: return SLJIT_XOR; case BPF_AND: return SLJIT_AND; case BPF_LSH: return (k > 31) ? bad : SLJIT_SHL; - case BPF_RSH: return (k > 31) ? bad : SLJIT_LSHR|SLJIT_INT_OP; + case BPF_RSH: return (k > 31) ? bad : SLJIT_LSHR|SLJIT_I32_OP; default: return bad; } @@ -1626,22 +1626,22 @@ bpf_jmp_to_sljit_cond(const struct bpf_i { /* * Note: all supported 64bit arches have 32bit comparison - * instructions so SLJIT_INT_OP doesn't have any overhead. + * instructions so SLJIT_I32_OP doesn't have any overhead. */ - int rv = SLJIT_INT_OP; + int rv = SLJIT_I32_OP; switch (BPF_OP(pc->code)) { case BPF_JGT: - rv |= negate ? SLJIT_C_LESS_EQUAL : SLJIT_C_GREATER; + rv |= negate ? SLJIT_LESS_EQUAL : SLJIT_GREATER; break; case BPF_JGE: - rv |= negate ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL; + rv |= negate ? SLJIT_LESS : SLJIT_GREATER_EQUAL; break; case BPF_JEQ: - rv |= negate ? SLJIT_C_NOT_EQUAL : SLJIT_C_EQUAL; + rv |= negate ? SLJIT_NOT_EQUAL : SLJIT_EQUAL; break; case BPF_JSET: - rv |= negate ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL; + rv |= negate ? SLJIT_EQUAL : SLJIT_NOT_EQUAL; break; default: BJ_ASSERT(false); @@ -1761,7 +1761,7 @@ generate_insn_code(struct sljit_compiler } else if (insn_dat[i].u.rdata.check_length > 0) { /* if (buflen < check_length) return 0; */ jump = sljit_emit_cmp(compiler, - SLJIT_C_LESS, + SLJIT_LESS, BJ_BUFLEN, 0, SLJIT_IMM, insn_dat[i].u.rdata.check_length); @@ -1957,7 +1957,7 @@ generate_insn_code(struct sljit_compiler /* division by zero? */ if (src == BPF_X) { jump = sljit_emit_cmp(compiler, - SLJIT_C_EQUAL|SLJIT_INT_OP, + SLJIT_EQUAL|SLJIT_I32_OP, BJ_XREG, 0, SLJIT_IMM, 0); if (jump == NULL) @@ -2050,7 +2050,7 @@ generate_insn_code(struct sljit_compiler /* BPF_RET+BPF_K accept k bytes */ if (rval == BPF_K) { status = sljit_emit_return(compiler, - SLJIT_MOV_UI, + SLJIT_MOV_U32, SLJIT_IMM, (uint32_t)pc->k); if (status != SLJIT_SUCCESS) goto fail; @@ -2059,7 +2059,7 @@ generate_insn_code(struct sljit_compiler /* BPF_RET+BPF_A accept A bytes */ if (rval == BPF_A) { status = sljit_emit_return(compiler, - SLJIT_MOV_UI, + SLJIT_MOV_U32, BJ_AREG, 0); if (status != SLJIT_SUCCESS) goto fail; @@ -2071,7 +2071,7 @@ generate_insn_code(struct sljit_compiler switch (BPF_MISCOP(pc->code)) { case BPF_TAX: status = sljit_emit_op1(compiler, - SLJIT_MOV_UI, + SLJIT_MOV_U32, BJ_XREG, 0, BJ_AREG, 0); if (status != SLJIT_SUCCESS) @@ -2121,7 +2121,7 @@ generate_insn_code(struct sljit_compiler } status = sljit_emit_return(compiler, - SLJIT_MOV_UI, + SLJIT_MOV_U32, SLJIT_IMM, 0); if (status != SLJIT_SUCCESS) goto fail; @@ -2150,7 +2150,7 @@ bpfjit_generate_code(const bpf_ctx_t *bc bpfjit_hint_t hints; /* memory store location for initial zero initialization */ - sljit_si mem_reg; + sljit_s32 mem_reg; sljit_sw mem_off; struct bpfjit_insn_data *insn_dat; @@ -2176,7 +2176,7 @@ bpfjit_generate_code(const bpf_ctx_t *bc if (!optimize(bc, insns, insn_dat, insn_count, &initmask, &hints)) goto fail; - compiler = sljit_create_compiler(); + compiler = sljit_create_compiler(NULL); if (compiler == NULL) goto fail; @@ -2184,8 +2184,8 @@ bpfjit_generate_code(const bpf_ctx_t *bc sljit_compiler_verbose(compiler, stderr); #endif - status = sljit_emit_enter(compiler, - 2, nscratches(hints), NSAVEDS, sizeof(struct bpfjit_stack)); + status = sljit_emit_enter(compiler, 0, 2, nscratches(hints), + NSAVEDS, 0, 0, sizeof(struct bpfjit_stack)); if (status != SLJIT_SUCCESS) goto fail; @@ -2193,7 +2193,7 @@ bpfjit_generate_code(const bpf_ctx_t *bc /* save ctx argument */ status = sljit_emit_op1(compiler, SLJIT_MOV_P, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, ctx), BJ_CTX_ARG, 0); if (status != SLJIT_SUCCESS) @@ -2201,7 +2201,7 @@ bpfjit_generate_code(const bpf_ctx_t *bc } if (extwords == 0) { - mem_reg = SLJIT_MEM1(SLJIT_LOCALS_REG); + mem_reg = SLJIT_MEM1(SLJIT_SP); mem_off = offsetof(struct bpfjit_stack, mem); } else { /* copy "mem" argument from bpf_args to bpfjit_stack */ @@ -2214,7 +2214,7 @@ bpfjit_generate_code(const bpf_ctx_t *bc status = sljit_emit_op1(compiler, SLJIT_MOV_P, - SLJIT_MEM1(SLJIT_LOCALS_REG), + SLJIT_MEM1(SLJIT_SP), offsetof(struct bpfjit_stack, extmem), BJ_TMP1REG, 0); if (status != SLJIT_SUCCESS) @@ -2239,7 +2239,7 @@ bpfjit_generate_code(const bpf_ctx_t *bc if (initmask & BJ_INIT_MBIT(i)) { /* M[i] = 0; */ status = sljit_emit_op1(compiler, - SLJIT_MOV_UI, + SLJIT_MOV_U32, mem_reg, mem_off + i * sizeof(uint32_t), SLJIT_IMM, 0); if (status != SLJIT_SUCCESS)