From: Petr Tesarik Subject: Define SYS_getrandom if needed Upstream: never, build fix for SLE12 SLE12 did not provide a definition for SYS_getrandom. Signed-off-by: Petr Tesarik --- configure.ac | 1 + kexec/arch/arm64/kexec-arm64.c | 5 +++++ kexec/arch/i386/x86-linux-setup.c | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) --- a/configure.ac +++ b/configure.ac @@ -203,6 +203,7 @@ if test "$with_xen" = dl ; then AC_MSG_NOTICE([Xen support disabled]))]) fi +AC_CHECK_HEADERS([sys/random.h]) dnl Check for the Xen kexec_status hypercall - reachable from --with-xen=yes|dl if test "$ac_cv_lib_xenctrl_xc_kexec_load" = yes ; then AC_CHECK_LIB(xenctrl, xc_kexec_status, --- a/kexec/arch/arm64/kexec-arm64.c +++ b/kexec/arch/arm64/kexec-arm64.c @@ -34,6 +34,11 @@ #include "mem_regions.h" #include "arch/options.h" +#ifndef __NR_getrandom +#define __NR_getrandom 278 +__SYSCALL(__NR_getrandom, sys_getrandom) +#endif + #define ROOT_NODE_ADDR_CELLS_DEFAULT 1 #define ROOT_NODE_SIZE_CELLS_DEFAULT 1 --- a/kexec/arch/i386/x86-linux-setup.c +++ b/kexec/arch/i386/x86-linux-setup.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -38,6 +37,16 @@ #include "x86-linux-setup.h" #include "../../kexec/kexec-syscall.h" +#ifdef HAVE_SYS_RANDOM_H +#include +#else +#include +static ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) +{ + return syscall(SYS_getrandom, buf, buflen, flags); +} +#endif + #ifndef VIDEO_CAPABILITY_64BIT_BASE #define VIDEO_CAPABILITY_64BIT_BASE (1 << 1) /* Frame buffer base is 64-bit */ #endif