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

Follow-up for masks on shift operations #105

Merged
merged 2 commits into from
Mar 15, 2024
Merged

Follow-up for masks on shift operations #105

merged 2 commits into from
Mar 15, 2024

Commits on Mar 15, 2024

  1. tests/ubpf_vm.rs: Add tests for arsh offset masking

    Add tests to make sure we handle the masking of the value (in the source
    register or as an immediate) telling by how many bits the value in the
    destination register should be shifted.
    
    The context is that we used to do no masking on this value, but the BPF
    ISA specification does require one, and the kernel implements it when
    the value is passed in the source register (and rejects immediates that
    it deems invalid).
    
    Signed-off-by: Quentin Monnet <qmo@qmon.net>
    qmonnet committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    7e9f2e1 View commit details
    Browse the repository at this point in the history
  2. src/interpreter: Remove/explain masks for 32-bit shift operations

    We recently fixed the 64-bit arithmetic shift-right operations by adding
    a mask to the number of bits (as immediates or from the source register)
    by which to shift, as per the eBPF ISA specification. The 32-bit
    operations must use the same mask, but .wrapping_shr() already takes
    care of it for us. Let's add a comment to make it explicit.
    
    As it turns out, masking is just as well unnecessary for the
    non-arithmetic left-right shift operations that we tried to fix
    recently. Let's also remove the mask there.
    
    Signed-off-by: Quentin Monnet <qmo@qmon.net>
    qmonnet committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    19a2be8 View commit details
    Browse the repository at this point in the history