This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[AArch64] Reject invalid immediate operands to MSR PAN
- From: Matthew Wahab <matthew dot wahab at foss dot arm dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Mon, 9 Nov 2015 12:44:21 +0000
- Subject: [AArch64] Reject invalid immediate operands to MSR PAN
- Authentication-results: sourceware.org; auth=none
Hello,
The support for accessing the ARMv8.1 PSTATE field PAN allows
instructions of the form MSR PAN, #<imm> with <imm> any unsigned 4-bit
integer. However, the architecture specification requires that the
immediate is either 0 or 1.
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/
2015-11-09 Matthew Wahab <matthew.wahab@arm.com>
* aarch64-opc.c (operand_general_constraint_met_p): Check validity
of MSR PAN immediate operand.
gas/testsuite/
2015-11-09 Matthew Wahab <matthew.wahab@arm.com>
* gas/aarch64/pan-illegal.d: New.
* gas/aarch64/pan-illegal.l: New.
* gas/aarch64/pan.s: Add tests for invalid immediates.
>From 8d5fe302bad5861dae7592cdcda31a70408fa0b4 Mon Sep 17 00:00:00 2001
From: Matthew Wahab <matthew.wahab@arm.com>
Date: Mon, 2 Nov 2015 13:12:58 +0000
Subject: [PATCH] [AArch64] Reject invalid immediate values in MSR PAN.
Change-Id: I0fc69548c3f5683e8ea73e751b4f2f2ac43a9f80
---
gas/testsuite/gas/aarch64/pan-illegal.d | 3 +++
gas/testsuite/gas/aarch64/pan-illegal.l | 15 +++++++++++++++
gas/testsuite/gas/aarch64/pan.s | 6 ++++++
opcodes/aarch64-opc.c | 8 ++++++++
4 files changed, 32 insertions(+)
create mode 100644 gas/testsuite/gas/aarch64/pan-illegal.d
create mode 100644 gas/testsuite/gas/aarch64/pan-illegal.l
diff --git a/gas/testsuite/gas/aarch64/pan-illegal.d b/gas/testsuite/gas/aarch64/pan-illegal.d
new file mode 100644
index 0000000..372b9d7
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/pan-illegal.d
@@ -0,0 +1,3 @@
+#as: -march=armv8.1-a --defsym ERROR=1
+#source: pan.s
+#error-output: pan-illegal.l
diff --git a/gas/testsuite/gas/aarch64/pan-illegal.l b/gas/testsuite/gas/aarch64/pan-illegal.l
new file mode 100644
index 0000000..f620ab0
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/pan-illegal.l
@@ -0,0 +1,15 @@
+[^:]*: Assembler messages:
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#2'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#3'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#4'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#5'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#6'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#7'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#8'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#9'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#10'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#11'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#12'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#13'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#14'
+[^:]*:[0-9]+: Error: immediate value out of range 0 to 1 at operand 1 -- `msr pan,#15'
diff --git a/gas/testsuite/gas/aarch64/pan.s b/gas/testsuite/gas/aarch64/pan.s
index 059046c..4144e2b 100644
--- a/gas/testsuite/gas/aarch64/pan.s
+++ b/gas/testsuite/gas/aarch64/pan.s
@@ -31,4 +31,10 @@
msr pan, x0
mrs x1, pan
+ .ifdef ERROR
+ .irp N,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ msr pan, #\N
+ .endr
+ .endif
+
.arch_extension nopan
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index c6ab4b2..50dbd36 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -1862,6 +1862,14 @@ 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
+ The immediate must be #0 or #1. */
+ if (opnd->pstatefield == 0x04 /* PAN. */
+ && opnds[1].imm.value > 1)
+ {
+ set_imm_out_of_range_error (mismatch_detail, idx, 0, 1);
+ return 0;
+ }
/* MSR SPSel, #uimm4
Uses uimm4 as a control value to select the stack pointer: if
bit 0 is set it selects the current exception level's stack
--
2.1.4