mbedtls: fix builds with crypto extensions

Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Beniamin Sandu
2023-06-26 14:50:40 +03:00
committed by Khem Raj
parent a3c5ac33f9
commit bf314d2c57
3 changed files with 70 additions and 5 deletions
@@ -0,0 +1,33 @@
From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001
From: Beniamin Sandu <beniaminsandu@gmail.com>
Date: Sun, 25 Jun 2023 19:58:08 +0300
Subject: [PATCH] aesce: do not specify an arch version when enabling crypto
instructions
Building mbedtls with different aarch64 tuning variations revealed
that we should use the crypto extensions without forcing a particular
architecture version or core, as that can create issues.
Upstream-Status: Submitted [https://github.com/Mbed-TLS/mbedtls/pull/7834]
Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
---
library/aesce.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/library/aesce.c b/library/aesce.c
index fe056dc4c..843de3973 100644
--- a/library/aesce.c
+++ b/library/aesce.c
@@ -60,7 +60,7 @@
# error "A more recent GCC is required for MBEDTLS_AESCE_C"
# endif
# pragma GCC push_options
-# pragma GCC target ("arch=armv8-a+crypto")
+# pragma GCC target ("+crypto")
# define MBEDTLS_POP_TARGET_PRAGMA
# else
# error "Only GCC and Clang supported for MBEDTLS_AESCE_C"
--
2.25.1
@@ -0,0 +1,34 @@
From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001
From: Beniamin Sandu <beniaminsandu@gmail.com>
Date: Mon, 26 Jun 2023 12:07:21 +0300
Subject: [PATCH] aesce: use correct target attribute when building with clang
Seems clang has its own issues when it comes to crypto extensions,
and right now the best way to avoid them is to accurately enable
the needed instructions instead of the broad crypto feature.
E.g.: https://github.com/llvm/llvm-project/issues/61645
Upstream-Status: Pending
Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
---
library/aesce.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/library/aesce.c b/library/aesce.c
index 843de3973..7bea088ba 100644
--- a/library/aesce.c
+++ b/library/aesce.c
@@ -53,7 +53,7 @@
# if __clang_major__ < 4
# error "A more recent Clang is required for MBEDTLS_AESCE_C"
# endif
-# pragma clang attribute push (__attribute__((target("crypto"))), apply_to=function)
+# pragma clang attribute push (__attribute__((target("aes"))), apply_to=function)
# define MBEDTLS_POP_TARGET_PRAGMA
# elif defined(__GNUC__)
# if __GNUC__ < 6
--
2.25.1
@@ -25,8 +25,9 @@ SECTION = "libs"
S = "${WORKDIR}/git" S = "${WORKDIR}/git"
SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33" SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33"
SRC_URI = "git://github.com/ARMmbed/mbedtls.git;protocol=https;branch=master \ SRC_URI = "git://github.com/ARMmbed/mbedtls.git;protocol=https;branch=master \
file://run-ptest \ file://0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch \
" file://0002-aesce-use-correct-target-attribute-when-building-wit.patch \
file://run-ptest"
inherit cmake update-alternatives ptest inherit cmake update-alternatives ptest
@@ -41,9 +42,6 @@ PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"
EXTRA_OECMAKE = "-DLIB_INSTALL_DIR:STRING=${libdir}" EXTRA_OECMAKE = "-DLIB_INSTALL_DIR:STRING=${libdir}"
# Needs crypto instructions on aarch64
TUNE_CCARGS_MARCH_OPTS:append:aarch64 = "${@bb.utils.contains('TUNE_FEATURES', 'crypto', '', '+crypto', d)}"
# For now the only way to enable PSA is to explicitly pass a -D via CFLAGS # For now the only way to enable PSA is to explicitly pass a -D via CFLAGS
CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', ' -DMBEDTLS_USE_PSA_CRYPTO', '', d)}" CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', ' -DMBEDTLS_USE_PSA_CRYPTO', '', d)}"