From f985c2512aee1c4440998db62d6aea98c737b3ef Mon Sep 17 00:00:00 2001 From: srinath Date: Thu, 2 Nov 2023 13:04:20 +0000 Subject: aarch64: Add support for GCS extension. This patch adds for Guarded Control Stack Extension (GCS) extension. GCS feature is optional from Armv9.4-A architecture and enabled by passing +gcs option to -march (eg: -march=armv9.4-a+gcs) or using ".arch_extension gcs" directive in the assembly file. Also this patch adds support for GCS instructions gcspushx, gcspopcx, gcspopx, gcsss1, gcsss2, gcspushm, gcspopm, gcsstr and gcssttr. --- gas/NEWS | 2 ++ gas/config/tc-aarch64.c | 1 + gas/doc/c-aarch64.texi | 2 ++ gas/testsuite/gas/aarch64/gcs-1-bad.d | 3 ++ gas/testsuite/gas/aarch64/gcs-1-bad.l | 45 +++++++++++++++++++++++++++++ gas/testsuite/gas/aarch64/gcs-1.d | 54 +++++++++++++++++++++++++++++++++++ gas/testsuite/gas/aarch64/gcs-1.s | 19 ++++++++++++ 7 files changed, 126 insertions(+) create mode 100644 gas/testsuite/gas/aarch64/gcs-1-bad.d create mode 100644 gas/testsuite/gas/aarch64/gcs-1-bad.l create mode 100644 gas/testsuite/gas/aarch64/gcs-1.d create mode 100644 gas/testsuite/gas/aarch64/gcs-1.s (limited to 'gas') diff --git a/gas/NEWS b/gas/NEWS index 2b593c1..a6ac839 100644 --- a/gas/NEWS +++ b/gas/NEWS @@ -1,5 +1,7 @@ -*- text -*- +* Add support for Guarded Control Stack (GCS) for AArch64. + * Add support for AArch64 Check Feature Status Extension (CHK). * Add support for 'armv8.9-a' and 'armv9.4-a' for -march in AArch64 GAS. diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index f5b7b42..6d20400 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -10325,6 +10325,7 @@ static const struct aarch64_option_cpu_value_table aarch64_features[] = { {"hbc", AARCH64_FEATURE (HBC), AARCH64_NO_FEATURES}, {"cssc", AARCH64_FEATURE (CSSC), AARCH64_NO_FEATURES}, {"chk", AARCH64_FEATURE (CHK), AARCH64_NO_FEATURES}, + {"gcs", AARCH64_FEATURE (GCS), AARCH64_NO_FEATURES}, {NULL, AARCH64_NO_FEATURES, AARCH64_NO_FEATURES}, }; diff --git a/gas/doc/c-aarch64.texi b/gas/doc/c-aarch64.texi index 0cabf72e..a3ca714 100644 --- a/gas/doc/c-aarch64.texi +++ b/gas/doc/c-aarch64.texi @@ -261,6 +261,8 @@ automatically cause those extensions to be disabled. @tab Enable Transactional Memory Extensions. @item @code{chk} @tab ARMv8-A @tab ARMv8-A @tab Enable Check Feature Status Extension. +@item @code{gcs} @tab N/A @tab No + @tab Enable Guarded Control Stack Extension. @end multitable @node AArch64 Syntax diff --git a/gas/testsuite/gas/aarch64/gcs-1-bad.d b/gas/testsuite/gas/aarch64/gcs-1-bad.d new file mode 100644 index 0000000..7c3a7ae --- /dev/null +++ b/gas/testsuite/gas/aarch64/gcs-1-bad.d @@ -0,0 +1,3 @@ +#as: -march=armv9.2-a +#source: gcs-1.s +#error_output: gcs-1-bad.l diff --git a/gas/testsuite/gas/aarch64/gcs-1-bad.l b/gas/testsuite/gas/aarch64/gcs-1-bad.l new file mode 100644 index 0000000..ca8d17a --- /dev/null +++ b/gas/testsuite/gas/aarch64/gcs-1-bad.l @@ -0,0 +1,45 @@ +[^ :]+: Assembler messages: +[^ :]+:[0-9]+: Error: selected processor does not support `gcspushx' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspopcx' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspopx' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspopm' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspushm x0' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspushm x15' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspushm x30' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspushm xzr' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss1 x0' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss1 x15' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss1 x30' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss1 xzr' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss2 x0' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss2 x15' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss2 x30' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsss2 xzr' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspopm x0' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspopm x15' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspopm x30' +[^ :]+:[0-9]+: Error: selected processor does not support `gcspopm xzr' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x0,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x0,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x0,sp' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x15,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x15,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x15,sp' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x30,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x30,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr x30,sp' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr xzr,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr xzr,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcsstr xzr,sp' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x0,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x0,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x0,sp' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x15,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x15,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x15,sp' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x30,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x30,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr x30,sp' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr xzr,x1' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr xzr,x16' +[^ :]+:[0-9]+: Error: selected processor does not support `gcssttr xzr,sp' diff --git a/gas/testsuite/gas/aarch64/gcs-1.d b/gas/testsuite/gas/aarch64/gcs-1.d new file mode 100644 index 0000000..51f9dd6 --- /dev/null +++ b/gas/testsuite/gas/aarch64/gcs-1.d @@ -0,0 +1,54 @@ +#name: Test of Guarded Control Stack Instructions. +#as: -march=armv9.3-a+gcs +#objdump: -dr + +[^:]+: file format .* + + +[^:]+: + +[^:]+: +.*: d508779f gcspushx +.*: d50877bf gcspopcx +.*: d50877df gcspopx +.*: d52b773f gcspopm +.*: d50b7700 gcspushm x0 +.*: d50b770f gcspushm x15 +.*: d50b771e gcspushm x30 +.*: d50b771f gcspushm xzr +.*: d50b7740 gcsss1 x0 +.*: d50b774f gcsss1 x15 +.*: d50b775e gcsss1 x30 +.*: d50b775f gcsss1 xzr +.*: d52b7760 gcsss2 x0 +.*: d52b776f gcsss2 x15 +.*: d52b777e gcsss2 x30 +.*: d52b777f gcsss2 xzr +.*: d52b7720 gcspopm x0 +.*: d52b772f gcspopm x15 +.*: d52b773e gcspopm x30 +.*: d52b773f gcspopm +.*: d91f0c20 gcsstr x0, x1 +.*: d91f0e00 gcsstr x0, x16 +.*: d91f0fe0 gcsstr x0, sp +.*: d91f0c2f gcsstr x15, x1 +.*: d91f0e0f gcsstr x15, x16 +.*: d91f0fef gcsstr x15, sp +.*: d91f0c3e gcsstr x30, x1 +.*: d91f0e1e gcsstr x30, x16 +.*: d91f0ffe gcsstr x30, sp +.*: d91f0c3f gcsstr xzr, x1 +.*: d91f0e1f gcsstr xzr, x16 +.*: d91f0fff gcsstr xzr, sp +.*: d91f1c20 gcssttr x0, x1 +.*: d91f1e00 gcssttr x0, x16 +.*: d91f1fe0 gcssttr x0, sp +.*: d91f1c2f gcssttr x15, x1 +.*: d91f1e0f gcssttr x15, x16 +.*: d91f1fef gcssttr x15, sp +.*: d91f1c3e gcssttr x30, x1 +.*: d91f1e1e gcssttr x30, x16 +.*: d91f1ffe gcssttr x30, sp +.*: d91f1c3f gcssttr xzr, x1 +.*: d91f1e1f gcssttr xzr, x16 +.*: d91f1fff gcssttr xzr, sp diff --git a/gas/testsuite/gas/aarch64/gcs-1.s b/gas/testsuite/gas/aarch64/gcs-1.s new file mode 100644 index 0000000..9706587 --- /dev/null +++ b/gas/testsuite/gas/aarch64/gcs-1.s @@ -0,0 +1,19 @@ + .text + gcspushx + gcspopcx + gcspopx + gcspopm + + .irp op gcspushm, gcsss1, gcsss2, gcspopm + .irp reg1 x0, x15, x30, xzr + \op \reg1 + .endr + .endr + + .irp op gcsstr, gcssttr + .irp reg1 x0, x15, x30, xzr + .irp reg2 x1, x16, sp + \op \reg1, \reg2 + .endr + .endr + .endr -- cgit v1.1