On Fri, 2018-01-12 at 18:59 -0800, Alexei Starovoitov wrote: > due to some JITs doing if (src_reg == 0) check in 64-bit mode > for div/mod opreations mask upper 32-bits of src register > before doing the check >
Is the plan to fix JIT, and if they can all be fixed, revert this patch ? x86 patch would be something like : diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 87f214fbe66ec163d24b12b6defc7edab612ecc9..91e4ab69573e09f793eb1c1e29d1b5ffad1d5dc7 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -548,8 +548,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, if (BPF_SRC(insn->code) == BPF_X) { /* if (src_reg == 0) return 0 */ - /* cmp r11, 0 */ - EMIT4(0x49, 0x83, 0xFB, 0x00); + if (BPF_CLASS(insn->code) == BPF_ALU64) { + /* cmp r11, 0 */ + EMIT4(0x49, 0x83, 0xFB, 0x00); + } else { + /* cmp r11d, 0 */ + EMIT4(0x41, 0x83, 0xFB, 0x00); + } /* jne .+9 (skip over pop, pop, xor and jmp) */ EMIT2(X86_JNE, 1 + 1 + 2 + 5);