diff options
| -rw-r--r-- | meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-AES-NI-use-target-attributes-for-x86-32-bit-intrinsi.patch | 87 | ||||
| -rw-r--r-- | meta-networking/recipes-connectivity/mbedtls/mbedtls_3.6.0.bb (renamed from meta-networking/recipes-connectivity/mbedtls/mbedtls_3.5.2.bb) | 8 |
2 files changed, 6 insertions, 89 deletions
diff --git a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-AES-NI-use-target-attributes-for-x86-32-bit-intrinsi.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-AES-NI-use-target-attributes-for-x86-32-bit-intrinsi.patch deleted file mode 100644 index 5030fb99f9..0000000000 --- a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-AES-NI-use-target-attributes-for-x86-32-bit-intrinsi.patch +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | From 80d3e73ad0648f558a067a9dbfe3bc80e6b614f8 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 3 | Date: Mon, 30 Oct 2023 19:15:56 +0000 | ||
| 4 | Subject: [PATCH] AES-NI: use target attributes for x86 32-bit intrinsics | ||
| 5 | |||
| 6 | This way we build with 32-bit gcc/clang out of the box. | ||
| 7 | We also fallback to assembly for 64-bit clang-cl if needed cpu | ||
| 8 | flags are not provided, instead of throwing an error. | ||
| 9 | |||
| 10 | Upstream-Status: Backport [https://github.com/Mbed-TLS/mbedtls/commit/800f2b7c020678a84abfa9688962b91c36e6693d] | ||
| 11 | |||
| 12 | Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 13 | --- | ||
| 14 | library/aesni.c | 20 ++++++++++++++++++++ | ||
| 15 | library/aesni.h | 8 +++++--- | ||
| 16 | 2 files changed, 25 insertions(+), 3 deletions(-) | ||
| 17 | |||
| 18 | diff --git a/library/aesni.c b/library/aesni.c | ||
| 19 | index 5f25a8249..481fa3822 100644 | ||
| 20 | --- a/library/aesni.c | ||
| 21 | +++ b/library/aesni.c | ||
| 22 | @@ -41,6 +41,17 @@ | ||
| 23 | #include <immintrin.h> | ||
| 24 | #endif | ||
| 25 | |||
| 26 | +#if defined(MBEDTLS_ARCH_IS_X86) | ||
| 27 | +#if defined(MBEDTLS_COMPILER_IS_GCC) | ||
| 28 | +#pragma GCC push_options | ||
| 29 | +#pragma GCC target ("pclmul,sse2,aes") | ||
| 30 | +#define MBEDTLS_POP_TARGET_PRAGMA | ||
| 31 | +#elif defined(__clang__) | ||
| 32 | +#pragma clang attribute push (__attribute__((target("pclmul,sse2,aes"))), apply_to=function) | ||
| 33 | +#define MBEDTLS_POP_TARGET_PRAGMA | ||
| 34 | +#endif | ||
| 35 | +#endif | ||
| 36 | + | ||
| 37 | #if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY) | ||
| 38 | /* | ||
| 39 | * AES-NI support detection routine | ||
| 40 | @@ -396,6 +407,15 @@ static void aesni_setkey_enc_256(unsigned char *rk_bytes, | ||
| 41 | } | ||
| 42 | #endif /* !MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */ | ||
| 43 | |||
| 44 | +#if defined(MBEDTLS_POP_TARGET_PRAGMA) | ||
| 45 | +#if defined(__clang__) | ||
| 46 | +#pragma clang attribute pop | ||
| 47 | +#elif defined(__GNUC__) | ||
| 48 | +#pragma GCC pop_options | ||
| 49 | +#endif | ||
| 50 | +#undef MBEDTLS_POP_TARGET_PRAGMA | ||
| 51 | +#endif | ||
| 52 | + | ||
| 53 | #else /* MBEDTLS_AESNI_HAVE_CODE == 1 */ | ||
| 54 | |||
| 55 | #if defined(__has_feature) | ||
| 56 | diff --git a/library/aesni.h b/library/aesni.h | ||
| 57 | index ba1429029..37ae02c82 100644 | ||
| 58 | --- a/library/aesni.h | ||
| 59 | +++ b/library/aesni.h | ||
| 60 | @@ -50,6 +50,10 @@ | ||
| 61 | #if defined(__GNUC__) && defined(__AES__) && defined(__PCLMUL__) | ||
| 62 | #define MBEDTLS_AESNI_HAVE_INTRINSICS | ||
| 63 | #endif | ||
| 64 | +/* For 32-bit, we only support intrinsics */ | ||
| 65 | +#if defined(MBEDTLS_ARCH_IS_X86) && (defined(__GNUC__) || defined(__clang__)) | ||
| 66 | +#define MBEDTLS_AESNI_HAVE_INTRINSICS | ||
| 67 | +#endif | ||
| 68 | |||
| 69 | /* Choose the implementation of AESNI, if one is available. | ||
| 70 | * | ||
| 71 | @@ -60,13 +64,11 @@ | ||
| 72 | #if defined(MBEDTLS_AESNI_HAVE_INTRINSICS) | ||
| 73 | #define MBEDTLS_AESNI_HAVE_CODE 2 // via intrinsics | ||
| 74 | #elif defined(MBEDTLS_HAVE_ASM) && \ | ||
| 75 | - defined(__GNUC__) && defined(MBEDTLS_ARCH_IS_X64) | ||
| 76 | + (defined(__GNUC__) || defined(__clang__)) && defined(MBEDTLS_ARCH_IS_X64) | ||
| 77 | /* Can we do AESNI with inline assembly? | ||
| 78 | * (Only implemented with gas syntax, only for 64-bit.) | ||
| 79 | */ | ||
| 80 | #define MBEDTLS_AESNI_HAVE_CODE 1 // via assembly | ||
| 81 | -#elif defined(__GNUC__) | ||
| 82 | -# error "Must use `-mpclmul -msse2 -maes` for MBEDTLS_AESNI_C" | ||
| 83 | #else | ||
| 84 | #error "MBEDTLS_AESNI_C defined, but neither intrinsics nor assembly available" | ||
| 85 | #endif | ||
| 86 | -- | ||
| 87 | 2.34.1 | ||
diff --git a/meta-networking/recipes-connectivity/mbedtls/mbedtls_3.5.2.bb b/meta-networking/recipes-connectivity/mbedtls/mbedtls_3.6.0.bb index d61c54edb8..92a2de82a3 100644 --- a/meta-networking/recipes-connectivity/mbedtls/mbedtls_3.5.2.bb +++ b/meta-networking/recipes-connectivity/mbedtls/mbedtls_3.6.0.bb | |||
| @@ -23,10 +23,14 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=379d5819937a6c2f1ef1630d341e026d" | |||
| 23 | SECTION = "libs" | 23 | SECTION = "libs" |
| 24 | 24 | ||
| 25 | S = "${WORKDIR}/git" | 25 | S = "${WORKDIR}/git" |
| 26 | SRCREV = "daca7a3979c22da155ec9dce49ab1abf3b65d3a9" | ||
| 27 | SRC_URI = "git://github.com/Mbed-TLS/mbedtls.git;protocol=https;branch=master \ | 26 | SRC_URI = "git://github.com/Mbed-TLS/mbedtls.git;protocol=https;branch=master \ |
| 28 | file://0001-AES-NI-use-target-attributes-for-x86-32-bit-intrinsi.patch \ | 27 | git://github.com/Mbed-TLS/mbedtls-framework.git;protocol=https;branch=main;destsuffix=git/framework;name=framework \ |
| 29 | file://run-ptest" | 28 | file://run-ptest" |
| 29 | |||
| 30 | SRCREV = "2ca6c285a0dd3f33982dd57299012dacab1ff206" | ||
| 31 | SRCREV_framework = "750634d3a51eb9d61b59fd5d801546927c946588" | ||
| 32 | SRCREV_FORMAT .= "_framework" | ||
| 33 | |||
| 30 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)" | 34 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)" |
| 31 | 35 | ||
| 32 | inherit cmake update-alternatives ptest | 36 | inherit cmake update-alternatives ptest |
