From patchwork Sun Jun 10 03:01:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138132 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2596467lji; Sat, 9 Jun 2018 20:43:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlP20XAXX66mzF411kSZouV9YYBA57vim6OV2pyOYtq/vb7WztWLQpZAi6uQmiLb0e8cys X-Received: by 2002:ac8:1bf0:: with SMTP id m45-v6mr11744915qtk.337.1528602233325; Sat, 09 Jun 2018 20:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602233; cv=none; d=google.com; s=arc-20160816; b=lLIVcR6phqh+zDaLotW9vyoihqlfjQ44lcBbopTlof6WQIgGK3PFZBSTqicxV+Bwqz lB4nCEPPPSSmcZoQkPQ04hkf8H9Wc4cLlhYUBkGmue55wpNcDLpXNHdHpf9G6mgxQBn4 m1mWnf/YdNBdoxEKuyV9sHZrNdlGYLuhqxwcFVMl8pCXSVJ+9iwBbyqsVhxNcMzGE8xt bQBtBRLSSvpg4PzE6p/Ptb8IA6lqxEDXPTiSjYJRGBJXx1oMBQ+vMf7TbJ1Am8UdR/XK iEYjsF/zU/ymn1T1QfrGi6s/s91gHYBgdOgJFt6c/5EmXSHWDYGjL7YufSJsMl3ui60F WJkw== 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=Dy18omCGqsPmW0DQ04jlvLVm4Iv1FbJd+HMNkW7NmX8=; b=C+pErNMsHPwMgG2MBPxlSMR7bRQs7okKGOG9tmv1d+WyiHBGH+tuvY7zB+93Xg4Ayw /hHAO3jaEBwdXsreeDhZmzKiFKF8g4BL4ytqNg5h3hGYH7LB57DUhiZ6J7wlb4bTOAqb t4p2lw535ZFR8+cYYoiIInBGXALg0uKSBGXJ4VAvKB6zAIKWVMGEoi7NWqNcJQ9VUh5V 85FZzZ0fj8b0kODbnDy4kgmOuv2MDepYSZRWwdKZaSmyHjqEPG227mJFXj2g13La+NlO NKt2ce6UHqn+z8Wa9RlLA5082sc+PMBO/AVPq142/8cPHiEA4UvtNU65TtmiH5bWa04T JPyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UR+TgYc7; 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 v12-v6si2441300qvb.1.2018.06.09.20.43.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:43:53 -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=UR+TgYc7; 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]:42401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrGi-0004n0-NB for patch@linaro.org; Sat, 09 Jun 2018 23:43:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf3-0003he-Ey for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf1-00049Y-V7 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:57 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:38930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf1-00049C-NH for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:55 -0400 Received: by mail-pg0-x244.google.com with SMTP id w12-v6so8139553pgc.6 for ; Sat, 09 Jun 2018 20:04:55 -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=Dy18omCGqsPmW0DQ04jlvLVm4Iv1FbJd+HMNkW7NmX8=; b=UR+TgYc7rX3xGDTZHx8gTrHxUjHYtLKR8bYXrs5Mv5jZuMe80wAUJTWWK9q0NKpHkQ jllOGBluw3l33kSwh741cA6hJ2S+fe0Y3sqy43D/5+d7pARSF+BpTJvVh7dM5uqZ7n0j 0gRAQnBx4eqzTvwfJvsRgbkW0n0mQcwPA/y0c= 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=Dy18omCGqsPmW0DQ04jlvLVm4Iv1FbJd+HMNkW7NmX8=; b=PNRyP90vQLXNXIQbT3LyXn9SrZY4z57vR+L+3lgkZcY/taD3+7fCT8lv9ekoRLGasU p6iyUoYf+TidzKgSgL8JghHpJGcv3jvvOJSZedkt3TBF8j+JmDBzh7Y7AvxF7ren5uKZ rwV/zbCxIqiYhk7ZYkhWIfuW4iIULiqjdKFMB7I3hG4r7CoM6Bii1FxOJuy401TUYuaV m4mu60QohOH1qjdXBSWFvcfS2qVtw3Bzq+Lzd3WqLKNa/T7FSDHUtlJGar7MM7X8WUrN Msc1mZW0iH+SFCTwqgv3WYqZMv9eTFuBNv1PXPtqtdWgMQw6uY98qDjTWl7y/FLW8KFI beQg== X-Gm-Message-State: APt69E0sX70KsJ8dQwV5Rx9+w67PVusVpDO9+6hgD8IcNRMwWKNQOHT1 I/NN6aS9Pkhh81lB19j1wZ1EKKVSuQ0= X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr10424887pgp.221.1528599894553; Sat, 09 Jun 2018 20:04:54 -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.04.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:42 -1000 Message-Id: <20180610030220.3777-71-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::244 Subject: [Qemu-devel] [PATCH v2 070/108] linux-user: Split out ftruncate64, truncate64, ugetrlimit, vfork 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 | 133 +++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 63 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 39e416db0b..c2dc7131bb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6718,34 +6718,6 @@ static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) } #endif /* TARGET_ABI_BITS != 32 */ -#ifdef TARGET_NR_truncate64 -static inline abi_long target_truncate64(void *cpu_env, const char *arg1, - abi_long arg2, - abi_long arg3, - abi_long arg4) -{ - if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { - arg2 = arg3; - arg3 = arg4; - } - return get_errno(truncate64(arg1, target_offset64(arg2, arg3))); -} -#endif - -#ifdef TARGET_NR_ftruncate64 -static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, - abi_long arg2, - abi_long arg3, - abi_long arg4) -{ - if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { - arg2 = arg3; - arg3 = arg4; - } - return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); -} -#endif - static inline abi_long target_to_host_timespec(struct timespec *host_ts, abi_ulong target_addr) { @@ -8204,6 +8176,17 @@ IMPL(ftruncate) return get_errno(ftruncate(arg1, arg2)); } +#ifdef TARGET_NR_ftruncate64 +IMPL(ftruncate64) +{ + if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { + arg2 = arg3; + arg3 = arg4; + } + return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); +} +#endif + #ifdef TARGET_NR_futimesat IMPL(futimesat) { @@ -11048,6 +11031,45 @@ IMPL(truncate) return ret; } +#ifdef TARGET_NR_truncate64 +IMPL(truncate64) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { + arg2 = arg3; + arg3 = arg4; + } + ret = get_errno(truncate64(p, target_offset64(arg2, arg3))); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_ugetrlimit +IMPL(ugetrlimit) +{ + struct rlimit rlim; + int resource = target_to_host_resource(arg1); + abi_long ret = get_errno(getrlimit(resource, &rlim)); + + if (!is_error(ret)) { + struct target_rlimit *target_rlim; + if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) { + return -TARGET_EFAULT; + } + target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); + target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); + unlock_user_struct(target_rlim, arg2, 1); + } + return ret; +} +#endif + IMPL(umask) { return get_errno(umask(arg1)); @@ -11183,6 +11205,14 @@ IMPL(utimes) } #endif +#ifdef TARGET_NR_vfork +IMPL(vfork) +{ + return get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD, + 0, 0, 0, 0)); +} +#endif + IMPL(vhangup) { return get_errno(vhangup()); @@ -11307,41 +11337,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_vfork - case TARGET_NR_vfork: - return get_errno(do_fork(cpu_env, - CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD, - 0, 0, 0, 0)); -#endif -#ifdef TARGET_NR_ugetrlimit - case TARGET_NR_ugetrlimit: - { - struct rlimit rlim; - int resource = target_to_host_resource(arg1); - ret = get_errno(getrlimit(resource, &rlim)); - if (!is_error(ret)) { - struct target_rlimit *target_rlim; - if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) - return -TARGET_EFAULT; - target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); - target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); - unlock_user_struct(target_rlim, arg2, 1); - } - return ret; - } -#endif -#ifdef TARGET_NR_truncate64 - case TARGET_NR_truncate64: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_ftruncate64 - case TARGET_NR_ftruncate64: - return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); -#endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: if (!(p = lock_user_string(arg1))) { @@ -13052,6 +13047,9 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(fsync); SYSCALL(ftruncate); +#ifdef TARGET_NR_ftruncate64 + SYSCALL(ftruncate64); +#endif #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif @@ -13352,6 +13350,12 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(times); SYSCALL(truncate); +#ifdef TARGET_NR_truncate64 + SYSCALL(truncate64); +#endif +#ifdef TARGET_NR_ugetrlimit + SYSCALL(ugetrlimit); +#endif SYSCALL(umask); #ifdef TARGET_NR_umount SYSCALL(umount); @@ -13367,6 +13371,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_utimes SYSCALL(utimes); +#endif +#ifdef TARGET_NR_vfork + SYSCALL(vfork); #endif SYSCALL(vhangup); #if defined(TARGET_I386) && !defined(TARGET_X86_64)