From patchwork Fri Jan 30 08:12:26 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: 5747851 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EC4C99F302 for ; Fri, 30 Jan 2015 08:46:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFA70201CE for ; Fri, 30 Jan 2015 08:46:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DDE0201BB for ; Fri, 30 Jan 2015 08:46:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759888AbbA3IqB (ORCPT ); Fri, 30 Jan 2015 03:46:01 -0500 Received: from mail-oi0-f53.google.com ([209.85.218.53]:64354 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754549AbbA3Ip3 (ORCPT ); Fri, 30 Jan 2015 03:45:29 -0500 Received: by mail-oi0-f53.google.com with SMTP id i138so33715201oig.12 for ; Fri, 30 Jan 2015 00:45:28 -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=NsmA5mhCRiy+H5LsJnSmZvxl9Lo7MZFlRqTzEgNJYmOp+FlqhAic3KcXlrHbRFWWrj cBrORRjdtfA8tjQ/fkiiveNuds6b8t2iJQA3gRBTRCx01M24fi2mj7ztZBDoqO0u9xme fVVDJ0foD/drX9zXp4+QXaPDP8K1AA0g8R6zKefarJFPBTsKa/pjtv/VSQUWpbSocEhH nIbZFaRLfZmahM4HkvGSyGcr5/nL4+2oJfQK9VbuDkvj8F2DfOUEgTOoS3bXRtboXLNl i7L8ZKuYg7PB0bOjNhf4EhAh5e12Jhe8DKLoc4iYj7MwpxO588vKSamgy6ZlpxRiiVA3 5m4Q== X-Gm-Message-State: ALoCoQkpxmNOxg2mpR4YCC0TaJyp6oQpdAdqKJtn4s+L39+Csk5fRyyEGgFUFFknI6cBxlPyK+2n X-Received: by 10.202.197.206 with SMTP id v197mr2934458oif.54.1422607528590; Fri, 30 Jan 2015 00:45:28 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id l3sm5046132obx.14.2015.01.30.00.45.28 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 30 Jan 2015 00:45:28 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , kvm-devel , Paolo Bonzini , "Michael S. Tsirkin" , Nicholas Bellinger Subject: [PATCH 2/8] vhost/scsi: Convert completion path to use memcpy_toiovecend Date: Fri, 30 Jan 2015 08:12:26 +0000 Message-Id: <1422605552-24797-3-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1422605552-24797-1-git-send-email-nab@daterainc.com> References: <1422605552-24797-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);