Truncate all ALU32 except for byte swap #454
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #452
This pull request primarily focuses on modifications to the
ubpf_vm
package, specifically thetranslate
function inubpf_jit_x86_64.c
and theubpf_exec
function inubpf_vm.c
. The changes are centered around the handling of ALU32 instructions. In both functions, additional code has been added to check if an instruction is an ALU32 instruction and perform certain operations if it is.Here are the key changes:
vm/ubpf_jit_x86_64.c
: In thetranslate
function, a check has been added to identify if an instruction is an ALU32 instruction. If it is, the target register is truncated to 32 bits using theemit_truncate_u32
function.vm/ubpf_vm.c
: Similar to thetranslate
function, theubpf_exec
function now checks if an instruction is an ALU32 instruction. If it is, the destination register (inst.dst
) is bitwise ANDed withUINT32_MAX
to ensure it only retains the lower 32 bits of the value.