From patchwork Sun Jun 10 03:00:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138092 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580230lji; Sat, 9 Jun 2018 20:14:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1mIszQWUH9zK3er/yvxoEIiyNpQghbWUt8dnlFR4CHZQvuoRJkv0VpR3Ne6Rl4Ww8Y7TC X-Received: by 2002:ac8:37f2:: with SMTP id e47-v6mr11170310qtc.386.1528600457343; Sat, 09 Jun 2018 20:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600457; cv=none; d=google.com; s=arc-20160816; b=WSytVNGIngg4/l/li5vyDIPlArpkRuitnW0erC9d4WbJd1SaHBdn9QAsX4rQzKswik 6aC1KoY2QrfCqdKpWl8NbH+aeeqgKD5jc+JEJkglXzCwacSv7P1qNRBZGIlOrfCOKqO+ Sy+KsunWchxFaVGEb1iTsoSoj7ng9Wg4oMfSBxp+qRHkCLfBmCBQmS1auEp5OWR4WDNZ atg9J5yJ/BnMxF5X85lEpI9rEgpYi2tYv4gxa1POx/8X9uNhU/MOrJIzgnY/ia++K42I hq8Br/P+c1s8o8bTyKIofj7xTjiN3nHBAH8XD8/DlOsg00pNblBOeK1j0sDYsokDyosR aw9w== 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=rAKn4akMvtjNjos1xTYioRl3XOSJGEfXiiI/zItlggw=; b=iWbGPW4wJIjhHGgvB9KunTWeOXcQAKstExVU/3UuVLkB+QHP6XU/8MKfZYMUlrnt0B uhbwI8lZL87decj8KEnsg4euVFx0pfz+83zDvU9S7DUDhPpqfa8raZVdmyIIPELXPc+Z qMRD7HW1Y0YQMJSPJ/tJi+hRKO28UGvrMfamWyb37mx+nLLoXwVsOBikfzy/jSS8HypY N+XRy8qzs1AN7AHPcDv9+I2NDkd5ZDTIjfZ1XjH8dXAWBOYWHd0cCZa0DfA/qs1fx2Hw q+bXQV8KHPx5i6JCqObDincxSNY2MWaN2MLhRGOD7x2PbWtSdiYOi9hKu/e29QuYYdCK RtTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kkUYdEAy; 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 d41-v6si756616qkh.309.2018.06.09.20.14.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:14:17 -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=kkUYdEAy; 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]:42233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqo4-0003J0-Lv for patch@linaro.org; Sat, 09 Jun 2018 23:14:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd9-0001tT-S1 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd8-0003Gj-Fq for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:59 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:39499) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd8-0003GS-AM for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:58 -0400 Received: by mail-pg0-x22c.google.com with SMTP id w12-v6so8138454pgc.6 for ; Sat, 09 Jun 2018 20:02:58 -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=rAKn4akMvtjNjos1xTYioRl3XOSJGEfXiiI/zItlggw=; b=kkUYdEAyc6K+AFSlznXPb72aMKzor2UjINsUa2/JMum6KTSzkM1NjGfVhu5jg5Xnz+ SG/lJQqDWqpoTPQ716BeXAxZmE/RTSIlQPsIIwG8lw5OBVY4FlqkEHzlGphZZ1cNJ6Qc JRKOjhimtsXtvFxcTElBZZaEOWkj2bsuHhwZQ= 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=rAKn4akMvtjNjos1xTYioRl3XOSJGEfXiiI/zItlggw=; b=PURPyrzOVETEcAZbBMUgP9kbtm4YlvBDxLlLWIscLKHjUeABB+B4NlTXTaH2PVH3X1 G/DLfgpNB5TQvbgUfhFJAxIHckLxHnCPrcHe59uUpOTEKN30wELa6PM13ikGHWIY1gxU fO34LI4P3sydEjm7aFpMekiYv5/miTAH/wJ4bliiNY0DCOAwItQYk/dW/Cy+jvg6bA3s R1QUlYhVp8U8HypPAHN57oBb6RSpI7MX6nTFeMU4r0z7fvbsKXE5gimST5b3qiWjVlVH xGJwr7JTUTlgTUBALlYGDZPB4g7hszAuA8KMOCdfUZEe3hSwaj0IP47iUOJ3PyEYdxIE KSbA== X-Gm-Message-State: APt69E0k8EcRlC6rFo2awCmg+eWlzJBTfhS0KonYbw1V8KmHlu9Ym5fm zyPydVuBzknZA7tPRbauqoNZYpyAlj4= X-Received: by 2002:a62:8a83:: with SMTP id o3-v6mr12242174pfk.12.1528599777022; Sat, 09 Jun 2018 20:02:57 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:47 -1000 Message-Id: <20180610030220.3777-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-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::22c Subject: [Qemu-devel] [PATCH v2 015/108] 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" All targets define waitid; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 104 +++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 39 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f51cc7e937..a146b696fd 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7882,6 +7882,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; @@ -8029,6 +8045,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 + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -8174,6 +8197,38 @@ IMPL(read) return ret; } +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; +} + +#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; @@ -8215,45 +8270,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; 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: { @@ -12482,8 +12498,14 @@ static impl_fn *syscall_table(unsigned num) */ SYSCALL(brk); SYSCALL(close); +#ifdef TARGET_NR_creat + SYSCALL(creat); +#endif SYSCALL(execve); SYSCALL(exit); +#ifdef TARGET_NR_fork + SYSCALL(fork); +#endif #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif @@ -12495,6 +12517,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(open_by_handle_at); #endif SYSCALL(read); + SYSCALL(waitid); +#ifdef TARGET_NR_waitpid + SYSCALL(waitpid); +#endif SYSCALL(write); }