ubpf
ubpf copied to clipboard
Fix atomic alu with fetch
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 inubpf/disassembler.py
. This includes handling various atomic opcodes and generating appropriate assembly instructions.
JIT Compiler Improvements:
- Updated
emit_atomic_fetch_alu
invm/ubpf_jit_x86_64.c
to handle cases where the source register isRAX
by saving the original value in eitherR10
orR11
. This ensures the atomic compare-exchange instruction does not overwrite the source register. - Modified
emit_atomic_xor32
andemit_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.