From b0bfa7b5b884f78b798ab8d34d2a50bc63f558df Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Fri, 11 Nov 2016 10:33:30 +0000 Subject: [PATCH] [AArch64] Add ARMv8.3 pointer authentication key registers Add support for system registers introduced in ARMv8.3 for pointer authentication. opcodes/ 2016-11-11 Szabolcs Nagy * 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/ 2016-11-11 Szabolcs Nagy * testsuite/gas/aarch64/sysreg-3.s: New. * testsuite/gas/aarch64/sysreg-3.d: New. * testsuite/gas/aarch64/illegal-sysreg-3.l: New. * testsuite/gas/aarch64/illegal-sysreg-3.d: New. --- gas/ChangeLog | 7 +++++ gas/testsuite/gas/aarch64/illegal-sysreg-3.d | 3 +++ gas/testsuite/gas/aarch64/illegal-sysreg-3.l | 21 +++++++++++++++ gas/testsuite/gas/aarch64/sysreg-3.d | 28 ++++++++++++++++++++ gas/testsuite/gas/aarch64/sysreg-3.s | 21 +++++++++++++++ opcodes/ChangeLog | 7 +++++ opcodes/aarch64-opc.c | 24 +++++++++++++++++ 7 files changed, 111 insertions(+) create mode 100644 gas/testsuite/gas/aarch64/illegal-sysreg-3.d create mode 100644 gas/testsuite/gas/aarch64/illegal-sysreg-3.l create mode 100644 gas/testsuite/gas/aarch64/sysreg-3.d create mode 100644 gas/testsuite/gas/aarch64/sysreg-3.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 1caf7a1e425..6c6e79f0f0d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2016-11-11 Szabolcs Nagy + + * testsuite/gas/aarch64/sysreg-3.s: New. + * testsuite/gas/aarch64/sysreg-3.d: New. + * testsuite/gas/aarch64/illegal-sysreg-3.l: New. + * testsuite/gas/aarch64/illegal-sysreg-3.d: New. + 2016-11-11 Szabolcs Nagy * testsuite/gas/aarch64/system-3.s: New. 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 00000000000..309391bdcc0 --- /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 00000000000..23aac82909d --- /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 00000000000..4329377e86d --- /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 00000000000..e2ffc81c2b2 --- /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/ChangeLog b/opcodes/ChangeLog index 0f3e89c23f5..5000976da56 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,10 @@ +2016-11-11 Szabolcs Nagy + + * 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. + 2016-11-11 Szabolcs Nagy * aarch64-tbl.h (aarch64_feature_v8_3, ARMV8_3, V8_3_INSN): New. diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c index 333be5ac025..8e89b5b22cc 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; } -- 2.30.2