1From a99fc685214452aedabf9ac105bb99357006aa26 Mon Sep 17 00:00:00 2001 2From: 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 18Upstream-Status: Inappropriate [klibc specific] 19Signed-off-by: Andrea Adami <andrea.adami@gmail.com> 20 21--- 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 26index b143e86..88d4168 100644 27--- 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) { 57 fprintf(stderr, "%s: Reading random bytes failed.\n", 58 __func__); 59