From patchwork Sun Jun 10 03:02:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138160 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2607391lji; Sat, 9 Jun 2018 21:03:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJX2VPNqjzHCJCstSWKamUknVkHvYsppqXOEDXY7C8khoNTXU6370YfSUPTO6wQNf+5jEQB X-Received: by 2002:a37:4249:: with SMTP id p70-v6mr10156994qka.297.1528603413126; Sat, 09 Jun 2018 21:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603413; cv=none; d=google.com; s=arc-20160816; b=KVbnIZwy8u5aJBsiWGAOVHnSm5itTXujwBAI+Egtyd9CNFAMSbNEvFaaCf0hDoApfS fUHtvXZpWmGBv3gp6xsNYhZH3x264OreId1hePEC6qGT1TSTJPqzocjpL7Xq6dXpN5yP PT4duoih7sG4lU7edU4bMsAuGFyu4I2qVJWhaKl0acnoYvpYlcXerukmVYAiG0gLSw9D 3HXfFWxa/toWpAR61Zs1Lu0BRm+Aair++pKinK09z07eDiYeXRGDS9sw4IWvv4Wc8szA O2K4Eb8XSfpUEQ5Hy63Qfh2qq4hOXizuXmgIL2wBiZLTjgDfuMQ3RnfxzhRUhUqMtn+9 IQ8Q== 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=WZNUfXoRoL9vKNtJeGiznUyoX3XtiiI2rLnPIeY6Qo8=; b=IUJKeC73Spa1lN/epRmKN+9XmEgScHL6NVdtOacmb4RHnzCaFGFdzQOAf7tNw/tkYQ lRzTGNJvaty1JnL9jBELK9vHlGwi5I9lGpGPl7UJBAe3dSL4f/80MWuA8TFtFh2AB3Uk tvd8DFz+yK51y4GuhOnigojzyzBuXlW2WiB8iyvdrp06yNVuSGvFpEfbn/MAW4WWMvDd jRtsqzg7Dvykrvg+T2HbAqorpbIjPG/xev0HfQDNgRO3hYXoK96go59YJ47OGT1dSXoi hKyyos19oB5Gp5S3X+krzkYRYM4qJnE19ULvTALOhxW/vlQtbCwQLZA6EZXyrfifPk05 Vt4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kG1RL1CB; 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 k11-v6si24591682qvo.167.2018.06.09.21.03.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:03:33 -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=kG1RL1CB; 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]:42514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZk-00074h-KP for patch@linaro.org; Sun, 10 Jun 2018 00:03:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfy-0004cn-4i for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfx-0004l1-3I for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:54 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:35912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfw-0004kj-Sl for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:53 -0400 Received: by mail-pl0-x243.google.com with SMTP id a7-v6so7900703plp.3 for ; Sat, 09 Jun 2018 20:05:52 -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=WZNUfXoRoL9vKNtJeGiznUyoX3XtiiI2rLnPIeY6Qo8=; b=kG1RL1CBjlqdd+zDtlFmgHXD1O47onu7kuoQ0BYm6fpd5K4wXhFR28XmdVLXThCnWV weIQq/jmCF+N8xUXYR2H6qEcrTDHKeirpOqUQuiFIMRb/0igkmsgXahMFkJ0NdamL/Rv G2MEWHaga68pNKkJcve2Lk72PC5XTMZnAPUBA= 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=WZNUfXoRoL9vKNtJeGiznUyoX3XtiiI2rLnPIeY6Qo8=; b=bmT0bP/brdTygFM/5PK1ZAOlGtINju8msZ2yD/Bz60Mr6w9YJiQohOWCpOkPDmFODd 9+meLggDkSgorsOdLmTF6AikkQV2YeylIfZYMC/xWkLIAID6tM5ZLdr2gXTxc6PjRjRF J5Gb8Ahw6Ep/0DHY/t9JLcMfrvoo0Vb6qabKcvDFGD3MkZr1Qb8MWD10GF/jalOP/R+v sOCOetNdrtmqUievEbHkrT9zvSYvaZryKqcTvKY41/Ogqe+2LvBWaoJQ5O2ExqqcG6tj S22tkA1Cj17ONINoSRQy2A0ZQJtVvXKDsnyF1qFmbLqpyNVUvO1R0w2lzK7SkF39MLqk 4kKQ== X-Gm-Message-State: APt69E26MxB/pYwEd1yn31NTxoxoAa55cN9JrhnfL2PSCEqylBTuVKE5 JH2vIwXHX9i+EzftrNW7HKcdw/75Ad4= X-Received: by 2002:a17:902:7604:: with SMTP id k4-v6mr12747799pll.13.1528599951773; Sat, 09 Jun 2018 20:05:51 -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.05.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:13 -1000 Message-Id: <20180610030220.3777-102-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:c01::243 Subject: [Qemu-devel] [PATCH v2 101/108] linux-user: Split out prlimit64 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 prlimit64; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 65 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 32 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9ce37c1119..91d90c7417 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -627,7 +627,6 @@ static int sys_renameat2(int oldfd, const char *old, } #endif -#if defined(TARGET_NR_prlimit64) #ifndef __NR_prlimit64 # define __NR_prlimit64 -1 #endif @@ -640,8 +639,6 @@ struct host_rlimit64 { _syscall4(int, sys_prlimit64, pid_t, pid, int, resource, const struct host_rlimit64 *, new_limit, struct host_rlimit64 *, old_limit) -#endif - #if defined(TARGET_NR_timer_create) /* Maxiumum of 32 active POSIX timers allowed at any one time. */ @@ -10713,6 +10710,38 @@ IMPL(preadv) return ret; } +IMPL(prlimit64) +{ + /* args: pid, resource number, ptr to new rlimit, ptr to old rlimit */ + struct host_rlimit64 rnew, rold; + int resource = target_to_host_resource(arg2); + abi_long ret; + + if (arg3) { + struct target_rlimit64 *target_rnew; + if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { + return -TARGET_EFAULT; + } + rnew.rlim_cur = tswap64(target_rnew->rlim_cur); + rnew.rlim_max = tswap64(target_rnew->rlim_max); + unlock_user_struct(target_rnew, arg3, 0); + } + + ret = get_errno(sys_prlimit64(arg1, resource, arg3 ? &rnew : NULL, + arg4 ? &rold : NULL)); + + if (!is_error(ret) && arg4) { + struct target_rlimit64 *target_rold; + if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { + return -TARGET_EFAULT; + } + target_rold->rlim_cur = tswap64(rold.rlim_cur); + target_rold->rlim_max = tswap64(rold.rlim_max); + unlock_user_struct(target_rold, arg4, 1); + } + return ret; +} + IMPL(pselect6) { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; @@ -12973,35 +13002,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef TARGET_NR_prlimit64 - case TARGET_NR_prlimit64: - { - /* args: pid, resource number, ptr to new rlimit, ptr to old rlimit */ - struct target_rlimit64 *target_rnew, *target_rold; - struct host_rlimit64 rnew, rold, *rnewp = 0; - int resource = target_to_host_resource(arg2); - if (arg3) { - if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { - return -TARGET_EFAULT; - } - rnew.rlim_cur = tswap64(target_rnew->rlim_cur); - rnew.rlim_max = tswap64(target_rnew->rlim_max); - unlock_user_struct(target_rnew, arg3, 0); - rnewp = &rnew; - } - - ret = get_errno(sys_prlimit64(arg1, resource, rnewp, arg4 ? &rold : 0)); - if (!is_error(ret) && arg4) { - if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { - return -TARGET_EFAULT; - } - target_rold->rlim_cur = tswap64(rold.rlim_cur); - target_rold->rlim_max = tswap64(rold.rlim_max); - unlock_user_struct(target_rold, arg4, 1); - } - return ret; - } -#endif #ifdef TARGET_NR_gethostname case TARGET_NR_gethostname: { @@ -13650,6 +13650,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(prctl); SYSCALL(pread64); SYSCALL(preadv); + SYSCALL(prlimit64); SYSCALL(pselect6); SYSCALL(pwrite64); SYSCALL(pwritev);