From patchwork Mon Oct 17 13:24:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9379305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E2E2600CA for ; Mon, 17 Oct 2016 13:46:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 300BE2906A for ; Mon, 17 Oct 2016 13:46:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 247252907B; Mon, 17 Oct 2016 13:46:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED5792906A for ; Mon, 17 Oct 2016 13:46:30 +0000 (UTC) Received: from localhost ([::1]:33164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw8FK-0004CV-6m for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Oct 2016 09:46:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw7ui-0003SF-4F for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw7uh-0003NE-28 for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:25:12 -0400 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:36171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bw7ug-0003MW-QM for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:25:10 -0400 Received: by mail-lf0-x22a.google.com with SMTP id b75so288604732lfg.3 for ; Mon, 17 Oct 2016 06:25:10 -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=u7uowMK38kxr4EjVIrfh6zyTGKKCT5jTOaera7rHcsY=; b=gOOeWxvOg7Bkupl2gmRfNWffrd358vi/No/p8Son05z6dOgMRGb7AxVJ7BdpzOfaPM 2KG8HNTYYjxGZz2NF/PqKEflH1M1pDdvWfqLXUx8dxgfUivNpqRVg+e2zTsLDshotEBG yhkQEhMBbilzcEoBLtES8U4X4ByogQLE7J2cE= 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=u7uowMK38kxr4EjVIrfh6zyTGKKCT5jTOaera7rHcsY=; b=RJJfU7o5xUpbbYYAOj13eeqVyKXxt+n19icqmQrVneoj9fvY98XgOt9UefTgb4/848 N+zoc9568vmA2FZ4IncuM1vfJ5B0mLFE2Pbq9ID5oh4k5ViM+TdFuSMu8SwumNrBCsM1 J0jXUg6Yp1mjp07Ah0K3ow7d/Svap9oTgKfsA90Ob5tEeHvF+OqGs7aV8llY8/btHlK1 FJpcPIL4Gysa7b4ISONRzNyCo1xrKe9cfGe6mgKY82vPfe+X9Shrf8WO1ivH3HfmzKk3 XqktPGqWXCM9a6pVItSmVC+UArOwgyjEqB1Onwh3GCZoy+oquhHxqF5UgmoNAqnz7uzr 3ehA== X-Gm-Message-State: AA6/9RmojDLjkOqyfqHGEkY8MxZedKsljk3EI01iDuxbFPQJlK4gmlmrUngDFBg0CDDABuxB X-Received: by 10.25.156.211 with SMTP id f202mr15349086lfe.159.1476710709019; Mon, 17 Oct 2016 06:25:09 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 06:25:07 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2016 16:24:38 +0300 Message-Id: <2f603120755b1d96a60317e40874f2c266454b02.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::22a Subject: [Qemu-devel] [PULL 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a91383f..10c940c 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, @@ -10077,6 +10079,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;