From patchwork Fri Feb 5 20:00:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 8239161 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E3A49BEEE5 for ; Fri, 5 Feb 2016 20:01:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8C2420389 for ; Fri, 5 Feb 2016 20:01:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 946DD20384 for ; Fri, 5 Feb 2016 20:01:15 +0000 (UTC) Received: from localhost ([::1]:50224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRmZ8-0000R6-1e for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Feb 2016 15:01:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRmZ1-0000Qz-JM for qemu-devel@nongnu.org; Fri, 05 Feb 2016 15:01:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRmZ0-0000U6-LM for qemu-devel@nongnu.org; Fri, 05 Feb 2016 15:01:07 -0500 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]:1249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRmZ0-0000Tt-Ff for qemu-devel@nongnu.org; Fri, 05 Feb 2016 15:01:06 -0500 Received: from Quad.localdomain (unknown [IPv6:2a01:e34:eeee:5240:12c3:7bff:fe6b:9a76]) by smtp1-g21.free.fr (Postfix) with ESMTPS id 6A0C79401BA; Fri, 5 Feb 2016 20:59:03 +0100 (CET) From: Laurent Vivier To: Riku Voipio Date: Fri, 5 Feb 2016 21:00:53 +0100 Message-Id: <1454702453-13943-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 2a01:e0c:1:1599::10 Cc: qemu-devel@nongnu.org, Laurent Vivier Subject: [Qemu-devel] [PATCH] linux-user: add getrandom() syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- linux-user/syscall.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dac5518..6801fa2 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 +#ifdef TARGET_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 +#ifdef TARGET_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);