Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp843004imm; Fri, 12 Oct 2018 07:34:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV6106r5YR4Eh2yOch7mBD40fs8Ptjd+lKNoItk7ucNwKmUxRGa5c15qTA5+sNXcPnSyImexa X-Received: by 2002:a62:d206:: with SMTP id c6-v6mr6440102pfg.8.1539354898117; Fri, 12 Oct 2018 07:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539354898; cv=none; d=google.com; s=arc-20160816; b=aAiH1YhDMAGbgvG506ploY+3NTfRHjvRtns1t93wN6b1lA79xTJCx9KWekYuxeayMr yt9npPa1irJcUBwRNVfymOJqXmxlSmp4/CM2l8Jg+roukZVhtsBD90n67qWFqzSzpvU+ LKEJsTxrFmkICIQ1IQCxbYEf5y5clU7FiXrxCIpyKeTUfcrnM4udSGVzHW4ZosTIO1Uo jSt6h+WeXnv2RvaJrIoKomaoA5G76loWInExSRHUCyGwU15N8XmIGjzwu5AgbsHKlvKI 3iMrpkor5lGkk48GSJoT+WuvxKYC+AIT2JLGPvvEvNbdll9upQV0nQHVC8CD+NxfV/rL HB7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Rwia31Kw1znVQX4yHt6Ld6fcOcP1NV20iyFGlOoU+fQ=; b=vIEc+3gKnD5rhF1e/MjiZd/lqPfebc7+9YR00ZJMgX4a+qEebgA1GDgJ2dP99dRzO7 rVmZMn01j4DuC1Ch8WGCPVP+LjJ9O4kFzPTAthVURrbPsqaz7rS1SoaxPxCq3cOVh17a Fuk7x6Ueo012OWA2h/2ALeSBNIWMtWcyWhn3ECi+W+NGd2pw0C5znIJrqxnI2mxyE5H5 n2MGcsrXbOY6R9SHarTFKYSm+r7++V2uuvhLBTHtHxadR4sSsR2Jgzh89i45CrePZlkS wjOGUCsJXXulbgja+y1WmKzuL0WkP7CB7Xjf/PNcp4WVQuSjfVSuWa78I5PRMK7mSQlQ 4gFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x33-v6si1311070pga.246.2018.10.12.07.34.43; Fri, 12 Oct 2018 07:34:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728900AbeJLWGq (ORCPT + 99 others); Fri, 12 Oct 2018 18:06:46 -0400 Received: from mga18.intel.com ([134.134.136.126]:44390 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728738AbeJLWGq (ORCPT ); Fri, 12 Oct 2018 18:06:46 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2018 07:34:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,372,1534834800"; d="scan'208";a="94673819" Received: from btwcube1.sh.intel.com (HELO debian) ([10.67.104.158]) by fmsmga002.fm.intel.com with ESMTP; 12 Oct 2018 07:34:01 -0700 Date: Fri, 12 Oct 2018 22:32:44 +0800 From: Tiwei Bie To: Jason Wang Cc: mst@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, wexu@redhat.com, jfreimann@redhat.com, maxime.coquelin@redhat.com Subject: Re: [PATCH net-next V2 6/8] vhost: packed ring support Message-ID: <20181012143244.GA28400@debian> References: <1531711691-6769-1-git-send-email-jasowang@redhat.com> <1531711691-6769-7-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1531711691-6769-7-git-send-email-jasowang@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 16, 2018 at 11:28:09AM +0800, Jason Wang wrote: [...] > @@ -1367,10 +1397,48 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg > vq->last_avail_idx = s.num; > /* Forget the cached index value. */ > vq->avail_idx = vq->last_avail_idx; > + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) { > + vq->last_avail_wrap_counter = wrap_counter; > + vq->avail_wrap_counter = vq->last_avail_wrap_counter; > + } > break; > case VHOST_GET_VRING_BASE: > s.index = idx; > s.num = vq->last_avail_idx; > + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) > + s.num |= vq->last_avail_wrap_counter << 31; > + if (copy_to_user(argp, &s, sizeof(s))) > + r = -EFAULT; > + break; > + case VHOST_SET_VRING_USED_BASE: > + /* Moving base with an active backend? > + * You don't want to do that. > + */ > + if (vq->private_data) { > + r = -EBUSY; > + break; > + } > + if (copy_from_user(&s, argp, sizeof(s))) { > + r = -EFAULT; > + break; > + } > + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) { > + wrap_counter = s.num >> 31; > + s.num &= ~(1 << 31); > + } > + if (s.num > 0xffff) { > + r = -EINVAL; > + break; > + } Do we want to put wrap_counter at bit 15? If put wrap_counter at bit 31, the check (s.num > 0xffff) won't be able to catch the illegal index 0x8000~0xffff for packed ring. > + vq->last_used_idx = s.num; > + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) > + vq->last_used_wrap_counter = wrap_counter; > + break; > + case VHOST_GET_VRING_USED_BASE: Do we need the new VHOST_GET_VRING_USED_BASE and VHOST_SET_VRING_USED_BASE ops? We are going to merge below series in DPDK: http://patches.dpdk.org/patch/45874/ We may need to reach an agreement first. > + s.index = idx; > + s.num = vq->last_used_idx; > + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) > + s.num |= vq->last_used_wrap_counter << 31; > if (copy_to_user(argp, &s, sizeof s)) > r = -EFAULT; > break; [...]