[AArch64] Add ARMv8.3 pointer authentication key registers

Message ID 5821A473.3000907@arm.com
State New
Headers show

Commit Message

Szabolcs Nagy Nov. 8, 2016, 10:09 a.m.
Add support for system registers introduced in ARMv8.3
for pointer authentication.

opcodes/
2016-11-08  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* aarch64-opc.c (aarch64_sys_regs): Add apiakeylo_el1, apiakeyhi_el1,
	apibkeylo_el1, apibkeyhi_el1, apdakeylo_el1, apdakeyhi_el1,
	apdbkeylo_el1, apdbkeyhi_el1, apgakeylo_el1 and apgakeyhi_el1.
	(aarch64_sys_reg_supported_p): Add feature test for new registers.

gas/testsuite/
2016-11-08  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* gas/aarch64/sysreg-3.s: New.
	* gas/aarch64/sysreg-3.d: New.
	* gas/aarch64/illegal-sysreg-3.l: New.
	* gas/aarch64/illegal-sysreg-3.d: New.

Comments

Nick Clifton Nov. 10, 2016, 2:46 p.m. | #1
Hi Szabolcs,

> opcodes/

> 2016-11-08  Szabolcs Nagy  <szabolcs.nagy@arm.com>

> 

> 	* aarch64-opc.c (aarch64_sys_regs): Add apiakeylo_el1, apiakeyhi_el1,

> 	apibkeylo_el1, apibkeyhi_el1, apdakeylo_el1, apdakeyhi_el1,

> 	apdbkeylo_el1, apdbkeyhi_el1, apgakeylo_el1 and apgakeyhi_el1.

> 	(aarch64_sys_reg_supported_p): Add feature test for new registers.

> 

> gas/testsuite/

> 2016-11-08  Szabolcs Nagy  <szabolcs.nagy@arm.com>

> 

> 	* gas/aarch64/sysreg-3.s: New.

> 	* gas/aarch64/sysreg-3.d: New.

> 	* gas/aarch64/illegal-sysreg-3.l: New.

> 	* gas/aarch64/illegal-sysreg-3.d: New.


Approved - please apply.

Cheers
  Nick

Patch hide | download patch | download mbox

diff --git a/gas/testsuite/gas/aarch64/illegal-sysreg-3.d b/gas/testsuite/gas/aarch64/illegal-sysreg-3.d
new file mode 100644
index 0000000..309391b
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/illegal-sysreg-3.d
@@ -0,0 +1,3 @@ 
+#as: -march=armv8-a
+#source: sysreg-3.s
+#error-output: illegal-sysreg-3.l
diff --git a/gas/testsuite/gas/aarch64/illegal-sysreg-3.l b/gas/testsuite/gas/aarch64/illegal-sysreg-3.l
new file mode 100644
index 0000000..23aac82
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/illegal-sysreg-3.l
@@ -0,0 +1,21 @@ 
+[^:]*: Assembler messages:
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apiakeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apiakeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apiakeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apiakeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apibkeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apibkeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apibkeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apibkeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdakeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdakeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdakeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdakeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdbkeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdbkeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdbkeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apdbkeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apgakeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apgakeylo_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apgakeyhi_el1'
+[^:]*:[0-9]+: Error: selected processor does not support system register name 'apgakeyhi_el1'
diff --git a/gas/testsuite/gas/aarch64/sysreg-3.d b/gas/testsuite/gas/aarch64/sysreg-3.d
new file mode 100644
index 0000000..4329377
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/sysreg-3.d
@@ -0,0 +1,28 @@ 
+#objdump: -dr
+#as: -march=armv8.3-a
+
+.*:     file .*
+
+Disassembly of section \.text:
+
+0000000000000000 <.*>:
+   0:	d5182100 	msr	apiakeylo_el1, x0
+   4:	d5382100 	mrs	x0, apiakeylo_el1
+   8:	d5182121 	msr	apiakeyhi_el1, x1
+   c:	d5382121 	mrs	x1, apiakeyhi_el1
+  10:	d5182142 	msr	apibkeylo_el1, x2
+  14:	d5382142 	mrs	x2, apibkeylo_el1
+  18:	d5182163 	msr	apibkeyhi_el1, x3
+  1c:	d5382163 	mrs	x3, apibkeyhi_el1
+  20:	d5182204 	msr	apdakeylo_el1, x4
+  24:	d5382204 	mrs	x4, apdakeylo_el1
+  28:	d5182225 	msr	apdakeyhi_el1, x5
+  2c:	d5382225 	mrs	x5, apdakeyhi_el1
+  30:	d5182246 	msr	apdbkeylo_el1, x6
+  34:	d5382246 	mrs	x6, apdbkeylo_el1
+  38:	d5182267 	msr	apdbkeyhi_el1, x7
+  3c:	d5382267 	mrs	x7, apdbkeyhi_el1
+  40:	d5182308 	msr	apgakeylo_el1, x8
+  44:	d5382308 	mrs	x8, apgakeylo_el1
+  48:	d5182329 	msr	apgakeyhi_el1, x9
+  4c:	d5382329 	mrs	x9, apgakeyhi_el1
diff --git a/gas/testsuite/gas/aarch64/sysreg-3.s b/gas/testsuite/gas/aarch64/sysreg-3.s
new file mode 100644
index 0000000..e2ffc81
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/sysreg-3.s
@@ -0,0 +1,21 @@ 
+/* sysreg-3.s Test file for ARMv8.3 system registers.  */
+
+	.macro test sys_reg xreg
+	msr \sys_reg, \xreg
+	mrs \xreg, \sys_reg
+	.endm
+
+	.text
+
+	test sys_reg=apiakeylo_el1 xreg=x0
+	test sys_reg=apiakeyhi_el1 xreg=x1
+	test sys_reg=apibkeylo_el1 xreg=x2
+	test sys_reg=apibkeyhi_el1 xreg=x3
+
+	test sys_reg=apdakeylo_el1 xreg=x4
+	test sys_reg=apdakeyhi_el1 xreg=x5
+	test sys_reg=apdbkeylo_el1 xreg=x6
+	test sys_reg=apdbkeyhi_el1 xreg=x7
+
+	test sys_reg=apgakeylo_el1 xreg=x8
+	test sys_reg=apgakeyhi_el1 xreg=x9
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index 333be5a..8e89b5b 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -3650,6 +3650,16 @@  const aarch64_sys_reg aarch64_sys_regs [] =
   { "tcr_el3",          CPENC(3,6,C2,C0,2),	0 },
   { "tcr_el12",		CPENC (3, 5, C2, C0, 2), F_ARCHEXT },
   { "vtcr_el2",         CPENC(3,4,C2,C1,2),	0 },
