All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fix undefined behavior in bitshift
@ 2021-06-21  3:00 Zbigniew Kempczyński
  2021-06-21  3:34 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
  2021-06-21  4:32 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  0 siblings, 2 replies; 4+ messages in thread
From: Zbigniew Kempczyński @ 2021-06-21  3:00 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

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@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-21  6:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21  3:00 [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fix undefined behavior in bitshift Zbigniew Kempczyński
2021-06-21  3:34 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2021-06-21  4:32 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-06-21  6:33   ` Zbigniew Kempczyński

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.