This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 2/2][Aarch64][gas] Add support for PAN architecture extension.
- From: Matthew Wahab <matthew dot wahab at arm dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Wed, 20 May 2015 13:18:23 +0100
- Subject: [PATCH 2/2][Aarch64][gas] Add support for PAN architecture extension.
- Authentication-results: sourceware.org; auth=none
The ARMv8.1 architecture introduced the Privileged Access Never extension. This
adds a processor state field PSTATE.PAN which can be accessed using the MRS/MSR
instructions.
This patch adds support and tests for the PAN architecture feature and processor
state field to GAS under a new aarch64 extension "pan".
Tested for aarch64-none-linux-gnu with check-binutils and check-gas with no
failures. Tested html documentation in browser.
Ok for trunk?
Matthew
gas/
2015-05-20 Matthew Wahab <matthew.wahab@arm.com>
* config/tc-aarch64.c (parse_sys_reg): New parameter. Check
target support. Fix whitespace.
(parse_operands): Update for parse_sys_reg changes.
(aarch64_features): Add "pan".
* doc/c-aarch64.texi (Aarch64 Extensions): Add "pan".
gas/testsuite
2015-05-20 Matthew Wahab <matthew.wahab@arm.com>
* pan-directive.d: New.
* pan.d: New.
* pan.s: New
From 8ebf088d2f806708ee5a213b1cc7aef54d2e02e2 Mon Sep 17 00:00:00 2001
From: Matthew Wahab <matthew.wahab@arm.com>
Date: Wed, 6 May 2015 14:32:22 +0100
Subject: [PATCH 2/2] Add gas support for PAN extension.
Change-Id: Ib0a36c8d68169735b153dda3145855540c8a5f45
---
gas/config/tc-aarch64.c | 22 +++++++++++++++-----
gas/doc/c-aarch64.texi | 2 ++
gas/testsuite/gas/aarch64/pan-directive.d | 13 ++++++++++++
gas/testsuite/gas/aarch64/pan.d | 12 +++++++++++
gas/testsuite/gas/aarch64/pan.s | 34 +++++++++++++++++++++++++++++++
5 files changed, 78 insertions(+), 5 deletions(-)
create mode 100644 gas/testsuite/gas/aarch64/pan-directive.d
create mode 100644 gas/testsuite/gas/aarch64/pan.d
create mode 100644 gas/testsuite/gas/aarch64/pan.s
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 646deb6..b984b03 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -3383,10 +3383,15 @@ parse_barrier (char **str)
Returns the encoding for the option, or PARSE_FAIL.
If IMPLE_DEFINED_P is non-zero, the function will also try to parse the
- implementation defined system register name S<op0>_<op1>_<Cn>_<Cm>_<op2>. */
+ implementation defined system register name S<op0>_<op1>_<Cn>_<Cm>_<op2>.
+
+ If PSTATEFIELD_P is non-zero, the function will parse the name as a PSTATE
+ field, otherwise as a system register.
+*/
static int
-parse_sys_reg (char **str, struct hash_control *sys_regs, int imple_defined_p)
+parse_sys_reg (char **str, struct hash_control *sys_regs,
+ int imple_defined_p, int pstatefield_p)
{
char *p, *q;
char buf[32];
@@ -3421,9 +3426,15 @@ parse_sys_reg (char **str, struct hash_control *sys_regs, int imple_defined_p)
}
else
{
+ if (pstatefield_p && !aarch64_pstatefield_supported_p (cpu_variant, o))
+ as_bad (_("selected processor does not support PSTATE field "
+ "name '%s'"), buf);
+ if (!pstatefield_p && !aarch64_sys_reg_supported_p (cpu_variant, o))
+ as_bad (_("selected processor does not support system register "
+ "name '%s'"), buf);
if (aarch64_sys_reg_deprecated_p (o))
as_warn (_("system register name '%s' is deprecated and may be "
-"removed in a future release"), buf);
+ "removed in a future release"), buf);
value = o->value;
}
@@ -5288,7 +5299,7 @@ parse_operands (char *str, const aarch64_opcode *opcode)
break;
case AARCH64_OPND_SYSREG:
- if ((val = parse_sys_reg (&str, aarch64_sys_regs_hsh, 1))
+ if ((val = parse_sys_reg (&str, aarch64_sys_regs_hsh, 1, 0))
== PARSE_FAIL)
{
set_syntax_error (_("unknown or missing system register name"));
@@ -5298,7 +5309,7 @@ parse_operands (char *str, const aarch64_opcode *opcode)
break;
case AARCH64_OPND_PSTATEFIELD:
- if ((val = parse_sys_reg (&str, aarch64_pstatefield_hsh, 0))
+ if ((val = parse_sys_reg (&str, aarch64_pstatefield_hsh, 0, 1))
== PARSE_FAIL)
{
set_syntax_error (_("unknown or missing PSTATE field name"));
@@ -7367,6 +7378,7 @@ static const struct aarch64_option_cpu_value_table aarch64_features[] = {
{"fp", AARCH64_FEATURE (AARCH64_FEATURE_FP, 0)},
{"lse", AARCH64_FEATURE (AARCH64_FEATURE_LSE, 0)},
{"simd", AARCH64_FEATURE (AARCH64_FEATURE_SIMD, 0)},
+ {"pan", AARCH64_FEATURE (AARCH64_FEATURE_PAN, 0)},
{NULL, AARCH64_ARCH_NONE}
};
diff --git a/gas/doc/c-aarch64.texi b/gas/doc/c-aarch64.texi
index 79fe168..f790c7a 100644
--- a/gas/doc/c-aarch64.texi
+++ b/gas/doc/c-aarch64.texi
@@ -133,6 +133,8 @@ automatically cause those extensions to be disabled.
@tab Enable floating-point extensions.
@item @code{simd} @tab ARMv8-A @tab ARMv8-A or later
@tab Enable Advanced SIMD extensions. This implies @code{fp}.
+@item @code{pan} @tab ARMv8-A @tab ARMv8-A or later
+ @tab Enable Privileged Access Never support.
@end multitable
@node AArch64 Syntax
diff --git a/gas/testsuite/gas/aarch64/pan-directive.d b/gas/testsuite/gas/aarch64/pan-directive.d
new file mode 100644
index 0000000..704f7a3
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/pan-directive.d
@@ -0,0 +1,13 @@
+#objdump: -dr
+#as: --defsym DIRECTIVE=1
+#source: pan.s
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+0000000000000000 <.*>:
+ 0: d500419f msr pan, #0x1
+ 4: d500409f msr pan, #0x0
+ 8: d5184260 msr pan, x0
+ c: d5384261 mrs x1, pan
diff --git a/gas/testsuite/gas/aarch64/pan.d b/gas/testsuite/gas/aarch64/pan.d
new file mode 100644
index 0000000..db1fd02
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/pan.d
@@ -0,0 +1,12 @@
+#objdump: -dr
+#as: -march=armv8-a+pan
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+0000000000000000 <.*>:
+ 0: d500419f msr pan, #0x1
+ 4: d500409f msr pan, #0x0
+ 8: d5184260 msr pan, x0
+ c: d5384261 mrs x1, pan
diff --git a/gas/testsuite/gas/aarch64/pan.s b/gas/testsuite/gas/aarch64/pan.s
new file mode 100644
index 0000000..059046c
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/pan.s
@@ -0,0 +1,34 @@
+/* pan.s Test file for AArch64 PAN instructions.
+
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ Contributed by ARM Ltd.
+
+ This file is part of GAS.
+
+ GAS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the license, or
+ (at your option) any later version.
+
+ GAS is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+
+ .text
+ .ifdef DIRECTIVE
+ .arch_extension pan
+ .endif
+
+ msr pan, #1
+ msr pan, #0
+
+ msr pan, x0
+ mrs x1, pan
+
+ .arch_extension nopan
--
1.9.1