Received: from eggs.gnu.org ([2001:4830:134:3::10]:58685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXQkk-0007IS-Az for qemu-devel@nongnu.org; Sun, 21 Feb 2016 04:56:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXQkh-0003Uv-4c for qemu-devel@nongnu.org; Sun, 21 Feb 2016 04:56:34 -0500 Received: from smtp1-g21.free.fr ([212.27.42.1]:14934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXQkg-0003UV-Ui for qemu-devel@nongnu.org; Sun, 21 Feb 2016 04:56:31 -0500 From: Laurent Vivier Date: Sun, 21 Feb 2016 10:56:23 +0100 Message-Id: <1456048583-23261-1-git-send-email-laurent@vivier.eu> Subject: [Qemu-devel] [PATCH v2] linux-user: add getrandom() syscall List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio Cc: qemu-devel@nongnu.org, Laurent Vivier 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 --- v2: fix compilation on AArch64 by conditionally define getrandom() on TARGET_NR_getrandom AND __NR_getrandom. linux-user/syscall.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a051669..5126aac 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -254,6 +254,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, }, @@ -8234,6 +8237,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.5.0