[v4,02/22] aarch64: Add asm helpers for GCS

Message ID 20241129163721.2385847-3-yury.khrustalev@arm.com
State Under Review
Delegated to: Carlos O'Donell
Headers
Series aarch64: Add support for Guarded Control Stack extension |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed

Commit Message

Yury Khrustalev Nov. 29, 2024, 4:37 p.m. UTC
  From: Szabolcs Nagy <szabolcs.nagy@arm.com>

The Guarded Control Stack instructions can be present even if the
hardware does not support the extension (runtime checked feature),
so the asm code should be backward compatible with old assemblers.
---
 sysdeps/aarch64/sysdep.h | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Carlos O'Donell Dec. 2, 2024, 9:23 p.m. UTC | #1
On 11/29/24 11:37 AM, Yury Khrustalev wrote:
> From: Szabolcs Nagy <szabolcs.nagy@arm.com>
> 
> The Guarded Control Stack instructions can be present even if the
> hardware does not support the extension (runtime checked feature),
> so the asm code should be backward compatible with old assemblers.

This is an internal header and it can go in right away.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/aarch64/sysdep.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h
> index 464674e89c..661d9fe8c1 100644
> --- a/sysdeps/aarch64/sysdep.h
> +++ b/sysdeps/aarch64/sysdep.h
> @@ -74,6 +74,13 @@ strip_pac (void *p)
>  #define PACIASP		hint	25
>  #define AUTIASP		hint	29
>  
> +/* Guarded Control Stack support.  */
> +#define CHKFEAT_X16	hint	40
> +#define MRS_GCSPR(x)	mrs	x, s3_3_c2_c5_1
> +#define GCSPOPM(x)	sysl	x, #3, c7, c7, #1
> +#define GCSSS1(x)	sys	#3, c7, c7, #2, x
> +#define GCSSS2(x)	sysl	x, #3, c7, c7, #3

OK. You put it right after pac-ret definitions and that makes sense.

> +
>  /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code.  */
>  #define FEATURE_1_AND 0xc0000000
>  #define FEATURE_1_BTI 1
  

Patch

diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h
index 464674e89c..661d9fe8c1 100644
--- a/sysdeps/aarch64/sysdep.h
+++ b/sysdeps/aarch64/sysdep.h
@@ -74,6 +74,13 @@  strip_pac (void *p)
 #define PACIASP		hint	25
 #define AUTIASP		hint	29
 
+/* Guarded Control Stack support.  */
+#define CHKFEAT_X16	hint	40
+#define MRS_GCSPR(x)	mrs	x, s3_3_c2_c5_1
+#define GCSPOPM(x)	sysl	x, #3, c7, c7, #1
+#define GCSSS1(x)	sys	#3, c7, c7, #2, x
+#define GCSSS2(x)	sysl	x, #3, c7, c7, #3
+
 /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code.  */
 #define FEATURE_1_AND 0xc0000000
 #define FEATURE_1_BTI 1