summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity')
-rw-r--r--meta/recipes-connectivity/openssl/openssl/0003-Add-support-for-io_pgetevents_time64-syscall.patch62
-rw-r--r--meta/recipes-connectivity/openssl/openssl/0004-Fixup-support-for-io_pgetevents_time64-syscall.patch99
-rw-r--r--meta/recipes-connectivity/openssl/openssl_1.1.1j.bb5
3 files changed, 166 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssl/openssl/0003-Add-support-for-io_pgetevents_time64-syscall.patch b/meta/recipes-connectivity/openssl/openssl/0003-Add-support-for-io_pgetevents_time64-syscall.patch
new file mode 100644
index 0000000000..d62b9344c1
--- /dev/null
+++ b/meta/recipes-connectivity/openssl/openssl/0003-Add-support-for-io_pgetevents_time64-syscall.patch
@@ -0,0 +1,62 @@
1From 5b5e2985f355c8e99c196d9ce5d02c15bebadfbc Mon Sep 17 00:00:00 2001
2From: Alistair Francis <alistair.francis@wdc.com>
3Date: Thu, 29 Aug 2019 13:56:21 -0700
4Subject: [PATCH] Add support for io_pgetevents_time64 syscall
5
632-bit architectures that are y2038 safe don't include syscalls that use
732-bit time_t. Instead these architectures have suffixed syscalls that
8always use a 64-bit time_t. In the case of the io_getevents syscall the
9syscall has been replaced with the io_pgetevents_time64 syscall instead.
10
11This patch changes the io_getevents() function to use the correct
12syscall based on the avaliable syscalls and the time_t size. We will
13only use the new 64-bit time_t syscall if the architecture is using a
1464-bit time_t. This is to avoid having to deal with 32/64-bit
15conversions and relying on a 64-bit timespec struct on 32-bit time_t
16platforms. As of Linux 5.3 there are no 32-bit time_t architectures
17without __NR_io_getevents. In the future if a 32-bit time_t architecture
18wants to use the 64-bit syscalls we can handle the conversion.
19
20This fixes build failures on 32-bit RISC-V.
21
22Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
23
24Reviewed-by: Richard Levitte <levitte@openssl.org>
25Reviewed-by: Paul Dale <paul.dale@oracle.com>
26(Merged from https://github.com/openssl/openssl/pull/9819)
27Upstream-Status: Accepted
28---
29 engines/e_afalg.c | 16 ++++++++++++++++
30 1 file changed, 16 insertions(+)
31
32diff --git a/engines/e_afalg.c b/engines/e_afalg.c
33index dacbe358cb..99516cb1bb 100644
34--- a/engines/e_afalg.c
35+++ b/engines/e_afalg.c
36@@ -125,7 +125,23 @@ static ossl_inline int io_getevents(aio_context_t ctx, long min, long max,
37 struct io_event *events,
38 struct timespec *timeout)
39 {
40+#if defined(__NR_io_getevents)
41 return syscall(__NR_io_getevents, ctx, min, max, events, timeout);
42+#elif defined(__NR_io_pgetevents_time64)
43+ /* Let's only support the 64 suffix syscalls for 64-bit time_t.
44+ * This simplifies the code for us as we don't need to use a 64-bit
45+ * version of timespec with a 32-bit time_t and handle converting
46+ * between 64-bit and 32-bit times and check for overflows.
47+ */
48+ if (sizeof(timeout->tv_sec) == 8)
49+ return syscall(__NR_io_pgetevents_time64, ctx, min, max, events, timeout, NULL);
50+ else {
51+ errno = ENOSYS;
52+ return -1;
53+ }
54+#else
55+# error "We require either the io_getevents syscall or __NR_io_pgetevents_time64."
56+#endif
57 }
58
59 static void afalg_waitfd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
60--
612.30.1
62
diff --git a/meta/recipes-connectivity/openssl/openssl/0004-Fixup-support-for-io_pgetevents_time64-syscall.patch b/meta/recipes-connectivity/openssl/openssl/0004-Fixup-support-for-io_pgetevents_time64-syscall.patch
new file mode 100644
index 0000000000..c8bc6f5c68
--- /dev/null
+++ b/meta/recipes-connectivity/openssl/openssl/0004-Fixup-support-for-io_pgetevents_time64-syscall.patch
@@ -0,0 +1,99 @@
1From e5499a3cac1e823c3e0697e8667e952317b70cc8 Mon Sep 17 00:00:00 2001
2From: Alistair Francis <alistair.francis@wdc.com>
3Date: Thu, 4 Mar 2021 12:10:11 -0500
4Subject: [PATCH] Fixup support for io_pgetevents_time64 syscall
5
6This is a fixup for the original commit 5b5e2985f355c8e99c196d9ce5d02c15bebadfbc
7"Add support for io_pgetevents_time64 syscall" that didn't correctly
8work for 32-bit architecutres with a 64-bit time_t that aren't RISC-V.
9
10For a full discussion of the issue see:
11https://github.com/openssl/openssl/commit/5b5e2985f355c8e99c196d9ce5d02c15bebadfbc
12
13Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
15Reviewed-by: Tomas Mraz <tomas@openssl.org>
16Reviewed-by: Paul Dale <pauli@openssl.org>
17(Merged from https://github.com/openssl/openssl/pull/14432)
18Upstream-Status: Accepted
19---
20 engines/e_afalg.c | 55 ++++++++++++++++++++++++++++++++++++-----------
21 1 file changed, 42 insertions(+), 13 deletions(-)
22
23diff --git a/engines/e_afalg.c b/engines/e_afalg.c
24index 9480d7c24b..4e9d67db2d 100644
25--- a/engines/e_afalg.c
26+++ b/engines/e_afalg.c
27@@ -124,27 +124,56 @@ static ossl_inline int io_read(aio_context_t ctx, long n, struct iocb **iocb)
28 return syscall(__NR_io_submit, ctx, n, iocb);
29 }
30
31+/* A version of 'struct timespec' with 32-bit time_t and nanoseconds. */
32+struct __timespec32
33+{
34+ __kernel_long_t tv_sec;
35+ __kernel_long_t tv_nsec;
36+};
37+
38 static ossl_inline int io_getevents(aio_context_t ctx, long min, long max,
39 struct io_event *events,
40 struct timespec *timeout)
41 {
42+#if defined(__NR_io_pgetevents_time64)
43+ /* Check if we are a 32-bit architecture with a 64-bit time_t */
44+ if (sizeof(*timeout) != sizeof(struct __timespec32)) {
45+ int ret = syscall(__NR_io_pgetevents_time64, ctx, min, max, events,
46+ timeout, NULL);
47+ if (ret == 0 || errno != ENOSYS)
48+ return ret;
49+ }
50+#endif
51+
52 #if defined(__NR_io_getevents)
53- return syscall(__NR_io_getevents, ctx, min, max, events, timeout);
54-#elif defined(__NR_io_pgetevents_time64)
55- /* Let's only support the 64 suffix syscalls for 64-bit time_t.
56- * This simplifies the code for us as we don't need to use a 64-bit
57- * version of timespec with a 32-bit time_t and handle converting
58- * between 64-bit and 32-bit times and check for overflows.
59- */
60- if (sizeof(timeout->tv_sec) == 8)
61- return syscall(__NR_io_pgetevents_time64, ctx, min, max, events, timeout, NULL);
62+ if (sizeof(*timeout) == sizeof(struct __timespec32))
63+ /*
64+ * time_t matches our architecture length, we can just use
65+ * __NR_io_getevents
66+ */
67+ return syscall(__NR_io_getevents, ctx, min, max, events, timeout);
68 else {
69- errno = ENOSYS;
70- return -1;
71+ /*
72+ * We don't have __NR_io_pgetevents_time64, but we are using a
73+ * 64-bit time_t on a 32-bit architecture. If we can fit the
74+ * timeout value in a 32-bit time_t, then let's do that
75+ * and then use the __NR_io_getevents syscall.
76+ */
77+ if (timeout && timeout->tv_sec == (long)timeout->tv_sec) {
78+ struct __timespec32 ts32;
79+
80+ ts32.tv_sec = (__kernel_long_t) timeout->tv_sec;
81+ ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec;
82+
83+ return syscall(__NR_io_getevents, ctx, min, max, events, ts32);
84+ } else {
85+ return syscall(__NR_io_getevents, ctx, min, max, events, NULL);
86+ }
87 }
88-#else
89-# error "We require either the io_getevents syscall or __NR_io_pgetevents_time64."
90 #endif
91+
92+ errno = ENOSYS;
93+ return -1;
94 }
95
96 static void afalg_waitfd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
97--
982.30.1
99
diff --git a/meta/recipes-connectivity/openssl/openssl_1.1.1j.bb b/meta/recipes-connectivity/openssl/openssl_1.1.1j.bb
index 181790e6ab..ed6d7e0cd4 100644
--- a/meta/recipes-connectivity/openssl/openssl_1.1.1j.bb
+++ b/meta/recipes-connectivity/openssl/openssl_1.1.1j.bb
@@ -23,6 +23,11 @@ SRC_URI_append_class-nativesdk = " \
23 file://environment.d-openssl.sh \ 23 file://environment.d-openssl.sh \
24 " 24 "
25 25
26SRC_URI_append_riscv32 = " \
27 file://0003-Add-support-for-io_pgetevents_time64-syscall.patch \
28 file://0004-Fixup-support-for-io_pgetevents_time64-syscall.patch \
29 "
30
26SRC_URI[sha256sum] = "aaf2fcb575cdf6491b98ab4829abf78a3dec8402b8b81efc8f23c00d443981bf" 31SRC_URI[sha256sum] = "aaf2fcb575cdf6491b98ab4829abf78a3dec8402b8b81efc8f23c00d443981bf"
27 32
28inherit lib_package multilib_header multilib_script ptest 33inherit lib_package multilib_header multilib_script ptest