[igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fix undefined behavior in bitshift
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Mon Jun 21 03:00:10 UTC 2021
As a part of rewriting tests to use no-reloc I was a little bit
surprised addr calculation on my SKL box lead to some strange
offsets which finally use relocations instead. At first glance
I wasn't able to spot it, debugging reveals:
if (addr >> 31)
addr = 1 << 31;
gives addr == ffffffff80000000
what is not address we want to use as an argument to modulo.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>
---
lib/igt_dummyload.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 82459e524..fc55be15b 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -119,7 +119,7 @@ emit_recursive_batch(igt_spin_t *spin,
*/
addr = gem_aperture_size(fd) / 2;
if (addr >> 31)
- addr = 1 << 31;
+ addr = 1ULL << 31;
addr += random() % addr / 2;
addr &= -4096;
--
2.26.0
More information about the igt-dev
mailing list