From patchwork Tue Oct 18 13:21:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 78054 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp892294qge; Tue, 18 Oct 2016 06:43:53 -0700 (PDT) X-Received: by 10.55.212.195 with SMTP id s64mr576911qks.216.1476798233060; Tue, 18 Oct 2016 06:43:53 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v9si4083771qka.130.2016.10.18.06.43.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 18 Oct 2016 06: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; 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 dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwUgK-0008SI-Fo for patch@linaro.org; Tue, 18 Oct 2016 09:43:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwULV-0006W3-7L for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwULR-0000kg-89 for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:21 -0400 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:33530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwULQ-0000kF-Vr for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:17 -0400 Received: by mail-lf0-x232.google.com with SMTP id x79so355989996lff.0 for ; Tue, 18 Oct 2016 06:22:16 -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=hpPDWMscIOus8Zm7AEwpCOJ4SEd7AdafI2NzPAWpzpc=; b=TxhF3kg06DgQXcvn5v/uZb3QF5cntY8LMJeYrAal8qkfO3YEpD3FVTzsLu48wvb1ES QBUoKsokNIK8O5ytTl+wcrZPENYRCLz5smdH+h0ntvPJGgCooYkt4OND8lOKXczMdmXz eekGd6rMo8ObXe7XXoDsy2mZmO/OFT7gyLRfw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hpPDWMscIOus8Zm7AEwpCOJ4SEd7AdafI2NzPAWpzpc=; b=dkDdSpUL/Ewz0F/xOdZ2ifmoNmC0DM5e2CfTAX+B8yqICY8ssFFo9D83qkwMY0b34i T7EsVFmTKlxytTPxZNjUeeX9E1TFl6/5SxceePvubxnjeB9rnfm6jWmstVEtkGot6sYQ NlEwGx89kAhZfU+cu687kKS6jgz5t6S9mx+5jbNmcwhDhiD9325Q2QNlekH9p8dmW61L dX0SU/1EnaEvgw3ZxHIoMLWpF2H33MMZ6fMdUbMm8EKakBVIxFRLunTutQheEnuWY/Ip kZUPvnSMGAI2Smi488wCNf5e/cTTVsC7JFrtaGzNbquWpyvc4OD8CSjWXlYFS4g3h9kb Pm4Q== X-Gm-Message-State: AA6/9Rl3UWGcTb/cY0e1k+3C2nnG887I8KBnf9hA+MiQPd6F7o3hUuAjXjDyPz03eJWKSS3Q X-Received: by 10.25.24.205 with SMTP id 74mr651525lfy.34.1476796935344; Tue, 18 Oct 2016 06:22:15 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 201sm9535359ljf.48.2016.10.18.06.22.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:22:14 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2016 16:21:48 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::232 Subject: [Qemu-devel] [PULL v2 20/22] linux-user: added support for preadv() system call. 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: Peter Maydell , Dejan Jovicevic Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Dejan Jovicevic This system call performs the same task as the readv() system call, with the exception of having the fourth argument, offset, which specifes the file offset at which the input operation is to be performed. Because of this, the preadv() implementation is based on the readv() implementation in linux-user mode. But, since preadv() is implemented in the kernel as a 5-argument syscall, 5 arguments are needed to be handled as input and passed to the host syscall. The pos_l and pos_h argument of the safe_preadv() are of type unsigned long, which can be of different sizes on different platforms. The input arguments are converted to the appropriate host size when passed to safe_preadv(). Signed-off-by: Dejan Jovicevic Signed-off-by: Riku Voipio --- linux-user/syscall.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d85a0b5..9cb2a8f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -919,6 +919,8 @@ safe_syscall2(int, tkill, int, tid, int, sig) safe_syscall3(int, tgkill, int, tgid, int, pid, int, sig) safe_syscall3(ssize_t, readv, int, fd, const struct iovec *, iov, int, iovcnt) safe_syscall3(ssize_t, writev, int, fd, const struct iovec *, iov, int, iovcnt) +safe_syscall5(ssize_t, preadv, int, fd, const struct iovec *, iov, int, iovcnt, + unsigned long, pos_l, unsigned long, pos_h) safe_syscall3(int, connect, int, fd, const struct sockaddr *, addr, socklen_t, addrlen) safe_syscall6(ssize_t, sendto, int, fd, const void *, buf, size_t, len, @@ -10078,6 +10080,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } } break; +#if defined(TARGET_NR_preadv) + case TARGET_NR_preadv: + { + struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); + if (vec != NULL) { + ret = get_errno(safe_preadv(arg1, vec, arg3, arg4, arg5)); + unlock_iovec(vec, arg2, arg3, 1); + } else { + ret = -host_to_target_errno(errno); + } + } + break; +#endif case TARGET_NR_getsid: ret = get_errno(getsid(arg1)); break;