From ef33047a8b93d416f08f3f640dd65f3887fb05c1 Mon Sep 17 00:00:00 2001 From: Przemyslaw Wirkus Date: Wed, 9 Dec 2020 21:29:58 +0000 Subject: [PATCH] aarch64: Add +pauth to -march New +pauth (Pointer Authentication from Armv8.3-A) feature option for -march command line option. Please note that majority of PAUTH instructions are implemented behind HINT instruction. PAUTH stays an Armv8.3-A feature but now can be assigned to other architectures or CPUs. gcc/ChangeLog: * config/aarch64/aarch64-option-extensions.def (AARCH64_OPT_EXTENSION): New +pauth option in -march for AArch64. * config/aarch64/aarch64.h (AARCH64_FL_PAUTH): New pauth extension bitmask. (AARCH64_ISA_PUATH): New ISA bitmask for PAUTH. (AARCH64_FL_FOR_ARCH8_3): Add PAUTH to Armv8.3-A. (TARGET_PAUTH): New target mask to isolate PAUTH instructions. * config/aarch64/aarch64.md (do_return): Condition set to TARGET_PAUTH. * doc/invoke.texi: Update docs for +flagm and +pauth. --- gcc/config/aarch64/aarch64-option-extensions.def | 3 +++ gcc/config/aarch64/aarch64.h | 9 ++++++++- gcc/config/aarch64/aarch64.md | 2 +- gcc/doc/invoke.texi | 9 +++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def index ec453017927..7db0a9fb3f6 100644 --- a/gcc/config/aarch64/aarch64-option-extensions.def +++ b/gcc/config/aarch64/aarch64-option-extensions.def @@ -229,4 +229,7 @@ AARCH64_OPT_EXTENSION("bf16", AARCH64_FL_BF16, \ /* Enabling/Disabling "flagm" only changes "flagm". */ AARCH64_OPT_EXTENSION("flagm", AARCH64_FL_FLAGM, 0, 0, false, "flagm") +/* Enabling/Disabling "pauth" only changes "pauth". */ +AARCH64_OPT_EXTENSION("pauth", AARCH64_FL_PAUTH, 0, 0, false, "paca pacg") + #undef AARCH64_OPT_EXTENSION diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 0bdcc74ace5..6c145cbc309 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -227,6 +227,9 @@ extern unsigned aarch64_architecture_version; /* Flag Manipulation Instructions (FLAGM) extension. */ #define AARCH64_FL_FLAGM (1ULL << 39) +/* Pointer Authentication (PAUTH) extension. */ +#define AARCH64_FL_PAUTH (1ULL << 40) + /* Has FP and SIMD. */ #define AARCH64_FL_FPSIMD (AARCH64_FL_FP | AARCH64_FL_SIMD) @@ -241,7 +244,7 @@ extern unsigned aarch64_architecture_version; #define AARCH64_FL_FOR_ARCH8_2 \ (AARCH64_FL_FOR_ARCH8_1 | AARCH64_FL_V8_2) #define AARCH64_FL_FOR_ARCH8_3 \ - (AARCH64_FL_FOR_ARCH8_2 | AARCH64_FL_V8_3) + (AARCH64_FL_FOR_ARCH8_2 | AARCH64_FL_V8_3 | AARCH64_FL_PAUTH) #define AARCH64_FL_FOR_ARCH8_4 \ (AARCH64_FL_FOR_ARCH8_3 | AARCH64_FL_V8_4 | AARCH64_FL_F16FML \ | AARCH64_FL_DOTPROD | AARCH64_FL_RCPC8_4 | AARCH64_FL_FLAGM) @@ -290,6 +293,7 @@ extern unsigned aarch64_architecture_version; #define AARCH64_ISA_BF16 (aarch64_isa_flags & AARCH64_FL_BF16) #define AARCH64_ISA_SB (aarch64_isa_flags & AARCH64_FL_SB) #define AARCH64_ISA_V8_R (aarch64_isa_flags & AARCH64_FL_V8_R) +#define AARCH64_ISA_PAUTH (aarch64_isa_flags & AARCH64_FL_PAUTH) /* Crypto is an optional extension to AdvSIMD. */ #define TARGET_CRYPTO (TARGET_SIMD && AARCH64_ISA_CRYPTO) @@ -378,6 +382,9 @@ extern unsigned aarch64_architecture_version; #define TARGET_BF16_SIMD (AARCH64_ISA_BF16 && TARGET_SIMD) #define TARGET_SVE_BF16 (TARGET_SVE && AARCH64_ISA_BF16) +/* PAUTH instructions are enabled through +pauth. */ +#define TARGET_PAUTH (AARCH64_ISA_PAUTH) + /* Make sure this is always defined so we don't have to check for ifdefs but rather use normal ifs. */ #ifndef TARGET_FIX_ERR_A53_835769_DEFAULT diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index eed06de3240..6327ae08899 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -873,7 +873,7 @@ { const char *ret = NULL; if (aarch64_return_address_signing_enabled () - && TARGET_ARMV8_3 + && (TARGET_PAUTH) && !crtl->calls_eh_return) { if (aarch64_ra_sign_key == AARCH64_KEY_B) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f7e8c8b29b0..8b871e8bffd 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -18016,8 +18016,8 @@ and the features that they enable by default: @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd} @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma} @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a} -@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a} -@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+fp16fml}, @samp{+dotprod} +@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth} +@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod} @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres} @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm} @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r} @@ -18288,8 +18288,9 @@ Advanced SIMD and floating-point instructions. This option is enabled by default for @option{-march=armv8.6-a}. Use of this option with architectures prior to Armv8.2-A is not supported. @item flagm -Enable the Flag Manipulation instructions Extension. This option is enabled by -default for @option{-march=armv8.4-a}. +Enable the Flag Manipulation instructions Extension. +@item pauth +Enable the Pointer Authentication Extension. @end table -- 2.30.2