ebpf-verifier icon indicating copy to clipboard operation
ebpf-verifier copied to clipboard

Add other atomic instructions

Open dthaler opened this issue 1 year ago • 1 comments

  • Add the rest of the atomic instructions defined in https://www.ietf.org/archive/id/draft-ietf-bpf-isa-00.html#name-atomic-operations
  • Add various test cases in atomic.yaml
  • Replace uses of (INST_MEM << 5) etc. with the more readable and less bug-prone INST_MODE_MEM.
  • Make the atomic operation conformance tests (all of which do operations on stack memory not shared memory) pass
  • The CMPXCHG instruction is still not as precise as it could be. Improving its precision is left for future work (filed issue #566 to track this issue where a number of conformance tests give TOP or a RANGE instead of the exact value)

Fixes #483

dthaler avatar Jan 04 '24 19:01 dthaler

Coverage Status

coverage: 90.322% (-0.02%) from 90.344% when pulling e96578fe6c0fd15f812f00478bcc1c0feb2532ae on dthaler:atomics into fe59c86c51091f5449409c2326eae7d257d36277 on vbpf:main.

coveralls avatar Jan 04 '24 20:01 coveralls

I'm probably missing something, but aren't the instructions atomic because they change memory regions that are already volatile?

elazarg avatar Mar 05 '24 17:03 elazarg

I'm probably missing something, but aren't the instructions atomic because they change memory regions that are already volatile?

Apparently atomic operations can also work on stack memory. Not that you need atomic operations for them, but if you do them they shouldn't fail verification per se (and don't on Linux).

dthaler avatar Mar 05 '24 23:03 dthaler

Looks good in general. See my question about the choice of fields though.

I think I've now made changes according to all your comments. Please re-review. Thanks!

dthaler avatar Mar 14 '24 20:03 dthaler