Skip to contentSkip to conversation

mbedtls: fix builds with crypto extensions

PATCH In review Beniamin Sandu 2 participants 5 messages Jun 26, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mbedtls: fix builds with crypto extensions

---
 ...cify-an-arch-version-when-enabling-c.patch | 33 ++++++++++++++++++
 ...t-target-attribute-when-building-wit.patch | 34 +++++++++++++++++++
 .../mbedtls/mbedtls_3.4.0.bb                  |  8 ++---
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch
 create mode 100644 meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +33 -0
new file mode 100644
index 000000000..d98d8fa57
@@ -0,0 +1,33 @@
+From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+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 <[email protected]>
+---
+ 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
+
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +34 -0
new file mode 100644
index 000000000..4775c8ddb
@@ -0,0 +1,34 @@
+From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+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 <[email protected]>
+---
+ 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
+
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +3 -5
index ebc6ba573..b8c9662de 100644
@@ -25,8 +25,9 @@ SECTION = "libs"
 S = "${WORKDIR}/git"
 SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33"
 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
 
@@ -41,9 +42,6 @@ PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"
 
 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
 CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', ' -DMBEDTLS_USE_PSA_CRYPTO', '', d)}"
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 32 lines · Beniamin Sandu
---
 ...cify-an-arch-version-when-enabling-c.patch | 33 ++++++++++++++++++
 ...t-target-attribute-when-building-wit.patch | 34 +++++++++++++++++++
 .../mbedtls/mbedtls_3.4.0.bb                  |  8 ++---
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch
 create mode 100644 meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +16 -0
new file mode 100644
index 000000000..d98d8fa57
@@ -0,0 +1,33 @@
+From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+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 <[email protected]>
+---
+ library/aesce.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch line 26

Quoted 10 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +10 -0
+
+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")

I think you need so add something similar for clang case as well.

Quoted 64 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +7 -0
++#       pragma GCC target ("+crypto")
+ #       define MBEDTLS_POP_TARGET_PRAGMA
+ #   else
+ #       error "Only GCC and Clang supported for MBEDTLS_AESCE_C"
+--
+2.25.1
+
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +34 -0
new file mode 100644
index 000000000..4775c8ddb
@@ -0,0 +1,34 @@
+From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+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 <[email protected]>
+---
+ 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
+
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +3 -2
index ebc6ba573..b8c9662de 100644
@@ -25,8 +25,9 @@ SECTION = "libs"
 S = "${WORKDIR}/git"
 SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33"
 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
 

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF" · line 46

Quoted 6 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -3
@@ -41,9 +42,6 @@ PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"
 
 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)}"
-

It will be good to turn this into a parse warning or note and ignore to build this recipe if crypro is not available on armv8+ tune selection.

Quoted 15 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -1
 # 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)}"
 
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#103575): https://lists.openembedded.org/g/openembedded-devel/message/103575
Mute This Topic: https://lists.openembedded.org/mt/99785788/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 45 lines · On Mon, 26 Jun 2023, 15:12 Khem Raj, <[email protected]> wrote:
Quoted 8 lines · Beniamin Sandu
---
 ...cify-an-arch-version-when-enabling-c.patch | 33 ++++++++++++++++++
 ...t-target-attribute-when-building-wit.patch | 34 +++++++++++++++++++
 .../mbedtls/mbedtls_3.4.0.bb                  |  8 ++---
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 1 line
 create mode 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 2 lines

diff --git

a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 4 lines

new file mode 100644
index 000000000..d98d8fa57
--- /dev/null
+++

b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch line 4

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +4 -0
@@ -0,0 +1,33 @@
+From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+Date: Sun, 25 Jun 2023 19:58:08 +0300
+Subject: [PATCH] aesce: do not specify an arch version when enabling

crypto

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 7 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +7 -0
+ 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]

Quoted 9 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +9 -0
+
+Signed-off-by: Beniamin Sandu <[email protected]>
+---
+ 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
Quoted 9 lines

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch line 26

Quoted 6 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +6 -0
++++ 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")

