Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qsr opened this issue Apr 3, 2024 · 2 comments · Fixed by #258
Closed

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

qsr opened this issue Apr 3, 2024 · 2 comments · Fixed by #258

Comments

@qsr
Copy link
Contributor

qsr commented Apr 3, 2024

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
Copy link
Owner

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

@Alan-Jowett
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants