Skip to content

Commit

Permalink
[qemu-usermode] [qemu-usermode-static] Add patch adding the getrandom…
Browse files Browse the repository at this point in the history
…() syscall ; JB#44440

This is needed as the "Unsupported syscall: 384" messages break e.g.
python3 tests on arm.

Signed-off-by: Aapi Hämäläinen <aapi.hamalainen@jollamobile.com>
  • Loading branch information
uaoh committed May 7, 2019
1 parent e322eb0 commit b3c4c7f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
48 changes: 48 additions & 0 deletions 0001-linux-user-add-getrandom-syscall.patch
@@ -0,0 +1,48 @@
From f894efd19917321844b31e5dd7a061fdc6fb322d Mon Sep 17 00:00:00 2001
From: Laurent Vivier <laurent@vivier.eu>
Date: Sun, 21 Feb 2016 10:56:23 +0100
Subject: [PATCH] linux-user: add getrandom() syscall

getrandom() has been introduced in kernel 3.17 and is now used during
the boot sequence of Debian unstable (stretch/sid).

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 539183a788..951753143c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -249,6 +249,9 @@ _syscall2(int, ioprio_get, int, which, int, who)
#if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)
_syscall3(int, ioprio_set, int, which, int, who, int, ioprio)
#endif
+#if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)
+_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags)
+#endif

static bitmask_transtbl fcntl_flags_tbl[] = {
{ TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, },
@@ -7541,6 +7544,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = get_errno(shutdown(arg1, arg2));
break;
#endif
+#if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)
+ case TARGET_NR_getrandom:
+ p = lock_user(VERIFY_WRITE, arg1, arg2, 0);
+ if (!p) {
+ goto efault;
+ }
+ ret = get_errno(getrandom(p, arg2, arg3));
+ unlock_user(p, arg1, ret);
+ break;
+#endif
#ifdef TARGET_NR_socket
case TARGET_NR_socket:
ret = do_socket(arg1, arg2, arg3);
--
2.17.1

3 changes: 3 additions & 0 deletions qemu-usermode.changes
@@ -1,3 +1,6 @@
* Tue May 7 2019 Aapi Hämäläinen <aapi.hamalainen@jollamobile.com> - 2.1.0-9
- Add patch that wires in the getrandom() syscall JB#44440

* Mon Apr 8 2019 Aapi Hämäläinen <aapi.hamalainen@jollamobile.com> - 2.1.0-8
- Update qemu-binfmt-conf.sh from upstream JB#45154

Expand Down
5 changes: 4 additions & 1 deletion qemu-usermode.spec
Expand Up @@ -4,7 +4,7 @@
Name: qemu-usermode
Summary: Universal CPU emulator
Version: 2.1.0
Release: 8
Release: 9
Group: System/Emulators/PC
License: GPLv2
ExclusiveArch: %{ix86}
Expand All @@ -20,6 +20,7 @@ Patch5: 0025-linux-user-Run-multi-threaded-code-on-one-core.patch
Patch6: 0026-linux-user-lock-tb-flushing-too.patch
Patch7: fix-strex.patch
Patch8: glibc_2.26_support.patch
patch9: 0001-linux-user-add-getrandom-syscall.patch
BuildRequires: pkgconfig(ext2fs)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(zlib)
Expand Down Expand Up @@ -57,6 +58,8 @@ QEMU is an extremely well-performing CPU emulator that allows you to choose betw
%patch7 -p1
# glibc_2.26_support.patch
%patch8 -p1
# 0001-linux-user-add-getrandom-syscall.patch
%patch9 -p1

%build
CFLAGS=`echo $CFLAGS | sed 's|-fno-omit-frame-pointer||g'` ; export CFLAGS ;
Expand Down

0 comments on commit b3c4c7f

Please sign in to comment.