I think you need so add something similar for clang case as well.

There is 2 patches, I have included one for clang too.

Quoted 79 lines
Quoted 8 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +7 -0
++#       pragma GCC target ("+crypto")
+ #       define MBEDTLS_POP_TARGET_PRAGMA
+ #   else
+ #       error "Only GCC and Clang supported for MBEDTLS_AESCE_C"
+--
+2.25.1
+

diff --git

a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 4 lines

new file mode 100644
index 000000000..4775c8ddb
--- /dev/null
+++

b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch line 4

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +4 -0
@@ -0,0 +1,34 @@
+From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+Date: Mon, 26 Jun 2023 12:07:21 +0300
+Subject: [PATCH] aesce: use correct target attribute when building with

clang

Quoted 13 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +13 -0
+
+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 <[email protected]>
+---
+ library/aesce.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 10 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +10 -0
+
+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)

Review line 28

Quoted 1 line
(quoted diff) +1 -0
++#       pragma clang attribute push (__attribute__((target("aes"))),

apply_to=function)

Review

Quoted 7 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +6 -0
+ #       define MBEDTLS_POP_TARGET_PRAGMA
+ #   elif defined(__GNUC__)
+ #       if __GNUC__ < 6
+--
+2.25.1
+
(quoted diff) +0 -0

mbedtls_3.4.0.bb b/meta-networking/recipes-connectivity/mbedtls/ mbedtls_3.4.0.bb

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs" · line 27

Quoted 7 lines

index ebc6ba573..b8c9662de 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
@@ -25,8 +25,9 @@ SECTION = "libs"
 S = "${WORKDIR}/git"
 SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33"
 SRC_URI = "git://

github.com/ARMmbed/mbedtls.git;protocol=https;branch=master \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs"

Quoted 3 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -2
-           file://run-ptest \
-          "
+

file://0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs" · line 29

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -0
+

file://0002-aesce-use-correct-target-attribute-when-building-wit.patch \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] =

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -0
+       file://run-ptest"
 
 inherit cmake update-alternatives ptest
 
@@ -41,9 +42,6 @@ PACKAGECONFIG[tests] =

"-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"

Quoted 3 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
 EXTRA_OECMAKE = "-DLIB_INSTALL_DIR:STRING=${libdir}"
 
Quoted 9 lines

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = · line 44

Quoted 2 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -2
-# Needs crypto instructions on aarch64
-TUNE_CCARGS_MARCH_OPTS:append:aarch64 =

"${@bb.utils.contains('TUNE_FEATURES', 'crypto', '', '+crypto', d)}"

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF" · line 46

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -1
-

It will be good to turn this into a parse warning or note and ignore to build this recipe if crypro is not available on armv8+ tune selection.

This is not needed anymore, as the flags are specified from source code in both cases, so it should now work with all tune variations, with or without crypto.

Quoted 20 lines

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = · line 44

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
 # For now the only way to enable PSA is to explicitly pass a -D via

CFLAGS

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = · line 45

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
 CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', '

-DMBEDTLS_USE_PSA_CRYPTO', '', d)}"

Quoted 8 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -1
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#103575):

