From patchwork Tue Oct 18 13:21:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 78057 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp895664qge; Tue, 18 Oct 2016 06:51:52 -0700 (PDT) X-Received: by 10.55.19.9 with SMTP id d9mr556190qkh.247.1476798712086; Tue, 18 Oct 2016 06:51:52 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o21si12882474qka.251.2016.10.18.06.51.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:51:52 -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]:41644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwUo3-0006nI-GR for patch@linaro.org; Tue, 18 Oct 2016 09:51:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwULZ-0006bC-FY for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwULV-0000mM-M3 for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:25 -0400 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]:34935) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwULV-0000ll-Ej for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:21 -0400 Received: by mail-lf0-x234.google.com with SMTP id l131so25244787lfl.2 for ; Tue, 18 Oct 2016 06:22:21 -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=ivVbog7yJss/Ew0+V5HFROnRtrJSSYjPqVhJa5hypi4=; b=T3+OLefTb/SDmjCIoUzhWrFSW6d/ZjbySRgOc0wkxHEZfPZEIHTg/ylJl34ycEn26n 1Ny/bucUrNQuVKS7vnDK9CjCs6iMZHij1sNUICyLIsXRiA6olZi4gaCB2iM7GhH1wiHX /A7821PZBdJZ8n+P2dWDoj3bZj2SYhuKpuW34= 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=ivVbog7yJss/Ew0+V5HFROnRtrJSSYjPqVhJa5hypi4=; b=C+gkZ3DDTQXYFRbu8xh2vHSES4Jh0cutA1NlbPvypPem++oZS+ci0L/Nq7uAzSS7ep w8hDsSrPi9g3Iraf4vcLWV1iI71x/RLbQNwTevQG3aWMXLQW9X58WzYO7IWN/n9ybjJW 5EH5VNaqiFuYO03E95y0ew/x0DxD5EuLAuOtS+s3P2u/I3pAbmeH5deRwTiwUYthcIXn q2x9uJPdLbj1FcJi1DaSYchDMWLK22xmyrCH2uj10YI51c3lLsyEPUbf7o82QQWYaxWZ SHvjUNlrN+QfMx9bEqppkB/hqzX5Jb9DOex7WwZR+9slmxWXzMiHuhJn0RJ11zoXg3fg NPhA== X-Gm-Message-State: AA6/9RmGOT4C6ldW6Lvlqr/4XhvRljeM78OOibiGjBgZMnG/yuBu8tgWimxMMWSKmE/4H72j X-Received: by 10.25.217.210 with SMTP id s79mr602152lfi.50.1476796936446; Tue, 18 Oct 2016 06:22:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:22:15 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2016 16:21:49 +0300 Message-Id: <1a607f6bd93f1c3635fa097029a983335f7949f8.1476796525.git.riku.voipio@linaro.org> 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::234 Subject: [Qemu-devel] [PULL v2 21/22] linux-user: added support for pwritev() 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 writev() 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 pwritev() implementation is based on the writev() implementation in linux-user mode. But, since pwritev() 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_pwritev() 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_pwritev(). 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 9cb2a8f..dfc483c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -921,6 +921,8 @@ 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_syscall5(ssize_t, pwritev, 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, @@ -10093,6 +10095,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } break; #endif +#if defined(TARGET_NR_pwritev) + case TARGET_NR_pwritev: + { + struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); + if (vec != NULL) { + ret = get_errno(safe_pwritev(arg1, vec, arg3, arg4, arg5)); + unlock_iovec(vec, arg2, arg3, 0); + } else { + ret = -host_to_target_errno(errno); + } + } + break; +#endif case TARGET_NR_getsid: ret = get_errno(getsid(arg1)); break;