Alan-Jowett / bpf_conformance

Measures the conformance of a BPF runtime to the ISA.
Other
27 stars 14 forks source link

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

Closed qsr closed 5 months ago

qsr commented 7 months ago

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.

Alan-Jowett commented 5 months ago

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

Alan-Jowett commented 5 months ago

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).