From patchwork Sun Jun 10 03:00:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138097 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2582513lji; Sat, 9 Jun 2018 20:18:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIVIPUQlEXLRtl5LLwjKzyTD6YNiFEQdyubsecjsOfTfItHhjHcUb/PhM8X1xcI6tCsyFML X-Received: by 2002:a37:4a09:: with SMTP id x9-v6mr3341644qka.5.1528600699955; Sat, 09 Jun 2018 20:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600699; cv=none; d=google.com; s=arc-20160816; b=DKi2utOVNZR93q/R1MXtAjWJgZxz4k7VXMD8V+XcRFmuMGpi91fuCqKx+UyZMFFMmc EoASFUVqNuvpoEm6bNjs/pFO5OBiodoSKFuR11WV68vFZsT9VixoNMmQC+iWjqbgQiWR yJHYoQ7AaJd4pcCCnU5Csv2GnM4Al86y+w24Z3nITECVYhAziDg+jsRuJN/F/PFr3Mg4 sPOBUs9TN4w7csxA/7I2NtXx5J351BBHxfb0QeNu1Q8ZVpN2dswRTOSN4Y7+9jKcL/AD 8rztxtf3qVagTCzOtJo0Ed6B+I37p3NMPu9NK+izzprlOC68pNP1qgS1Kvp9H8414W+q USAg== 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=R4j+RT6f+GYqsFrf7zQPl8+tK/GawpYCnD8r6P5SW1Q=; b=LZn9OLzQVnLBNVDk0qf31Hg820GXWKTyVGsC/HQFUCevxpHd/DgwK3deDBjwxndPik vhAWrYpF9BIi4Gbpq0xSHRdFNaddFwyoLWW3hfrvdcG08GmGe0lnHvUKgbacWfM0GEVv FeXwFb11WYkZ0aAlUUfAHLLpzTRIsMRtqJSXaXImiZuiUQIn7wFfSlHxsNUcma0d9nCf LKN9MJNQ5sJQVDdSps6UPVdf9zzmY7ZozSJx/cFaPI2ADiLivWw2P6/uvL2HUB6oe1cx pmYaIaC290jaO8j/z32Njfp9F/rjjomSMXLXM7LjZpaa+ciDW1AmASRIEByTs7CUgJrx RMRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=La7lx9Uy; 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 i49-v6si936178qvi.207.2018.06.09.20.18.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:18:19 -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=La7lx9Uy; 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]:42254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqrz-0006fy-A1 for patch@linaro.org; Sat, 09 Jun 2018 23:18:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdW-0002D1-BY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdV-0003Pq-42 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:22 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:35651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdU-0003PS-SR for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:21 -0400 Received: by mail-pl0-x243.google.com with SMTP id k1-v6so1987035plt.2 for ; Sat, 09 Jun 2018 20:03:20 -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=R4j+RT6f+GYqsFrf7zQPl8+tK/GawpYCnD8r6P5SW1Q=; b=La7lx9UyBLVB5zgZGGFeRRmwj9DJFYy2z5xt9HxH6u9kapqqqwduarRTBJdNTXRwzh N+VWP+Ny7r8vbjev3P36pe4FXvxGdeSAc0n1TMNr4TK364OTyJv6xQiUdIsD5V0Au/O4 QP5C2M2EehCdyc4IOsDSeT+d7qJB8NBguW6xM= 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=R4j+RT6f+GYqsFrf7zQPl8+tK/GawpYCnD8r6P5SW1Q=; b=s2wmQHciQ06D0qaR6xjOMJUl+4VBM7RadzksUKSHWSGH2DRtJtFSv3sKME5j99h/hd LP8xHPleRsKRxekNDRwsEOvhGsFXGSNzePKTvs18TsSmRi0aFWnCMa72uiPFYMCZw5RR YnDA92UAWbSIPhN6Rq8naEoojDqMG+68v8ObzMGCd4KKx0o+TXU7eFbFHCV6lPEWmQUl mCwnQGP6aIZeR/GsygwqgciFMkaUhkHbMdDMz5qM89ylkIJecuryjexviMgrfHiqxelU /3gQnSZ3BDy+/2ebd7FeCniBlroJZufZL8yMe2bx0zIsMPERYYPGgyTa58ULzXwxmuqc N5ng== X-Gm-Message-State: APt69E2sucXrBgcatdlY+Q4kbOm5MEYoP5OCAr2nlRukXA1VekuUdDsp OlrVedI45NhHtrGVXW0IDDWD9BMAc8s= X-Received: by 2002:a17:902:d68b:: with SMTP id v11-v6mr12765650ply.16.1528599799673; Sat, 09 Jun 2018 20:03:19 -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.03.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:57 -1000 Message-Id: <20180610030220.3777-26-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 025/108] linux-user: Split out acct, pipe, pipe2, times, umount2 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 pipe2 and umount2; remove the ifdefs. Merge do_pipe2 into its only user. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 148 +++++++++++++++++++++++++------------------ 1 file changed, 88 insertions(+), 60 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f22d45d2cb..81e142f091 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1561,24 +1561,25 @@ static abi_long do_old_select(abi_ulong arg1) #endif #endif -static abi_long do_pipe2(int host_pipe[], int flags) -{ -#ifdef CONFIG_PIPE2 - return pipe2(host_pipe, flags); -#else - return -ENOSYS; -#endif -} - static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, int flags, int is_pipe2) { int host_pipe[2]; abi_long ret; - ret = flags ? do_pipe2(host_pipe, flags) : pipe(host_pipe); - if (is_error(ret)) - return get_errno(ret); + if (flags) { +#ifdef CONFIG_PIPE2 + ret = pipe2(host_pipe, flags); +#else + return -ENOSYS; +#endif + } else { + ret = pipe(host_pipe); + } + ret = get_errno(ret); + if (is_error(ret)) { + return ret; + } /* Several targets have special calling conventions for the original pipe syscall, but didn't replicate this into the pipe2 syscall. */ @@ -1599,9 +1600,10 @@ static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, } if (put_user_s32(host_pipe[0], pipedes) - || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) + || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) { return -TARGET_EFAULT; - return get_errno(ret); + } + return ret; } static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn, @@ -7884,6 +7886,23 @@ IMPL(access) } #endif +IMPL(acct) +{ + if (arg1 == 0) { + return get_errno(acct(NULL)); + } else { + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(acct(path(p))); + unlock_user(p, arg1, 0); + return ret; + } +} + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8435,6 +8454,19 @@ IMPL(pause) } #endif +#ifdef TARGET_NR_pipe +IMPL(pipe) +{ + return do_pipe(cpu_env, arg1, 0, 0); +} +#endif + +IMPL(pipe2) +{ + return do_pipe(cpu_env, arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); +} + IMPL(read) { abi_long ret; @@ -8552,6 +8584,28 @@ IMPL(time) } #endif +IMPL(times) +{ + struct tms tms; + abi_long ret = get_errno(times(&tms)); + + if (is_error(ret)) { + return ret; + } + if (arg1) { + struct target_tms *tmsp + = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); + if (!tmsp) { + return -TARGET_EFAULT; + } + tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); + tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); + tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); + tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); + } + return host_to_target_clock_t(ret); +} + #ifdef TARGET_NR_umount IMPL(umount) { @@ -8567,6 +8621,19 @@ IMPL(umount) } #endif +IMPL(umount2) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(umount2(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8717,52 +8784,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_pipe - case TARGET_NR_pipe: - return do_pipe(cpu_env, arg1, 0, 0); -#endif -#ifdef TARGET_NR_pipe2 - case TARGET_NR_pipe2: - return do_pipe(cpu_env, arg1, - target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); -#endif - case TARGET_NR_times: - { - struct target_tms *tmsp; - struct tms tms; - ret = get_errno(times(&tms)); - if (arg1) { - tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); - if (!tmsp) - return -TARGET_EFAULT; - tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); - tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); - tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); - tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); - } - if (!is_error(ret)) - ret = host_to_target_clock_t(ret); - } - return ret; - case TARGET_NR_acct: - if (arg1 == 0) { - ret = get_errno(acct(NULL)); - } else { - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(acct(path(p))); - unlock_user(p, arg1, 0); - } - return ret; -#ifdef TARGET_NR_umount2 - case TARGET_NR_umount2: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(umount2(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_ioctl: return do_ioctl(arg1, arg2, arg3); #ifdef TARGET_NR_fcntl @@ -12591,6 +12612,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_access SYSCALL(access); #endif + SYSCALL(acct); #ifdef TARGET_NR_alarm SYSCALL(alarm); #endif @@ -12650,6 +12672,10 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_pause SYSCALL(pause); #endif +#ifdef TARGET_NR_pipe + SYSCALL(pipe); +#endif + SYSCALL(pipe2); SYSCALL(read); #ifdef TARGET_NR_rename SYSCALL(rename); @@ -12671,9 +12697,11 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_time SYSCALL(time); #endif + SYSCALL(times); #ifdef TARGET_NR_umount SYSCALL(umount); #endif + SYSCALL(umount2); #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif