diff options
| author | Jiong Wang <jiong.wang@netronome.com> | 2019-01-26 12:26:13 -0500 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2019-01-26 16:33:02 -0500 |
| commit | 6ea848b5ced53cbfd5677ff176c2aca10fd61bf4 (patch) | |
| tree | b362dbebfb60ce4b7a9ba03bc10ea7f8f7ed26fb /samples | |
| parent | 461448398ac104b014530680dbac09e577cd2695 (diff) | |
selftests: bpf: functional and min/max reasoning unit tests for JMP32
This patch adds unit tests for new JMP32 instructions.
This patch also added the new BPF_JMP32_REG and BPF_JMP32_IMM macros to
samples/bpf/bpf_insn.h so that JMP32 insn builders are available to tests
under 'samples' directory.
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'samples')
| -rw-r--r-- | samples/bpf/bpf_insn.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/samples/bpf/bpf_insn.h b/samples/bpf/bpf_insn.h index 20dc5cefec84..544237980582 100644 --- a/samples/bpf/bpf_insn.h +++ b/samples/bpf/bpf_insn.h | |||
| @@ -164,6 +164,16 @@ struct bpf_insn; | |||
| 164 | .off = OFF, \ | 164 | .off = OFF, \ |
| 165 | .imm = 0 }) | 165 | .imm = 0 }) |
| 166 | 166 | ||
| 167 | /* Like BPF_JMP_REG, but with 32-bit wide operands for comparison. */ | ||
| 168 | |||
| 169 | #define BPF_JMP32_REG(OP, DST, SRC, OFF) \ | ||
| 170 | ((struct bpf_insn) { \ | ||
| 171 | .code = BPF_JMP32 | BPF_OP(OP) | BPF_X, \ | ||
| 172 | .dst_reg = DST, \ | ||
| 173 | .src_reg = SRC, \ | ||
| 174 | .off = OFF, \ | ||
| 175 | .imm = 0 }) | ||
| 176 | |||
| 167 | /* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ | 177 | /* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ |
| 168 | 178 | ||
| 169 | #define BPF_JMP_IMM(OP, DST, IMM, OFF) \ | 179 | #define BPF_JMP_IMM(OP, DST, IMM, OFF) \ |
| @@ -174,6 +184,16 @@ struct bpf_insn; | |||
| 174 | .off = OFF, \ | 184 | .off = OFF, \ |
| 175 | .imm = IMM }) | 185 | .imm = IMM }) |
| 176 | 186 | ||
| 187 | /* Like BPF_JMP_IMM, but with 32-bit wide operands for comparison. */ | ||
| 188 | |||
| 189 | #define BPF_JMP32_IMM(OP, DST, IMM, OFF) \ | ||
| 190 | ((struct bpf_insn) { \ | ||
| 191 | .code = BPF_JMP32 | BPF_OP(OP) | BPF_K, \ | ||
| 192 | .dst_reg = DST, \ | ||
| 193 | .src_reg = 0, \ | ||
| 194 | .off = OFF, \ | ||
| 195 | .imm = IMM }) | ||
| 196 | |||
| 177 | /* Raw code statement block */ | 197 | /* Raw code statement block */ |
| 178 | 198 | ||
| 179 | #define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \ | 199 | #define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \ |
