From patchwork Fri Jun 1 07:30:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137476 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp614430lji; Fri, 1 Jun 2018 00:46:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIbIcpWG2P+TTLxaRCZy6oTYzZabLyJL/+e/gBIjr6szzlssZDIHNejVhFi7CDt82Zcaasx X-Received: by 2002:a37:f60e:: with SMTP id y14-v6mr9226759qkj.374.1527839167182; Fri, 01 Jun 2018 00:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839167; cv=none; d=google.com; s=arc-20160816; b=PL/H5h63QUcGUUdD0yC5zJ+n5uaSWuLzJ7+zhGhA5Pf/thQWym5kYi3FnuLdB/zYuD uDh7ElqsndIowf1ge9Qp9Vx67XgCdCtF6qczntZbJSCl0fqVPYsXx7WF/kvXqQX8hZlD FvHjdGZv7qRLWFswPndAVS9HhV770ilXHiLBJIsjD27y2hEfjkmdFuSwBh1aZUZYMs+y 2iNMaUq83sejnCLuAZoAjkliz8nzrtM7BeqCXkuR4QHjswgvyIsV8IxdkJkPwuKg2NVx oqvp/kqtUyo4GoHf7Bi1luMGLsh0/eE042T6FukdK3XVPOdvQb3cRi1q8S0Q8UcgxGtu KS1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Gd3OrgaRytojWAKBUPZdGXy3p/dEUecwW8tJ9jzjJ4A=; b=smMesdrcJKs6oXsgSwZ5P5duc7IiQ1KVw+RITj3AHlfNOqfxbmMx5hZCPVHqPyb085 IsXarNCRZth29a8xFCDprkUoSMG6MSFyjhb4Wm4UsABTMBnpJlhwZYLK4c+XjlyK2mv1 SImr0cf/5g0kMMENv1jI0XQ3c3tWeqKbHZkY9ki7w39qDxcIamP9WCQQa4/KTDeh47rg H0YI4A9PGxaVBxxLGwmqJqdyHh1A25JktLJRxhaAInTrWamrn9T4bjr7w792Y2OnyiBd n2O3KABScfOLaycjxWf5Fs9mCqcBNmBNIhT+fJ50Yt9Zrf+X265UUKeLah/sX/oeZTxM m/2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kyfZaZ9+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z67-v6si1570721qkd.318.2018.06.01.00.46.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:46:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kyfZaZ9+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOelC-0007i9-H1 for patch@linaro.org; Fri, 01 Jun 2018 03:46:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWs-0005a6-N0 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWq-0000VF-CA for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44909) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWq-0000Um-6D for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:16 -0400 Received: by mail-pg0-x241.google.com with SMTP id p21-v6so10876647pgd.11 for ; Fri, 01 Jun 2018 00:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gd3OrgaRytojWAKBUPZdGXy3p/dEUecwW8tJ9jzjJ4A=; b=kyfZaZ9+mlUY58tbSDbpL44da5+rsDKxt3xTL0m9hQ18Jp61WZ6N1DNPvFHIpnSCna 1nUaOxZMpcecgbGZE9L/9pVh7Qv2MR/X6r6KL1/Bn73iF21/qqxIL/c/Gn+cWlyQcn6h rQk4ReHvV4xQ5RGAGJWb4RyZPF00YBwoKv/Uw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Gd3OrgaRytojWAKBUPZdGXy3p/dEUecwW8tJ9jzjJ4A=; b=EJiuSNBsrWhf7pkYP2azLOIUc1ogd8ziUFh+4uHPz4LwzWg5k49yEkcnKjFcn7U+Iw OH9m5EpkPOGcb5DY+gD7a4+Ofo5iCe9q1zpmEhoN4tDDAyc8hICTneiQog2FSiFkOI7j 0CFvhQab1EnWYYysxZk0XzUUxJfaziGOzLkgcJ2m3fZkH42NumofA6AAupCdPqVKzjPa qy0mASuAFGgxSmXjgwkpxUA0nv3SpAMdFJzXrjrAHpUfSluc0gyorUnVrmNEz9pTjaON tkNlptvu+0hEmKdcsnzkFSdJB76tHuAvuXhE78Jvb28rK7YHqU/KjFB/5Yo+FOuQFSzg Zdrg== X-Gm-Message-State: ALKqPwfNf9n+sZOozNFv58oCeQwD84SoG0W69gcG8td2FEopQVsCShO0 Qd5nS27SLluqVSvbrK+vpkeL1aCELw8= X-Received: by 2002:a63:7f15:: with SMTP id a21-v6mr7963255pgd.21.1527838274951; Fri, 01 Jun 2018 00:31:14 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:32 -0700 Message-Id: <20180601073050.8054-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 108 +++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 39 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 48bb1c0231..e208f8647a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7908,6 +7908,22 @@ IMPL(close) return get_errno(close(arg1)); } +#ifdef TARGET_NR_creat +IMPL(creat) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(creat(p, arg2)); + fd_trans_unregister(ret); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8055,6 +8071,13 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_fork +IMPL(fork) +{ + return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); +} +#endif + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8216,6 +8239,40 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_waitid +IMPL(waitid) +{ + siginfo_t info; + abi_long ret; + + info.si_pid = 0; + ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL)); + if (!is_error(ret) && arg3 && info.si_pid != 0) { + target_siginfo_t *p + = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, arg3, sizeof(target_siginfo_t)); + } + return ret; +} +#endif + +#ifdef TARGET_NR_waitpid +IMPL(waitpid) +{ + int status; + abi_long ret = get_errno(safe_wait4(arg1, &status, arg3, 0)); + if (!is_error(ret) && arg2 && ret && + put_user_s32(host_to_target_waitstatus(status), arg2)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(write) { abi_long ret; @@ -8258,45 +8315,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_fork - case TARGET_NR_fork: - return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); -#endif -#ifdef TARGET_NR_waitpid - case TARGET_NR_waitpid: - { - int status; - ret = get_errno(safe_wait4(arg1, &status, arg3, 0)); - if (!is_error(ret) && arg2 && ret - && put_user_s32(host_to_target_waitstatus(status), arg2)) - return -TARGET_EFAULT; - } - return ret; -#endif -#ifdef TARGET_NR_waitid - case TARGET_NR_waitid: - { - siginfo_t info; - info.si_pid = 0; - ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL)); - if (!is_error(ret) && arg3 && info.si_pid != 0) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) - return -TARGET_EFAULT; - host_to_target_siginfo(p, &info); - unlock_user(p, arg3, sizeof(target_siginfo_t)); - } - } - return ret; -#endif -#ifdef TARGET_NR_creat /* not on alpha */ - case TARGET_NR_creat: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(creat(p, arg2)); - fd_trans_unregister(ret); - unlock_user(p, arg1, 0); - return ret; -#endif #ifdef TARGET_NR_link case TARGET_NR_link: { @@ -12932,8 +12950,14 @@ IMPL(everything_else) static impl_fn * const syscall_table[] = { [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, +#ifdef TARGET_NR_creat + [TARGET_NR_creat] = impl_creat, +#endif [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#ifdef TARGET_NR_fork + [TARGET_NR_fork] = impl_fork, +#endif #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif @@ -12945,6 +12969,12 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_waitid + [TARGET_NR_waitid] = impl_waitid, +#endif +#ifdef TARGET_NR_waitpid + [TARGET_NR_waitpid] = impl_waitpid, +#endif [TARGET_NR_write] = impl_write, };