+  { "apiakeylo_el1",	CPENC (3, 0, C2, C1, 0), F_ARCHEXT },
+  { "apiakeyhi_el1",	CPENC (3, 0, C2, C1, 1), F_ARCHEXT },
+  { "apibkeylo_el1",	CPENC (3, 0, C2, C1, 2), F_ARCHEXT },
+  { "apibkeyhi_el1",	CPENC (3, 0, C2, C1, 3), F_ARCHEXT },
+  { "apdakeylo_el1",	CPENC (3, 0, C2, C2, 0), F_ARCHEXT },
+  { "apdakeyhi_el1",	CPENC (3, 0, C2, C2, 1), F_ARCHEXT },
+  { "apdbkeylo_el1",	CPENC (3, 0, C2, C2, 2), F_ARCHEXT },
+  { "apdbkeyhi_el1",	CPENC (3, 0, C2, C2, 3), F_ARCHEXT },
+  { "apgakeylo_el1",	CPENC (3, 0, C2, C3, 0), F_ARCHEXT },
+  { "apgakeyhi_el1",	CPENC (3, 0, C2, C3, 1), F_ARCHEXT },
   { "afsr0_el1",        CPENC(3,0,C5,C1,0),	0 },
   { "afsr1_el1",        CPENC(3,0,C5,C1,1),	0 },
   { "afsr0_el2",        CPENC(3,4,C5,C1,0),	0 },
@@ -4026,6 +4036,20 @@  aarch64_sys_reg_supported_p (const aarch64_feature_set features,
       && !AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_PROFILE))
     return FALSE;
 
+  /* ARMv8.3 Pointer authentication keys.  */
+  if ((reg->value == CPENC (3, 0, C2, C1, 0)
+       || reg->value == CPENC (3, 0, C2, C1, 1)
+       || reg->value == CPENC (3, 0, C2, C1, 2)
+       || reg->value == CPENC (3, 0, C2, C1, 3)
+       || reg->value == CPENC (3, 0, C2, C2, 0)
+       || reg->value == CPENC (3, 0, C2, C2, 1)
+       || reg->value == CPENC (3, 0, C2, C2, 2)
+       || reg->value == CPENC (3, 0, C2, C2, 3)
+       || reg->value == CPENC (3, 0, C2, C3, 0)
+       || reg->value == CPENC (3, 0, C2, C3, 1))
+      && !AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_3))
+    return FALSE;
+
   return TRUE;
 }