aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2024-03-17 02:44:57 +0000
committeriximeow <me@iximeow.net>2024-03-17 02:44:57 +0000
commita91c1c50a39ff68a7e73cef70829e8a5b08b4b6b (patch)
tree6fa88baec038e8cb43d4f349d627a12df51df1db
parent79d220ce177833f7dd80e15e1094bbfbf4c6f8b1 (diff)
be more explicit about undefined system instructions being invalid
-rw-r--r--differential-tests/tests/capstone-differential.rs9
-rw-r--r--src/armv8/a64.rs6
-rw-r--r--tests/armv8/a64.rs5
3 files changed, 19 insertions, 1 deletions
diff --git a/differential-tests/tests/capstone-differential.rs b/differential-tests/tests/capstone-differential.rs
index 3db6fdd..cbed59f 100644
--- a/differential-tests/tests/capstone-differential.rs
+++ b/differential-tests/tests/capstone-differential.rs
@@ -368,7 +368,14 @@ fn capstone_differential() {
stats.missed_incomplete.fetch_add(1, Ordering::SeqCst);
continue;
} else {
- panic!("yax errored where capstone succeeded. cs text: '{}', bytes: {:x?}", cs_text, bytes);
+ // capstone dedodes the UNDEFINED encodings in C5.1.2 as "mrs", yax returns
+ // a decode error.
+ if cs_text.starts_with("mrs ") {
+ stats.yax_reject.fetch_add(1, Ordering::SeqCst);
+ continue;
+ } else {
+ panic!("yax errored where capstone succeeded. cs text: '{}', bytes: {:x?}", cs_text, bytes);
+ }
};
fn acceptable_match(yax_text: &str, cs_text: &str) -> bool {
diff --git a/src/armv8/a64.rs b/src/armv8/a64.rs
index 19440ba..a228027 100644
--- a/src/armv8/a64.rs
+++ b/src/armv8/a64.rs
@@ -10454,7 +10454,12 @@ impl Decoder<ARMv8> for InstDecoder {
];
}
0b100 => {
+ // quote C5.1.2:
+ // All encodings with L==1 and op0==0b0x are UNDEFINED, except
+ // for encodings in the area reserved for IMPLEMENTATION
+ // DEFINED use
inst.opcode = Opcode::Invalid;
+ return Err(DecodeError::InvalidOpcode);
}
0b101 => {
let Rt = word & 0b11111;
@@ -10484,6 +10489,7 @@ impl Decoder<ARMv8> for InstDecoder {
}
_ => {
inst.opcode = Opcode::Invalid;
+ return Err(DecodeError::InvalidOpcode);
}
}
}
diff --git a/tests/armv8/a64.rs b/tests/armv8/a64.rs
index a3ec96e..00f53e6 100644
--- a/tests/armv8/a64.rs
+++ b/tests/armv8/a64.rs
@@ -4753,6 +4753,11 @@ fn test_vec_shift() {
}
#[test]
+fn test_reserved() {
+ test_err([0x00, 0x00, 0x20, 0xd5], DecodeError::InvalidOpcode);
+}
+
+#[test]
fn test_system() {
const TESTS: &[([u8; 4], &'static str)] = &[
([0x00, 0x00, 0x08, 0xd5], "sys #0x0, c0, c0, #0x0, x0"),