From patchwork Mon Oct 17 13:24:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 682972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3syKP00PXJz9s9c for ; Tue, 18 Oct 2016 00:51:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=dWWZFvd5; dkim-atps=neutral Received: from localhost ([::1]:33190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw8Js-00089C-S4 for incoming@patchwork.ozlabs.org; Mon, 17 Oct 2016 09:51:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw7un-0003XO-3N for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:25:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw7uk-0003Op-Dv for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:25:17 -0400 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]:35002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bw7uk-0003OM-5q for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:25:14 -0400 Received: by mail-lf0-x236.google.com with SMTP id l131so242736445lfl.2 for ; Mon, 17 Oct 2016 06:25:14 -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=SozoaiFBRhyDc2OmGTg8H0HlNQaHQS0++i8/aVkPnKE=; b=dWWZFvd5gx5oZGN6QDzliZqvTNjWOuPitaAfsUFMMJM9zToAD8SNFepXnvxwffGx+0 +5hqhn7UfiKZPVhLFG/qB1UKvFcmEp9PdVcxzFRa0/pCSqmSKfa9ft1w2EJpGK+aId3m ni1u6FmqjBpXZmWeCtNgDzP56C3c/ct4IdZYo= 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=SozoaiFBRhyDc2OmGTg8H0HlNQaHQS0++i8/aVkPnKE=; b=Lrf8GAiP5DbbT5T61X3NJZ6+9bZAsGlFMqZ8CmEdR4ueCwmvJTq9d/ycdNw90oGvRL RZ+PwpM9GmcwFbFFf9ll9phZh8RwGi7xLnXnyzVDvGZSXDIVLbqgA7sFKupH1GwwufSE q4FIbAHNSJ228exDKfS8fNlGVD9XVvd4nvgT2SoU+hc0bBoGcynYCUNW/zYOo8oKaPNf 8E/0eyJcywWNWVFTLHDpDU4gz4HJQVwnGFvZYAe1bWIACem/mihFWhZqmxjSAA3ugC4W c1g7H27/cWCnnC1AIoGotByi1gruZFmm4yF19gNWJLxxIE3HqrR45WmK/oLRpjlVmPzV 943w== X-Gm-Message-State: AA6/9RkvSBwIkeFnqLnCJnssuEC0suGGptyxEbNrY7/lAh3B8juPqYo2HVsbDkJY5XPUuHUL X-Received: by 10.25.196.193 with SMTP id u184mr13372684lff.32.1476710710549; Mon, 17 Oct 2016 06:25:10 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id y81sm7782857lff.29.2016.10.17.06.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 06:25:09 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2016 16:24:39 +0300 Message-Id: <1b3f07d272dc7f9a1fdc981796aecd77e990ea8f.1476710353.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::236 Subject: [Qemu-devel] [PULL 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+incoming=patchwork.ozlabs.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(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 10c940c..2072b1f 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, @@ -10092,6 +10094,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;