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
This commit is contained in:
Richard Henderson 2019-03-13 11:21:02 -04:00 committed by Lioncash
parent fcb49bb6f6
commit 4111a3a892
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -756,6 +756,8 @@ def parse_generic(lineno, is_format, name, toks):
sign = True sign = True
flen = flen[1:] flen = flen[1:]
shift = int(flen, 10) shift = int(flen, 10)
if shift + width > insnwidth:
error(lineno, 'field {0} exceeds insnwidth'.format(fname))
f = Field(sign, insnwidth - width - shift, shift) f = Field(sign, insnwidth - width - shift, shift)
flds = add_field(lineno, flds, fname, f) flds = add_field(lineno, flds, fname, f)
fixedbits <<= shift fixedbits <<= shift