This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[AArch64] Reject invalid immediate operands to MSR UAO
- From: Matthew Wahab <matthew dot wahab at foss dot arm dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 14 Jan 2016 15:46:51 +0000
- Subject: [AArch64] Reject invalid immediate operands to MSR UAO
- Authentication-results: sourceware.org; auth=none
Hello,
In the instruction to write to the ARMv8.2 PSTATE field UAO, MSR UAO,
#<imm>, the immediate should be either 0 or 1 but GAS accepts any
unsigned 4-bit integer.
This patch implements the constraint on the immediate, generating an
error if the immediate operand is invalid, and adds tests for the
illegal forms.
Tested aarch64-none-linux-gnu with cross-compiled check-binutils and
check-gas.
Ok for trunk?
Matthew
opcodes/
2016-01-14 Matthew Wahab <matthew.wahab@arm.com>
* aarch64-opc.c (operand_general_constraint_met_p): Check validity
of MSR UAO immediate operand.
gas/
2015-01-14 Matthew Wahab <matthew.wahab@arm.com>
* testsuite/gas/aarch64/armv8_2-a-illegal.d: New.
* testsuite/gas/aarch64/armv8_2-a-illegal.l: New.
* testsuite/gas/aarch64/armv8_2-a-illegal.s: New.
>From 0248bb8b68ba74fac43284cf6f60093fe63a8d2e Mon Sep 17 00:00:00 2001
From: Matthew Wahab <matthew.wahab@arm.com>
Date: Thu, 14 Jan 2016 09:48:07 +0000
Subject: [PATCH] [AArch64] Check for invalid argument to MSR UAO.
Change-Id: I4e8fa9b99bf837d93f1c0fe895bf48776b8d0f4e
---
gas/testsuite/gas/aarch64/armv8_2-a-illegal.d | 3 +++
gas/testsuite/gas/aarch64/armv8_2-a-illegal.l | 9 +++++++++
gas/testsuite/gas/aarch64/armv8_2-a-illegal.s | 5 +++++
opcodes/aarch64-opc.c | 6 ++++--
4 files changed, 21 insertions(+), 2 deletions(-)
create mode 100644 gas/testsuite/gas/aarch64/armv8_2-a-illegal.d
create mode 100644 gas/testsuite/gas/aarch64/armv8_2-a-illegal.l
create mode 100644 gas/testsuite/gas/aarch64/armv8_2-a-illegal.s
diff --git a/gas/testsuite/gas/aarch64/armv8_2-a-illegal.d b/gas/testsuite/gas/aarch64/armv8_2-a-illegal.d
new file mode 100644
index 0000000..ce7f637
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/armv8_2-a-illegal.d
@@ -0,0 +1,3 @@
+#as: -march=armv8.2-a
+#source: armv8_2-a-illegal.s
+#error-output: armv8_2-a-illegal.l
diff --git a/gas/testsuite/gas/aarch64/armv8_2-a-illegal.l b/gas/testsuite/gas/aarch64/armv8_2-a-illegal.l
new file mode 100644
index 0000000..f917bf7
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/armv8_2-a-illegal.l
@@ -0,0 +1,9 @@
+[^:]+: Assembler messages:
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#2'
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#3'
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#4'
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#5'
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#8'
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#15'
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#19'
+[^:]+:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr uao,#31'
diff --git a/gas/testsuite/gas/aarch64/armv8_2-a-illegal.s b/gas/testsuite/gas/aarch64/armv8_2-a-illegal.s
new file mode 100644
index 0000000..da551ae
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/armv8_2-a-illegal.s
@@ -0,0 +1,5 @@
+
+ /* MSR UAO, #imm4. */
+ .irp N,0, 1,2,3,4,5,8,15,19,31
+ msr uao, #\N
+ .endr
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index 83c4dbb..c22004b 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -1878,9 +1878,11 @@ operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx,
{
case AARCH64_OPND_PSTATEFIELD:
assert (idx == 0 && opnds[1].type == AARCH64_OPND_UIMM4);
- /* MSR PAN, #uimm4
+ /* MSR UAO, #uimm4
+ MSR PAN, #uimm4
The immediate must be #0 or #1. */
- if (opnd->pstatefield == 0x04 /* PAN. */
+ if ((opnd->pstatefield == 0x03 /* UAO. */
+ || opnd->pstatefield == 0x04) /* PAN. */
&& opnds[1].imm.value > 1)
{
set_imm_out_of_range_error (mismatch_detail, idx, 0, 1);
--
2.1.4