From patchwork Sun May 19 20:36:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164510 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4788389ili; Sun, 19 May 2019 13:54:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqywpZDooKYdRVHjgefq24xPhCos/ME2kJo3wF9srFYOOsVAt2LHy2fcaLHSnEwZUdiYv1F2 X-Received: by 2002:a17:906:110c:: with SMTP id h12mr36036300eja.269.1558299277619; Sun, 19 May 2019 13:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299277; cv=none; d=google.com; s=arc-20160816; b=UyUlFxYtHxLD+iqMAl+IzGSTUamCADMupmzytxLg0SP98xMWSMaN3MKTNGH9gzP6lW re9sm6WCSULHEDrAQGGhYafiIG0zI7SnF1bo8EOJoIXsFdjKxeQSyuqFOV9KkTzFUVnv /GxNcpKBWf7jalUOYvNmLqQWWTgjhu5ve96pYGLzyMKmZ+GeMMg7US0LjKDruceQJqOs 84okUW25hTjQSuPl4pYKQ20P30H2R5UjU67cax1SsAF+QzwB8VxbreKRZmdlqWh2Cwn0 YamoBPpc6pthyMn3N217YBVIi6NM2N65vj2feut8SF6hXbqkDrZqaKftw38NsdRlr9oH Rw5A== 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=ivbPF9AA08UpYLCiKojYQPTAvKrugZNh3dcbIM2DPu8=; b=LAorZ5st7zT6RGhTedpQRjNBFKC9DystFKSSeZjR1TFTPd4LOZaSTcebOOYmDGL4XI yFzFxh80dFwGqWVD6Z1Uh713+3LWnj8BwuVUW3VADmGehra2jwvc+3eSO8jl9gy9bDtp 1ruLmynoxrj+hGsAPB58QoOKGqIpP3LhfwJstNKP8C8NsCOov2aGaBhMgLvQZZW5/KXU TQUwSva4ApcMTQ9FBy8uXeBveoGaNJneaVSTH2i7mw7JdVG9Vuo8EfBkk3YU9uL7Um0T lxtud7Ybgy9XsbfVdy6TacXA3gx+ZT1fJsaYgz5YfjGN2LI4aRAJ4MTDdooVwn7p13Uq bHpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SEGoWLAg; 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 s4si5346833edm.64.2019.05.19.13.54.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:54:37 -0700 (PDT) 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=SEGoWLAg; 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]:53335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSpI-0008Mt-FM for patch@linaro.org; Sun, 19 May 2019 16:54:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZB-0003Be-9R for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZA-0003pH-Av for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:57 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:43808) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZA-0003oM-56 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:56 -0400 Received: by mail-pg1-x542.google.com with SMTP id t22so5725712pgi.10 for ; Sun, 19 May 2019 13:37:56 -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=ivbPF9AA08UpYLCiKojYQPTAvKrugZNh3dcbIM2DPu8=; b=SEGoWLAg+RZ4riZbIc9naxcWLRTzjediGWpq+QTz2q69v76H7vtAdmobl0AGbDZdoI MaGzazjNCp4ynnWbZItcjih5THmw/jn2+9wY8iLQ4YrqdfClw1SlkwkLAfPDhQbZ7v9L 88CrbuuuVAEo6g//NygY64sQOKlLLwnNIC+dw4gaLWju+cxxPq0sQqjW32LAL1qz78ca /X14LNquJlWDSmmHYJlU6uEwAC97etaUIJp8O8mZj3Gg3C4VCO2moZEPfZivYkSMg/It e8UsBBR2Vvmkq9FLGG63ndnoq6Bg431KBrwaYnmSo3p/WGQmoW6uNgKyWtcSsa0bEYUy G3sQ== 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=ivbPF9AA08UpYLCiKojYQPTAvKrugZNh3dcbIM2DPu8=; b=Q0cp8bvm7KlfLfL1YaK42JC16p+KNZwPP1kJyhslKBoYy9vaQOpXCwWSGcsZ1iezeS EWqAMCX6BtK3f8YittEaxz8p+aoAanLsqfTI+V5wIy+4JaOP8p6MoDF/FzU0y4om7vqG K6QPvsWm10CmlVGgO6dJemm5b1xWqiWej+baBSRW0s5J9HMP3KxNGWhNiRsfoWictVa1 +4zwzUQR78W9ZtTgava4aqJsbzH38EXapoPC3ibh4gQEB3nPL+6I1dKqA4nkHvbXPGgn 3SNOslEjOtgJ68BZWgC9W9FH3DhNygBUhjYfRHaKcnXn35Z0PYc8j9gExv/1w1u0AG+m GcWw== X-Gm-Message-State: APjAAAUMHd+W/t2omA5JDvCRIgOKIhPlBGcQjlhd04fKfA2e9EPK3Z7B VBFBnGXRgyAE0fkLVIUmSpgJpR0YKsM= X-Received: by 2002:a62:d205:: with SMTP id c5mr75464414pfg.219.1558298274771; Sun, 19 May 2019 13:37:54 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:31 -0700 Message-Id: <20190519203726.20729-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-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::542 Subject: [Qemu-devel] [PATCH v7 19/74] 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.1 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 7c647f36d7..b7304b7a42 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; }