Files
meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch
Khem Raj d3529a351d kexec-tools-klibc: Update to latest 2.0.32 release
Add riscv64 support
Rework klibc support patches

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Andrea Adami <andrea.adami@gmail.com>
2025-12-14 10:11:17 -08:00

57 lines
1.6 KiB
Diff

From a99fc685214452aedabf9ac105bb99357006aa26 Mon Sep 17 00:00:00 2001
From: Andrea Adami <andrea.adami@gmail.com>
Date: Wed, 5 Sep 2018 17:07:48 +0200
Subject: [PATCH] kexec-arm64.c: workaround for getrandom() syscall
The syscall was added to OE's klibc.
Fix
| ../git/kexec/arch/arm64/kexec-arm64.c:19:10: fatal error: syscall.h: No such file or directory
| #include <syscall.h>
and
| ../git/kexec/arch/arm64/kexec-arm64.c: In function 'setup_2nd_dtb':
| ../git/kexec/arch/arm64/kexec-arm64.c:499:12: warning: implicit declaration of function 'getrandom'; did you mean 'srandom'? [-Wimplicit-function-declaration]
| result = getrandom(&fdt_val64,
Upstream-Status: Inappropriate [klibc specific]
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
---
kexec/arch/arm64/kexec-arm64.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -19,7 +19,11 @@
#include <elf_info.h>
#include <unistd.h>
+
+#ifndef __KLIBC__
#include <syscall.h>
+#endif
+
#include <errno.h>
#include <linux/random.h>
@@ -595,10 +599,16 @@ static int setup_2nd_dtb(struct dtb *dtb
* have a valid random seed to pass to the
* secondary kernel.
*/
+#ifndef __KLIBC__
result = syscall(SYS_getrandom, &fdt_val64,
sizeof(fdt_val64),
GRND_NONBLOCK);
-
+#else
+ extern ssize_t getrandom(void *, size_t, unsigned int);
+ result = getrandom(&fdt_val64,
+ sizeof(fdt_val64),
+ GRND_NONBLOCK);
+#endif
if(result == -1) {
fprintf(stderr, "%s: Reading random bytes failed.\n",
__func__);