From b6fd41837f3ff233aeb0be908d5065a86219242b Mon Sep 17 00:00:00 2001
From: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Date: Fri, 1 Mar 2019 09:35:26 +0000
Subject: [PATCH] Correctly check for support of Address Authentication

Check for both IMPLEMENTATION_DEFINED and Architected algorithms of
Address Authentication.

Change-Id: I209dcc6087172cfef7baf8d09e0454628f02cbd0
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
---
 common/bl_common.c                   | 2 +-
 include/arch/aarch64/arch_features.h | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/common/bl_common.c b/common/bl_common.c
index 4e76dd3e6..61f031bfd 100644
--- a/common/bl_common.c
+++ b/common/bl_common.c
@@ -265,7 +265,7 @@ void bl_handle_pauth(void)
 	 * system registers. Pointer authentication can't be enabled here or the
 	 * authentication will fail when returning from this function.
 	 */
-	assert(is_armv8_3_pauth_api_present());
+	assert(is_armv8_3_pauth_apa_api_present());
 
 	uint64_t *apiakey = plat_init_apiakey();
 
diff --git a/include/arch/aarch64/arch_features.h b/include/arch/aarch64/arch_features.h
index 495ecb3a2..6af1d0397 100644
--- a/include/arch/aarch64/arch_features.h
+++ b/include/arch/aarch64/arch_features.h
@@ -34,10 +34,12 @@ static inline bool is_armv8_3_pauth_present(void)
 	return (read_id_aa64isar1_el1() & mask) != 0U;
 }
 
-static inline bool is_armv8_3_pauth_api_present(void)
+static inline bool is_armv8_3_pauth_apa_api_present(void)
 {
-	return ((read_id_aa64isar1_el1() >> ID_AA64ISAR1_API_SHIFT) &
-		ID_AA64ISAR1_API_MASK) != 0U;
+	uint64_t mask = (ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) |
+			(ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT);
+
+	return (read_id_aa64isar1_el1() & mask) != 0U;
 }
 
 static inline bool is_armv8_4_ttst_present(void)
-- 
GitLab