summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-12-01 14:26:46 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-12-01 14:31:34 +0000
commit9c2c485df9fd39ae36779f765a892e36835a8001 (patch)
treed97d55b91504b59aa19a27d6497984c60aab9a96 /src
parent263d10998617ba935179942d2440a1607cd3c21c (diff)
sna: Validate that the reg/insn size is well defined
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/sna/brw/brw_eu_emit.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/sna/brw/brw_eu_emit.c b/src/sna/brw/brw_eu_emit.c
index 5c0b3065..00c984d9 100644
--- a/src/sna/brw/brw_eu_emit.c
+++ b/src/sna/brw/brw_eu_emit.c
@@ -34,6 +34,8 @@
#include <string.h>
#include <stdlib.h>
+#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
+
/***********************************************************************
* Internal helper for constructing instructions
*/
@@ -179,6 +181,11 @@ validate_reg(struct brw_instruction *insn, struct brw_reg reg)
reg.file == BRW_ARF_NULL)
return;
+ assert(reg.hstride >= 0 && reg.hstride < ARRAY_SIZE(hstride_for_reg));
+ assert(reg.vstride >= 0 && reg.vstride < ARRAY_SIZE(vstride_for_reg));
+ assert(reg.width >= 0 && reg.width < ARRAY_SIZE(width_for_reg));
+ assert(insn->header.execution_size >= 0 && insn->header.execution_size < ARRAY_SIZE(execsize_for_reg));
+
hstride = hstride_for_reg[reg.hstride];
if (reg.vstride == 0xf) {