From 4111a3a89280c9a0b993393baa2b89f667eac427 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 13 Mar 2019 11:21:02 -0400 Subject: [PATCH] decodetree: Properly diagnose fields overflowing an insn Previously this would result in an exception for shifting the field mask by a negative number. Backports commit 2decfc95583dc28add69810eaca6ada7b4b44d3a from qemu --- qemu/scripts/decodetree.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qemu/scripts/decodetree.py b/qemu/scripts/decodetree.py index 0006a979..195d86ed 100644 --- a/qemu/scripts/decodetree.py +++ b/qemu/scripts/decodetree.py @@ -756,6 +756,8 @@ def parse_generic(lineno, is_format, name, toks): sign = True flen = flen[1:] shift = int(flen, 10) + if shift + width > insnwidth: + error(lineno, 'field {0} exceeds insnwidth'.format(fname)) f = Field(sign, insnwidth - width - shift, shift) flds = add_field(lineno, flds, fname, f) fixedbits <<= shift