Alan-Jowett/bpf_conformance

Tests seems to imply that xchg and xchg32 stores the old value in r0

Closed this issue · 2 comments

qsr commented

Both xchg tests check that the value is store in r0 after the atomic exchange. I cannot see any place in the ebpf spec that implies this. The value is supposed to be exchange with the src register.

Good point. I think only the CMPXCHG is supposed to do that per the IETF BPF ISA doc.

Thanks for catching this. The issue is that the test was setting %r0 to 0 at the start of the test and then checking that it was zero to determine success. If the first check fails, it would exit early, leaving %r0 as 0, marking it as passed. The fix is to set %r0 to 1 (or any non-zero value at the start).