https://lists.openembedded.org/g/openembedded-devel/message/103575

Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/99785788/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [

[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
Quoted 145 lines · Beniamin Sandu
Quoted 45 lines · On Mon, 26 Jun 2023, 15:12 Khem Raj, <[email protected]> wrote:
Quoted 8 lines · Beniamin Sandu
---
 ...cify-an-arch-version-when-enabling-c.patch | 33 ++++++++++++++++++
 ...t-target-attribute-when-building-wit.patch | 34 +++++++++++++++++++
 .../mbedtls/mbedtls_3.4.0.bb                  |  8 ++---
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 1 line
 create mode 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 2 lines

diff --git

a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 4 lines

new file mode 100644
index 000000000..d98d8fa57
--- /dev/null
+++

b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch line 4

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +4 -0
@@ -0,0 +1,33 @@
+From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+Date: Sun, 25 Jun 2023 19:58:08 +0300
+Subject: [PATCH] aesce: do not specify an arch version when enabling

crypto

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 7 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +7 -0
+ 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]

Quoted 9 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +9 -0
+
+Signed-off-by: Beniamin Sandu <[email protected]>
+---
+ 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
Quoted 9 lines

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch line 26

Quoted 6 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +6 -0
++++ 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")

I think you need so add something similar for clang case as well.

There is 2 patches, I have included one for clang too.

Quoted 85 lines
Quoted 8 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +7 -0
++#       pragma GCC target ("+crypto")
+ #       define MBEDTLS_POP_TARGET_PRAGMA
+ #   else
+ #       error "Only GCC and Clang supported for MBEDTLS_AESCE_C"
+--
+2.25.1
+

diff --git

a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 4 lines

new file mode 100644
index 000000000..4775c8ddb
--- /dev/null
+++

b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch line 4

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +4 -0
@@ -0,0 +1,34 @@
+From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+Date: Mon, 26 Jun 2023 12:07:21 +0300
+Subject: [PATCH] aesce: use correct target attribute when building

with clang

Quoted 11 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +11 -0
+
+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 <[email protected]>
+---

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 10 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +10 -0
+ 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"

Review line 27

Quoted 2 lines
(quoted diff) +2 -0
+ #       endif
+-#       pragma clang attribute push

(__attribute__((target("crypto"))), apply_to=function)

Review line 28

Quoted 1 line
(quoted diff) +1 -0
++#       pragma clang attribute push (__attribute__((target("aes"))),

apply_to=function)

Review

Quoted 7 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +6 -0
+ #       define MBEDTLS_POP_TARGET_PRAGMA
+ #   elif defined(__GNUC__)
+ #       if __GNUC__ < 6
+--
+2.25.1
+
(quoted diff) +0 -0

mbedtls_3.4.0.bb b/meta-networking/recipes-connectivity/mbedtls/ mbedtls_3.4.0.bb

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs" · line 27

Quoted 7 lines

index ebc6ba573..b8c9662de 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
@@ -25,8 +25,9 @@ SECTION = "libs"
 S = "${WORKDIR}/git"
 SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33"
 SRC_URI = "git://

github.com/ARMmbed/mbedtls.git;protocol=https;branch=master \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs"

Quoted 3 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -2
-           file://run-ptest \
-          "
+

file://0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs" · line 29

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -0
+

file://0002-aesce-use-correct-target-attribute-when-building-wit.patch \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] =

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -0
+       file://run-ptest"
 
 inherit cmake update-alternatives ptest
 
@@ -41,9 +42,6 @@ PACKAGECONFIG[tests] =

"-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -2
 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)}"

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -1
-
Quoted 9 lines
Quoted 4 lines

It will be good to turn this into a parse warning or note and ignore to build this recipe if crypro is not available on armv8+ tune selection.

This is not needed anymore, as the flags are specified from source code in both cases, so it should now work with all tune variations, with or without crypto.

Compile will work but will it run on a cpu without crypto

Quoted 23 lines
Quoted 22 lines

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = · line 44

Quoted 3 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
 # For now the only way to enable PSA is to explicitly pass a -D via

CFLAGS

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = · line 45

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
 CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', '

-DMBEDTLS_USE_PSA_CRYPTO', '', d)}"

Quoted 8 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -1
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#103575):

https://lists.openembedded.org/g/openembedded-devel/message/103575

Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/99785788/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub

