Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 1 | From a99fc685214452aedabf9ac105bb99357006aa26 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 2 | From: Andrea Adami <andrea.adami@gmail.com> |
| 3 | Date: Wed, 5 Sep 2018 17:07:48 +0200 |
| 4 | Subject: [PATCH] kexec-arm64.c: workaround for getrandom() syscall |
| 5 | |
| 6 | The syscall was added to OE's klibc. |
| 7 | Fix |
| 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 | |
| 12 | and |
| 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 18 | Upstream-Status: Inappropriate [klibc specific] |
| 19 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 20 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 21 | --- |
| 22 | kexec/arch/arm64/kexec-arm64.c | 12 +++++++++++- |
| 23 | 1 file changed, 11 insertions(+), 1 deletion(-) |
| 24 | |
| 25 | diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 26 | index b143e86..88d4168 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 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) { |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 57 | fprintf(stderr, "%s: Reading random bytes failed.\n", |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 58 | __func__); |