[igt-dev] [PATCH i-g-t 1/2] lib: Beware implicit sign extension on large constants
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Tue Jun 22 03:00:43 UTC 2021
On Mon, Jun 21, 2021 at 12:59:21PM +0200, Zbigniew Kempczyński wrote:
> From: Chris Wilson <chris.p.wilson at intel.com>
>
> (gdb) p/x (long long unsigned int)(1 << 31)
> $1 = 0xffffffff80000000
> (gdb) p/x (long long unsigned int)(1u << 31)
> $2 = 0x80000000
>
> The impact of this is that the random address we were placing the spinner
> at was always invalid on modern machines, causing the kernel to relocate
> the spinners wherever and thus undergoing relocations.
>
> Signed-off-by: Chris Wilson <chris.p.wilson at intel.com>
We have same observation and we want to fix that.
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
--
Zbigniew
> ---
> 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..63b1fc73b 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 = 1u << 31;
> addr += random() % addr / 2;
> addr &= -4096;
>
> --
> 2.26.0
>
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
More information about the igt-dev
mailing list