* updated knights (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / package / security / openssl / riscv32.patch
blob2c7f0ed172399b3be61e1b3b6464bf626b429b20
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/*/openssl/riscv32.patch
5 # Copyright (C) 2021 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 From 5b5e2985f355c8e99c196d9ce5d02c15bebadfbc Mon Sep 17 00:00:00 2001
18 From: Alistair Francis <alistair.francis@wdc.com>
19 Date: Thu, 29 Aug 2019 13:56:21 -0700
20 Subject: [PATCH] Add support for io_pgetevents_time64 syscall
22 32-bit architectures that are y2038 safe don't include syscalls that use
23 32-bit time_t. Instead these architectures have suffixed syscalls that
24 always use a 64-bit time_t. In the case of the io_getevents syscall the
25 syscall has been replaced with the io_pgetevents_time64 syscall instead.
27 This patch changes the io_getevents() function to use the correct
28 syscall based on the avaliable syscalls and the time_t size. We will
29 only use the new 64-bit time_t syscall if the architecture is using a
30 64-bit time_t. This is to avoid having to deal with 32/64-bit
31 conversions and relying on a 64-bit timespec struct on 32-bit time_t
32 platforms. As of Linux 5.3 there are no 32-bit time_t architectures
33 without __NR_io_getevents. In the future if a 32-bit time_t architecture
34 wants to use the 64-bit syscalls we can handle the conversion.
36 This fixes build failures on 32-bit RISC-V.
38 Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
40 Reviewed-by: Richard Levitte <levitte@openssl.org>
41 Reviewed-by: Paul Dale <paul.dale@oracle.com>
42 (Merged from https://github.com/openssl/openssl/pull/9819)
43 ---
44 engines/e_afalg.c | 16 ++++++++++++++++
45 1 file changed, 16 insertions(+)
47 diff --git a/engines/e_afalg.c b/engines/e_afalg.c
48 index dacbe358cb..99516cb1bb 100644
49 --- a/engines/e_afalg.c
50 +++ b/engines/e_afalg.c
51 @@ -125,7 +125,23 @@ static ossl_inline int io_getevents(aio_context_t ctx, long min, long max,
52 struct io_event *events,
53 struct timespec *timeout)
55 +#if defined(__NR_io_getevents)
56 return syscall(__NR_io_getevents, ctx, min, max, events, timeout);
57 +#elif defined(__NR_io_pgetevents_time64)
58 + /* Let's only support the 64 suffix syscalls for 64-bit time_t.
59 + * This simplifies the code for us as we don't need to use a 64-bit
60 + * version of timespec with a 32-bit time_t and handle converting
61 + * between 64-bit and 32-bit times and check for overflows.
62 + */
63 + if (sizeof(timeout->tv_sec) == 8)
64 + return syscall(__NR_io_pgetevents_time64, ctx, min, max, events, timeout, NULL);
65 + else {
66 + errno = ENOSYS;
67 + return -1;
68 + }
69 +#else
70 +# error "We require either the io_getevents syscall or __NR_io_pgetevents_time64."
71 +#endif
74 static void afalg_waitfd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
75 --
76 2.26.2