ubpf icon indicating copy to clipboard operation
ubpf copied to clipboard

Fix atomic alu with fetch

Open Alan-Jowett opened this issue 5 months ago • 5 comments

This pull request introduces support for atomic operations in the disassembler and improves the handling of atomic compare-exchange instructions in the JIT compiler. The most important changes include handling atomic operations in the disassembler, saving the original value of the source register in the JIT compiler, and ensuring atomic compare-exchange instructions are correctly implemented.

Disassembler Enhancements:

  • Added support for atomic operations in the disassemble_one function in ubpf/disassembler.py. This includes handling various atomic opcodes and generating appropriate assembly instructions.

JIT Compiler Improvements:

  • Updated emit_atomic_fetch_alu in vm/ubpf_jit_x86_64.c to handle cases where the source register is RAX by saving the original value in either R10 or R11. This ensures the atomic compare-exchange instruction does not overwrite the source register.
  • Modified emit_atomic_xor32 and emit_atomic_compare_exchange32 to remove unnecessary blank lines, improving code readability. [1] [2]
  • Cleaned up the translate function by removing extra blank lines for better code clarity.

Alan-Jowett avatar Sep 11 '24 16:09 Alan-Jowett