[DTrace-devel] [PATCH] Switch ALU instruction to fit a signed 32-bit IMM
Kris Van Hees
kris.van.hees at oracle.com
Mon Aug 21 22:44:13 UTC 2023
On Thu, Aug 10, 2023 at 01:47:42PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> ALU instructions take a signed 32-bit IMM. Strictly speaking,
> 0xffffffff overflows it. Switch to -1 to be safe.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-byb: Kris Van Hees <kris.van.hees at oracle.com>
... but I would suggest you change the subject. You are not really switching
ALU instructions (it is still an AND) - you are just adjusting the immediate
operand because the instruction ex[ects a signed 32-bit IMM value. So perhaps
make it:
Fix overflow in immediate operand to 'and'
> ---
> bpf/index.S | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bpf/index.S b/bpf/index.S
> index f64a24dd..c8b1d7cd 100644
> --- a/bpf/index.S
> +++ b/bpf/index.S
> @@ -36,7 +36,7 @@
> * // perfect match any mismatches
> * // == 0 != 0
> * r0 |= (r0 >> 32); // == 0 != 0
> - * r0 &= 0xffffffff; // == 0 > 0
> + * r0 &= -1; // == 0 > 0
> * r0 -= 1; // < 0 >= 0
> * r0 >>= 63; // == 1 == 0
> *
> @@ -69,7 +69,7 @@ dt_index_match:
> mov %r4, %r0
> rsh %r4, 32
> or %r0, %r4
> - and %r0, 0xffffffff
> + and %r0, -1
> sub %r0, 1
> rsh %r0, 63
>
> --
> 2.18.4
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list