[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/12] decodetree: Properly diagnose fields overflowi
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PULL 12/12] decodetree: Properly diagnose fields overflowing an insn |
Date: |
Tue, 12 Mar 2019 10:03:34 -0700 |
Previously this would result in an exception for shifting
the field mask by a negative number.
Signed-off-by: Richard Henderson <address@hidden>
---
scripts/decodetree.py | 2 ++
tests/decode/err_width1.decode | 5 +++++
tests/decode/err_width2.decode | 5 +++++
tests/decode/err_width3.decode | 5 +++++
tests/decode/err_width4.decode | 5 +++++
5 files changed, 22 insertions(+)
create mode 100644 tests/decode/err_width1.decode
create mode 100644 tests/decode/err_width2.decode
create mode 100644 tests/decode/err_width3.decode
create mode 100644 tests/decode/err_width4.decode
diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index ac158b42d0..aa790b596a 100755
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -622,6 +622,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
diff --git a/tests/decode/err_width1.decode b/tests/decode/err_width1.decode
new file mode 100644
index 0000000000..0c14f6d73b
--- /dev/null
+++ b/tests/decode/err_width1.decode
@@ -0,0 +1,5 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose too many bits (33 of 32)
+one 000000000000000000000000000000000
diff --git a/tests/decode/err_width2.decode b/tests/decode/err_width2.decode
new file mode 100644
index 0000000000..47f0acf322
--- /dev/null
+++ b/tests/decode/err_width2.decode
@@ -0,0 +1,5 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose too few bits (31 of 32)
+one 0000000000000000000000000000000
diff --git a/tests/decode/err_width3.decode b/tests/decode/err_width3.decode
new file mode 100644
index 0000000000..c5fb6b3699
--- /dev/null
+++ b/tests/decode/err_width3.decode
@@ -0,0 +1,5 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose too many bits (33 of 32)
+one 0 s:32
diff --git a/tests/decode/err_width4.decode b/tests/decode/err_width4.decode
new file mode 100644
index 0000000000..1588a63698
--- /dev/null
+++ b/tests/decode/err_width4.decode
@@ -0,0 +1,5 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose too few bits (31 of 32)
+one 0 s:30
--
2.17.2
- [Qemu-devel] [PULL 00/12] decodetree patches, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 11/12] decodetree: Prefix extract function names with decode_function, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 10/12] decodetree: Allow +- to begin a number initializing a field, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 12/12] decodetree: Properly diagnose fields overflowing an insn,
Richard Henderson <=
- [Qemu-devel] [PULL 07/12] test/decode: Add tests for PatternGroups, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 09/12] decodetree: Produce clean output for an empty input file, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 08/12] decodetree: Add --static-decode option, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 04/12] decodetree: Ensure build_tree does not include values outside insnmask, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 05/12] decodetree: Do not unconditionaly return from Pattern.output_code, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 06/12] decodetree: Allow grouping of overlapping patterns, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 03/12] decodetree: Document the usefulness of argument sets, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 01/12] MAINTAINERS: Add scripts/decodetree.py to the TCG section, Richard Henderson, 2019/03/12
- [Qemu-devel] [PULL 02/12] decodetree: Move documentation to docs/devel/decodetree.rst, Richard Henderson, 2019/03/12
- Re: [Qemu-devel] [PULL 00/12] decodetree patches, Peter Maydell, 2019/03/13