From patchwork Mon Feb 2 04:06:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 5759111 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F50ABF440 for ; Mon, 2 Feb 2015 04:39:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8DEF92026F for ; Mon, 2 Feb 2015 04:39:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 816FB20266 for ; Mon, 2 Feb 2015 04:39:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755173AbbBBEjj (ORCPT ); Sun, 1 Feb 2015 23:39:39 -0500 Received: from mail-oi0-f45.google.com ([209.85.218.45]:61496 "EHLO mail-oi0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932167AbbBBEje (ORCPT ); Sun, 1 Feb 2015 23:39:34 -0500 Received: by mail-oi0-f45.google.com with SMTP id g201so42567101oib.4 for ; Sun, 01 Feb 2015 20:39:33 -0800 (PST) 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=jYdwDFpCn25kedrLeXfD7+6xY6oQzR83d+KyhJbxndo=; b=dOaYOkcvtDDn+2+gJAw3JzKWFEFrjk+/4DLWBvLtmiDgatzd87b4APkEIHXRFASc8D ddTNs4lo3rKFzHjSVWAyQhDdw+JmfrK7cq7POeOMoKQykeT3on1iDty0wgXmil74iul+ 8k2uJyKMMp0RHKEQLSmkF7kjNZBIG1vUdBpfNVUK1F7GGGPQ04xionPUUzQ0M7OG6qUE k5+sK0Reh6iLGo/13iW8F5E7hjqejRo5S8YobnAex01OKPOMXX8cdJ1w0IrcK0KArUhN 9HN+iR0SBNqxoG+MNwvQrnReWMq+Q8AXPBynkaRnVUbW55Vq70qmKIXhO5R/7H36Nkmd gYkw== X-Gm-Message-State: ALoCoQm95ljeEgvfqpGQ+uBt2y868pBACszPstBuY/xaR7Teo4/24ZhoAs8rZYfAmMAvZipKpoJA X-Received: by 10.60.63.37 with SMTP id d5mr11099977oes.2.1422851973807; Sun, 01 Feb 2015 20:39:33 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id y2sm8950007oei.1.2015.02.01.20.39.33 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 01 Feb 2015 20:39:33 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , kvm-devel , Paolo Bonzini , "Michael S. Tsirkin" , Nicholas Bellinger Subject: [PATCH-v2 02/11] vhost/scsi: Convert completion path to use memcpy_toiovecend Date: Mon, 2 Feb 2015 04:06:25 +0000 Message-Id: <1422849994-3419-3-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1422849994-3419-1-git-send-email-nab@daterainc.com> References: <1422849994-3419-1-git-send-email-nab@daterainc.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger Required for ANY_LAYOUT support when the incoming virtio-scsi response header + fixed size sense buffer payload may span more than a single iovec entry. This changes existing code to save cmd->tvc_resp_iod instead of the first single iovec base pointer from &vq->iov[out]. Cc: Michael S. Tsirkin Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- drivers/vhost/scsi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 01c01cb..a03ac41 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -87,8 +87,8 @@ struct tcm_vhost_cmd { struct scatterlist *tvc_sgl; struct scatterlist *tvc_prot_sgl; struct page **tvc_upages; - /* Pointer to response */ - struct virtio_scsi_cmd_resp __user *tvc_resp; + /* Pointer to response header iovec */ + struct iovec *tvc_resp_iov; /* Pointer to vhost_scsi for our device */ struct vhost_scsi *tvc_vhost; /* Pointer to vhost_virtqueue for the cmd */ @@ -703,7 +703,8 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) se_cmd->scsi_sense_length); memcpy(v_rsp.sense, cmd->tvc_sense_buf, se_cmd->scsi_sense_length); - ret = copy_to_user(cmd->tvc_resp, &v_rsp, sizeof(v_rsp)); + ret = memcpy_toiovecend(cmd->tvc_resp_iov, (unsigned char *)&v_rsp, + 0, sizeof(v_rsp)); if (likely(ret == 0)) { struct vhost_scsi_virtqueue *q; vhost_add_used(cmd->tvc_vq, cmd->tvc_vq_desc, 0); @@ -1159,7 +1160,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) cmd->tvc_vhost = vs; cmd->tvc_vq = vq; - cmd->tvc_resp = vq->iov[out].iov_base; + cmd->tvc_resp_iov = &vq->iov[out]; pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n", cmd->tvc_cdb[0], cmd->tvc_lun);