Commit 18423550 authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

bpf, sparc64: implement jiting of BPF_J{LT, LE, SLT, SLE}

This work implements jiting of BPF_J{LT,LE,SLT,SLE} instructions
with BPF_X/BPF_K variants for the sparc64 eBPF JIT.
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c362b2f3
...@@ -128,6 +128,8 @@ static u32 WDISP10(u32 off) ...@@ -128,6 +128,8 @@ static u32 WDISP10(u32 off)
#define BA (BRANCH | CONDA) #define BA (BRANCH | CONDA)
#define BG (BRANCH | CONDG) #define BG (BRANCH | CONDG)
#define BL (BRANCH | CONDL)
#define BLE (BRANCH | CONDLE)
#define BGU (BRANCH | CONDGU) #define BGU (BRANCH | CONDGU)
#define BLEU (BRANCH | CONDLEU) #define BLEU (BRANCH | CONDLEU)
#define BGE (BRANCH | CONDGE) #define BGE (BRANCH | CONDGE)
...@@ -715,9 +717,15 @@ static int emit_compare_and_branch(const u8 code, const u8 dst, u8 src, ...@@ -715,9 +717,15 @@ static int emit_compare_and_branch(const u8 code, const u8 dst, u8 src,
case BPF_JGT: case BPF_JGT:
br_opcode = BGU; br_opcode = BGU;
break; break;
case BPF_JLT:
br_opcode = BLU;
break;
case BPF_JGE: case BPF_JGE:
br_opcode = BGEU; br_opcode = BGEU;
break; break;
case BPF_JLE:
br_opcode = BLEU;
break;
case BPF_JSET: case BPF_JSET:
case BPF_JNE: case BPF_JNE:
br_opcode = BNE; br_opcode = BNE;
...@@ -725,9 +733,15 @@ static int emit_compare_and_branch(const u8 code, const u8 dst, u8 src, ...@@ -725,9 +733,15 @@ static int emit_compare_and_branch(const u8 code, const u8 dst, u8 src,
case BPF_JSGT: case BPF_JSGT:
br_opcode = BG; br_opcode = BG;
break; break;
case BPF_JSLT:
br_opcode = BL;
break;
case BPF_JSGE: case BPF_JSGE:
br_opcode = BGE; br_opcode = BGE;
break; break;
case BPF_JSLE:
br_opcode = BLE;
break;
default: default:
/* Make sure we dont leak kernel information to the /* Make sure we dont leak kernel information to the
* user. * user.
...@@ -746,18 +760,30 @@ static int emit_compare_and_branch(const u8 code, const u8 dst, u8 src, ...@@ -746,18 +760,30 @@ static int emit_compare_and_branch(const u8 code, const u8 dst, u8 src,
case BPF_JGT: case BPF_JGT:
cbcond_opcode = CBCONDGU; cbcond_opcode = CBCONDGU;
break; break;
case BPF_JLT:
cbcond_opcode = CBCONDLU;
break;
case BPF_JGE: case BPF_JGE:
cbcond_opcode = CBCONDGEU; cbcond_opcode = CBCONDGEU;
break; break;
case BPF_JLE:
cbcond_opcode = CBCONDLEU;
break;
case BPF_JNE: case BPF_JNE:
cbcond_opcode = CBCONDNE; cbcond_opcode = CBCONDNE;
break; break;
case BPF_JSGT: case BPF_JSGT:
cbcond_opcode = CBCONDG; cbcond_opcode = CBCONDG;
break; break;
case BPF_JSLT:
cbcond_opcode = CBCONDL;
break;
case BPF_JSGE: case BPF_JSGE:
cbcond_opcode = CBCONDGE; cbcond_opcode = CBCONDGE;
break; break;
case BPF_JSLE:
cbcond_opcode = CBCONDLE;
break;
default: default:
/* Make sure we dont leak kernel information to the /* Make sure we dont leak kernel information to the
* user. * user.
...@@ -1176,10 +1202,14 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx) ...@@ -1176,10 +1202,14 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
/* IF (dst COND src) JUMP off */ /* IF (dst COND src) JUMP off */
case BPF_JMP | BPF_JEQ | BPF_X: case BPF_JMP | BPF_JEQ | BPF_X:
case BPF_JMP | BPF_JGT | BPF_X: case BPF_JMP | BPF_JGT | BPF_X:
case BPF_JMP | BPF_JLT | BPF_X:
case BPF_JMP | BPF_JGE | BPF_X: case BPF_JMP | BPF_JGE | BPF_X:
case BPF_JMP | BPF_JLE | BPF_X:
case BPF_JMP | BPF_JNE | BPF_X: case BPF_JMP | BPF_JNE | BPF_X:
case BPF_JMP | BPF_JSGT | BPF_X: case BPF_JMP | BPF_JSGT | BPF_X:
case BPF_JMP | BPF_JSLT | BPF_X:
case BPF_JMP | BPF_JSGE | BPF_X: case BPF_JMP | BPF_JSGE | BPF_X:
case BPF_JMP | BPF_JSLE | BPF_X:
case BPF_JMP | BPF_JSET | BPF_X: { case BPF_JMP | BPF_JSET | BPF_X: {
int err; int err;
...@@ -1191,10 +1221,14 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx) ...@@ -1191,10 +1221,14 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
/* IF (dst COND imm) JUMP off */ /* IF (dst COND imm) JUMP off */
case BPF_JMP | BPF_JEQ | BPF_K: case BPF_JMP | BPF_JEQ | BPF_K:
case BPF_JMP | BPF_JGT | BPF_K: case BPF_JMP | BPF_JGT | BPF_K:
case BPF_JMP | BPF_JLT | BPF_K:
case BPF_JMP | BPF_JGE | BPF_K: case BPF_JMP | BPF_JGE | BPF_K:
case BPF_JMP | BPF_JLE | BPF_K:
case BPF_JMP | BPF_JNE | BPF_K: case BPF_JMP | BPF_JNE | BPF_K:
case BPF_JMP | BPF_JSGT | BPF_K: case BPF_JMP | BPF_JSGT | BPF_K:
case BPF_JMP | BPF_JSLT | BPF_K:
case BPF_JMP | BPF_JSGE | BPF_K: case BPF_JMP | BPF_JSGE | BPF_K:
case BPF_JMP | BPF_JSLE | BPF_K:
case BPF_JMP | BPF_JSET | BPF_K: { case BPF_JMP | BPF_JSET | BPF_K: {
int err; int err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment