From patchwork Fri Jan 18 21:30:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156083 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3747990jaa; Fri, 18 Jan 2019 14:01:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN5cexvy39uTPEd8F1vC7eVpI6lk4abHJPt/E4BAA5yuaGP/FAXBpZMahlHnCkfGXH2YqxKM X-Received: by 2002:a7b:c44d:: with SMTP id l13mr17214016wmi.144.1547848902686; Fri, 18 Jan 2019 14:01:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547848902; cv=none; d=google.com; s=arc-20160816; b=WqMq6I/MuxBb5YroP1rEVyiT/gLAuOcLIQMkZLI0uw/r33tqqaHWY44KIP5drA6uuh 1pc5BuiKqOkD6nmkiLxrXszzY/qjGtGUy89UJRzD5wKE7/568OZAzfoWivgQFVUGPLLB mUjm3a6wJD4zfeXzmeK6MCdkYrrsueRmZKNtgTbPeJjWnIuGEj6KrB6inW5D2eoiMzF7 5gST1pGiqtt+X/Njo/1YP22qFpeSdf7D0JXw9yqzF2jhD7ZwY9KpxEkD29kBHDSTL+qC 2k/zKrRA7uPGMVCOniHx6k9dcOgo009ftSFrMQg3Lx3ZZ3gOofqVhgTdrNdg8Nu0zfTM s5Sw== 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; bh=W1Z9Vd3YSX5Q31DkxW6Gq3ieWVMIgFgXheKfcYbSUmk=; b=xObBEYpf+AjS4ktsLK/aWD6ZgJX22vT0WGixxHpNZ/IZkm6wx1CgLnEaJOs3nZC3Q0 C2w2BzCUedBRizlDTrvcfq42CnG5F1j2ZA+HDIOWB2a2N69KwGxi+BHSPlsKztsQk7uV XFcDGcPFIr7XLn5Kp+U4QQaK3DGcIR6oqq0QpDhREDIFTIojd7J0lODjmNoFcTLctIVT zSMNzev/5BWWDPLvFuEZ/MjY8sG2lpYl+Yp3MnCDI6gxtSdCNdqFRxolfT1YKFqFHJ/D sQdRYKDReff1uiTMtzo6M1WZk03iFIoAo2dWDCU2dfMh2+fJ05q4f5yqVvtr5QzjH1zT LX3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YVYeamRX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id g11si59254353wru.308.2019.01.18.14.01.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 14:01:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YVYeamRX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:47810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkcCr-0003aI-Jw for patch@linaro.org; Fri, 18 Jan 2019 17:01:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbkb-0005Iy-Bu for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbkZ-0004oS-0V for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:29 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbkQ-0004ea-L4 for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:20 -0500 Received: by mail-pl1-x641.google.com with SMTP id a14so6865894plm.12 for ; Fri, 18 Jan 2019 13:32:15 -0800 (PST) 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=W1Z9Vd3YSX5Q31DkxW6Gq3ieWVMIgFgXheKfcYbSUmk=; b=YVYeamRXxcH+Uo4D/eev09z49vvFAvwL/Fhl4nrtRNZOArY4WUG97OOA4hZEIpJjcY Y51x41Eo3YbejpguP/jyJtlu+VAOPUASC6uYwPK/S/VlQ850qFFZGhMD8Yvtiup6Kes7 GO5GFf597l/tH8YNqtrP+u6JX3l51g7zZImNE= 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=W1Z9Vd3YSX5Q31DkxW6Gq3ieWVMIgFgXheKfcYbSUmk=; b=MnEEiUoxx70xTpdZ42wgKs5BR7VJVeY1gcon+ykxGKQWsKwBSVihGUfFzQEJmb2nrb mqhhMxS2AW+1uYkpOy4jVF8jgaMzIo1EtCKSU/LqSU+k5hF4jmGmu5/MIBOWEzl2i503 ORLZYRLQW4ry/PawVPqFw8PnbrohhZSmd26UGZmlj4SHR2N+XttaHWJeLm8b24N/D3h8 uIkaS3gYICUiTTeKxyGvGw/tEytcE34zBba8kxUltEQtJKkPaXojU0cNW9lHnQqSrRZj c08N7xS10ytqxhAc4MH8CokOY/OiczJGUzatHe0Su91ELnvufljjcviiLHfmRSXLV/W7 Ckmg== X-Gm-Message-State: AJcUukcRv2F9J8p5AfyAZ1+43NbdU3QFXDpyqqrmSSBWI4sOYq4ozQGS Mw+Hz2B7+tUdn2LMOcwt7K7hyRcve8M= X-Received: by 2002:a17:902:b03:: with SMTP id 3mr20541807plq.91.1547847134635; Fri, 18 Jan 2019 13:32:14 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.32.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:32:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:30:53 +1100 Message-Id: <20190118213122.22865-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v6 20/49] linux-user: Implement rusage argument to waitid 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" The kernel interface, which we are supposed to be implementing, takes a fifth argument: an rusage pointer akin to wait4. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 +- linux-user/syscall-proc.inc.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) -- 2.17.2 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index a84050a318..f099d98fa3 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -119,7 +119,7 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); SYSCALL_DEF_FULL(vfork, .impl = impl_fork); #endif SYSCALL_DEF(wait4, ARG_DEC, ARG_PTR, ARG_HEX, ARG_PTR); -SYSCALL_DEF(waitid, ARG_HEX, ARG_DEC, ARG_PTR, ARG_HEX); +SYSCALL_DEF(waitid, ARG_HEX, ARG_DEC, ARG_PTR, ARG_HEX, ARG_PTR); #ifdef TARGET_NR_waitpid SYSCALL_DEF(waitpid, ARG_DEC, ARG_PTR, ARG_HEX); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 37f5bbe197..de4efed9f4 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -370,19 +370,30 @@ SYSCALL_IMPL(waitid) id_t id = arg2; abi_ulong target_info = arg3; int options = arg4; + abi_ulong target_rusage = arg5; siginfo_t info, *info_ptr = target_info ? &info : NULL; + struct rusage rusage; + struct rusage *rusage_ptr = target_rusage ? &rusage : NULL; abi_long ret; info.si_pid = 0; - ret = get_errno(safe_waitid(idtype, id, info_ptr, options, NULL)); - if (!is_error(ret) && target_info && info.si_pid != 0) { - target_siginfo_t *p = lock_user(VERIFY_WRITE, target_info, - sizeof(target_siginfo_t), 0); - if (!p) { - return -TARGET_EFAULT; + ret = get_errno(safe_waitid(idtype, id, info_ptr, options, rusage_ptr)); + if (!is_error(ret)) { + if (target_info && info.si_pid != 0) { + target_siginfo_t *p = lock_user(VERIFY_WRITE, target_info, + sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, target_info, sizeof(target_siginfo_t)); + } + if (target_rusage) { + abi_long err = host_to_target_rusage(target_rusage, &rusage); + if (err) { + ret = err; + } } - host_to_target_siginfo(p, &info); - unlock_user(p, target_info, sizeof(target_siginfo_t)); } return ret; }