Module Name: src
Committed By: msaitoh
Date: Wed Oct 16 01:44:48 UTC 2019
Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: r600d.h rv770d.h
src/sys/external/bsd/drm2/dist/include/drm: drm_fixed.h
Log Message:
Use unsigned to avoid undefined behavior. Found by kUBSan.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/dist/drm/radeon/r600d.h
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/radeon/rv770d.h
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/include/drm/drm_fixed.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/dist/drm/radeon/r600d.h
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/r600d.h:1.3 src/sys/external/bsd/drm2/dist/drm/radeon/r600d.h:1.4
--- src/sys/external/bsd/drm2/dist/drm/radeon/r600d.h:1.3 Sat Aug 17 15:50:05 2019
+++ src/sys/external/bsd/drm2/dist/drm/radeon/r600d.h Wed Oct 16 01:44:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: r600d.h,v 1.3 2019/08/17 15:50:05 msaitoh Exp $ */
+/* $NetBSD: r600d.h,v 1.4 2019/10/16 01:44:48 msaitoh Exp $ */
/*
* Copyright 2009 Advanced Micro Devices, Inc.
@@ -644,7 +644,7 @@
#define DMA_MODE 0xd0bc
/* async DMA packets */
-#define DMA_PACKET(cmd, t, s, n) ((((cmd) & 0xF) << 28) | \
+#define DMA_PACKET(cmd, t, s, n) ((((u32)(cmd) & 0xF) << 28) | \
(((t) & 0x1) << 23) | \
(((s) & 0x1) << 22) | \
(((n) & 0xFFFF) << 0))
Index: src/sys/external/bsd/drm2/dist/drm/radeon/rv770d.h
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/rv770d.h:1.2 src/sys/external/bsd/drm2/dist/drm/radeon/rv770d.h:1.3
--- src/sys/external/bsd/drm2/dist/drm/radeon/rv770d.h:1.2 Mon Aug 27 04:58:36 2018
+++ src/sys/external/bsd/drm2/dist/drm/radeon/rv770d.h Wed Oct 16 01:44:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rv770d.h,v 1.2 2018/08/27 04:58:36 riastradh Exp $ */
+/* $NetBSD: rv770d.h,v 1.3 2019/10/16 01:44:48 msaitoh Exp $ */
/*
* Copyright 2009 Advanced Micro Devices, Inc.
@@ -563,7 +563,7 @@
#define SQ_DYN_GPR_SIZE_SIMD_AB_5 0x8DC4
#define SQ_DYN_GPR_SIZE_SIMD_AB_6 0x8DC8
#define SQ_DYN_GPR_SIZE_SIMD_AB_7 0x8DCC
-#define ES_PRIO(x) ((x) << 30)
+#define ES_PRIO(x) ((u32)(x) << 30)
#define SQ_GPR_RESOURCE_MGMT_1 0x8C04
#define NUM_PS_GPRS(x) ((x) << 0)
#define NUM_VS_GPRS(x) ((x) << 16)
@@ -661,7 +661,7 @@
#define DMA_RB_WPTR 0xd00c
/* async DMA packets */
-#define DMA_PACKET(cmd, t, s, n) ((((cmd) & 0xF) << 28) | \
+#define DMA_PACKET(cmd, t, s, n) ((((u32)(cmd) & 0xF) << 28) | \
(((t) & 0x1) << 23) | \
(((s) & 0x1) << 22) | \
(((n) & 0xFFFF) << 0))
Index: src/sys/external/bsd/drm2/dist/include/drm/drm_fixed.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drm_fixed.h:1.2 src/sys/external/bsd/drm2/dist/include/drm/drm_fixed.h:1.3
--- src/sys/external/bsd/drm2/dist/include/drm/drm_fixed.h:1.2 Mon Aug 27 04:58:37 2018
+++ src/sys/external/bsd/drm2/dist/include/drm/drm_fixed.h Wed Oct 16 01:44:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_fixed.h,v 1.2 2018/08/27 04:58:37 riastradh Exp $ */
+/* $NetBSD: drm_fixed.h,v 1.3 2019/10/16 01:44:48 msaitoh Exp $ */
/*
* Copyright 2009 Red Hat Inc.
@@ -34,7 +34,7 @@ typedef union dfixed {
} fixed20_12;
-#define dfixed_const(A) (u32)(((A) << 12))/* + ((B + 0.000122)*4096)) */
+#define dfixed_const(A) (((u32)(A) << 12))/* + ((B + 0.000122)*4096)) */
#define dfixed_const_half(A) (u32)(((A) << 12) + 2048)
#define dfixed_const_666(A) (u32)(((A) << 12) + 2731)
#define dfixed_const_8(A) (u32)(((A) << 12) + 3277)