blob: df7b0a7782aa43ee4d253b00ee36a336134f76a4 [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From a99fc685214452aedabf9ac105bb99357006aa26 Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Andrea Adami <andrea.adami@gmail.com>
3Date: Wed, 5 Sep 2018 17:07:48 +0200
4Subject: [PATCH] kexec-arm64.c: workaround for getrandom() syscall
5
6The syscall was added to OE's klibc.
7Fix
8
9| ../git/kexec/arch/arm64/kexec-arm64.c:19:10: fatal error: syscall.h: No such file or directory
10| #include <syscall.h>
11
12and
13
14| ../git/kexec/arch/arm64/kexec-arm64.c: In function 'setup_2nd_dtb':
15| ../git/kexec/arch/arm64/kexec-arm64.c:499:12: warning: implicit declaration of function 'getrandom'; did you mean 'srandom'? [-Wimplicit-function-declaration]
16| result = getrandom(&fdt_val64,
17
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018Upstream-Status: Inappropriate [klibc specific]
19Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Brad Bishop26bdd442019-08-16 17:08:17 -040020
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080021---
22 kexec/arch/arm64/kexec-arm64.c | 12 +++++++++++-
23 1 file changed, 11 insertions(+), 1 deletion(-)
24
25diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
Brad Bishop26bdd442019-08-16 17:08:17 -040026index b143e86..88d4168 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027--- a/kexec/arch/arm64/kexec-arm64.c
28+++ b/kexec/arch/arm64/kexec-arm64.c
29@@ -16,7 +16,11 @@
30 #include <elf.h>
31
32 #include <unistd.h>
33+
34+#ifndef __KLIBC__
35 #include <syscall.h>
36+#endif
37+
38 #include <errno.h>
39 #include <linux/random.h>
40
41@@ -487,10 +491,16 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash)
42 * have a valid random seed to pass to the
43 * secondary kernel.
44 */
45+#ifndef __KLIBC__
46 result = syscall(SYS_getrandom, &fdt_val64,
47 sizeof(fdt_val64),
48 GRND_NONBLOCK);
49-
50+#else
51+ extern ssize_t getrandom(void *, size_t, unsigned int);
52+ result = getrandom(&fdt_val64,
53+ sizeof(fdt_val64),
54+ GRND_NONBLOCK);
55+#endif
56 if(result == -1) {
Brad Bishop26bdd442019-08-16 17:08:17 -040057 fprintf(stderr, "%s: Reading random bytes failed.\n",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080058 __func__);