[DTrace-devel] [PATCH] Switch ALU instruction to fit a signed 32-bit IMM

eugene.loh at oracle.com eugene.loh at oracle.com
Thu Aug 10 17:47:42 UTC 2023


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>
---
 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




More information about the DTrace-devel mailing list