On Tue, Oct 4, 2022 at 9:36 AM Dave Thaler <dthaler@xxxxxxxxxxxxx> wrote: > > Those differences are in signed div/mod only, right? > > Unsigned div/mod doesn't have it, right? > > bpf has only unsigned div/mod. > > Ah right, will replace. However since imm is a signed integer, that leaves > an ambiguity that is important to clarify. > > What is the expected value for the following 64-bit BPF_DIV operation: > r0 = 0xFFFFFFFFFFFFFFFF > r0 /= -10 > Is it 0x1 or 0x10000000a? i.e., is the -10 sign extended to > 0xFFFFFFFFFFFFFFF6 or treated as 0xFFFFFFF6 when doing the unsigned > division? x86 and arm64 JITs treat it as imm32 is zero extended. But looking at the interpreter: ALU64_DIV_K: DST = div64_u64(DST, IMM); it looks like we have a bug there. But we have a bunch of div_k tests in lib/test_bpf.c including negative imm32. Hmm.