diff mbox series

[2/6] aarch64: Add missing ACLE support for PAC-RET

Message ID a2cff3d887d770eeb0015c738c6f079c9a09325a.1594224951.git.szabolcs.nagy@arm.com
State New
Headers show
Series aarch64: Fix target libraries for BTI [PR96001] | expand

Commit Message

Szabolcs Nagy July 8, 2020, 4:26 p.m. UTC
Define the __ARM_FEATURE_PAC_DEFAULT feature test
macro when PAC-RET branch protection is enabled.

gcc/ChangeLog:

2020-07-08  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Add
	__ARM_FEATURE_PAC_DEFAULT support.

---
Note: i expect to push this patch after the pac-ret
__builtin_return_address and unwinder patches are
resolved so we only advertise pac-ret support in a
fixed gcc which makes it possible to configure test
for __builtin_return_address behaviour.
---
 gcc/config/aarch64/aarch64-c.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Kyrylo Tkachov July 8, 2020, 4:46 p.m. UTC | #1
> -----Original Message-----
> From: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
> Sent: 08 July 2020 17:27
> To: gcc-patches@gcc.gnu.org
> Cc: Richard Earnshaw <Richard.Earnshaw@arm.com>; Kyrylo Tkachov
> <Kyrylo.Tkachov@arm.com>
> Subject: [PATCH 2/6] aarch64: Add missing ACLE support for PAC-RET
> 
> Define the __ARM_FEATURE_PAC_DEFAULT feature test
> macro when PAC-RET branch protection is enabled.
> 

Ok once the prerequisites are in.
The developer.arm.com website hosting the ACLE spec is having trouble at the moment but, being familiar with this part of the spec, the definition looks correct to me.

Thanks,
Kyrill

> gcc/ChangeLog:
> 
> 2020-07-08  Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
> 	* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Add
> 	__ARM_FEATURE_PAC_DEFAULT support.
> 
> ---
> Note: i expect to push this patch after the pac-ret
> __builtin_return_address and unwinder patches are
> resolved so we only advertise pac-ret support in a
> fixed gcc which makes it possible to configure test
> for __builtin_return_address behaviour.
> ---
>  gcc/config/aarch64/aarch64-c.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c
> index 1882288af8d..1a1f4ecef04 100644
> --- a/gcc/config/aarch64/aarch64-c.c
> +++ b/gcc/config/aarch64/aarch64-c.c
> @@ -181,6 +181,19 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
>    aarch64_def_or_undef (aarch64_bti_enabled (),
>  			"__ARM_FEATURE_BTI_DEFAULT", pfile);
> 
> +  cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT");
> +  if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE)
> +    {
> +      int v = 0;
> +      if (aarch64_ra_sign_key == AARCH64_KEY_A)
> +	v |= 1;
> +      if (aarch64_ra_sign_key == AARCH64_KEY_B)
> +	v |= 2;
> +      if (aarch64_ra_sign_scope == AARCH64_FUNCTION_ALL)
> +	v |= 4;
> +      builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", v);
> +    }
> +
>    aarch64_def_or_undef (TARGET_I8MM,
> "__ARM_FEATURE_MATMUL_INT8", pfile);
>    aarch64_def_or_undef (TARGET_BF16_SIMD,
>  			"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC",
> pfile);
> --
> 2.17.1
diff mbox series

Patch

diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c
index 1882288af8d..1a1f4ecef04 100644
--- a/gcc/config/aarch64/aarch64-c.c
+++ b/gcc/config/aarch64/aarch64-c.c
@@ -181,6 +181,19 @@  aarch64_update_cpp_builtins (cpp_reader *pfile)
   aarch64_def_or_undef (aarch64_bti_enabled (),
 			"__ARM_FEATURE_BTI_DEFAULT", pfile);
 
+  cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT");
+  if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE)
+    {
+      int v = 0;
+      if (aarch64_ra_sign_key == AARCH64_KEY_A)
+	v |= 1;
+      if (aarch64_ra_sign_key == AARCH64_KEY_B)
+	v |= 2;
+      if (aarch64_ra_sign_scope == AARCH64_FUNCTION_ALL)
+	v |= 4;
+      builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", v);
+    }
+
   aarch64_def_or_undef (TARGET_I8MM, "__ARM_FEATURE_MATMUL_INT8", pfile);
   aarch64_def_or_undef (TARGET_BF16_SIMD,
 			"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", pfile);