[[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 155 lines · On Mon, 26 Jun 2023, 16:00 Khem Raj, <[email protected]> wrote:
Quoted 150 lines · Beniamin Sandu
Quoted 45 lines · On Mon, 26 Jun 2023, 15:12 Khem Raj, <[email protected]> wrote:
Quoted 8 lines · Beniamin Sandu
---
 ...cify-an-arch-version-when-enabling-c.patch | 33 ++++++++++++++++++
 ...t-target-attribute-when-building-wit.patch | 34 +++++++++++++++++++
 .../mbedtls/mbedtls_3.4.0.bb                  |  8 ++---
 3 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 1 line
 create mode 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 2 lines

diff --git

a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 4 lines

new file mode 100644
index 000000000..d98d8fa57
--- /dev/null
+++

b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch line 4

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +4 -0
@@ -0,0 +1,33 @@
+From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+Date: Sun, 25 Jun 2023 19:58:08 +0300
+Subject: [PATCH] aesce: do not specify an arch version when enabling

crypto

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch

Quoted 7 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +7 -0
+ 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]

Quoted 9 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +9 -0
+
+Signed-off-by: Beniamin Sandu <[email protected]>
+---
+ 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
Quoted 9 lines

meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch line 26

Quoted 6 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +6 -0
++++ 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")

I think you need so add something similar for clang case as well.

There is 2 patches, I have included one for clang too.

Quoted 89 lines
Quoted 8 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch new file +7 -0
++#       pragma GCC target ("+crypto")
+ #       define MBEDTLS_POP_TARGET_PRAGMA
+ #   else
+ #       error "Only GCC and Clang supported for MBEDTLS_AESCE_C"
+--
+2.25.1
+

diff --git

a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 4 lines

new file mode 100644
index 000000000..4775c8ddb
--- /dev/null
+++

b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch line 4

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +4 -0
@@ -0,0 +1,34 @@
+From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001
+From: Beniamin Sandu <[email protected]>
+Date: Mon, 26 Jun 2023 12:07:21 +0300
+Subject: [PATCH] aesce: use correct target attribute when building

with clang

Quoted 11 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +11 -0
+
+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 <[email protected]>
+---

meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch

Quoted 10 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +10 -0
+ 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"

Review line 27

Quoted 2 lines
(quoted diff) +2 -0
+ #       endif
+-#       pragma clang attribute push

(__attribute__((target("crypto"))), apply_to=function)

Review line 28

Quoted 1 line
(quoted diff) +1 -0
++#       pragma clang attribute push (__attribute__((target("aes"))),

apply_to=function)

Review

Quoted 7 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch new file +6 -0
+ #       define MBEDTLS_POP_TARGET_PRAGMA
+ #   elif defined(__GNUC__)
+ #       if __GNUC__ < 6
+--
+2.25.1
+
(quoted diff) +0 -0

mbedtls_3.4.0.bb b/meta-networking/recipes-connectivity/mbedtls/ mbedtls_3.4.0.bb

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs" · line 27

Quoted 7 lines

index ebc6ba573..b8c9662de 100644

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
@@ -25,8 +25,9 @@ SECTION = "libs"
 S = "${WORKDIR}/git"
 SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33"
 SRC_URI = "git://

github.com/ARMmbed/mbedtls.git;protocol=https;branch=master \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs"

Quoted 3 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -2
-           file://run-ptest \
-          "
+

file://0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb SECTION = "libs" · line 29

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -0
+

file://0002-aesce-use-correct-target-attribute-when-building-wit.patch \

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] =

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +1 -0
+       file://run-ptest"
 
 inherit cmake update-alternatives ptest
 
@@ -41,9 +42,6 @@ PACKAGECONFIG[tests] =

"-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"

Quoted 5 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -2
 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)}"

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF" · line 46

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -1
-

It will be good to turn this into a parse warning or note and ignore to build this recipe if crypro is not available on armv8+ tune selection.

Quoted 7 lines
Quoted 4 lines

This is not needed anymore, as the flags are specified from source code in both cases, so it should now work with all tune variations, with or without crypto.

Compile will work but will it run on a cpu without crypto

I have run the ptest collection on a couple of variations (with/without crypto), and it seemed fine.

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = · line 44

Quoted 2 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
 # For now the only way to enable PSA is to explicitly pass a -D via

CFLAGS

meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb PACKAGECONFIG[tests] = · line 45

Quoted 1 line
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -0
 CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', '

-DMBEDTLS_USE_PSA_CRYPTO', '', d)}"

Quoted 8 lines
meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb +0 -1
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#103575):

https://lists.openembedded.org/g/openembedded-devel/message/103575

Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/99785788/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub

[[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-