From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULPzy-0003ck-Ag for qemu-devel@nongnu.org; Thu, 28 Mar 2013 23:29:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULPzx-00088L-51 for qemu-devel@nongnu.org; Thu, 28 Mar 2013 23:29:02 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:55050 helo=linux-iscsi.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULPzw-000888-Tb for qemu-devel@nongnu.org; Thu, 28 Mar 2013 23:29:01 -0400 From: "Nicholas A. Bellinger" In-Reply-To: <20130328090416.GA18482@redhat.com> References: <1363653285-23776-1-git-send-email-asias@redhat.com> <1363653285-23776-4-git-send-email-asias@redhat.com> <20130319084057.GB24393@stefanha-thinkpad.redhat.com> <1363744628.13070.28.camel@haakon2.linux-iscsi.org> <20130320095140.GA16615@redhat.com> <1364419887.17698.19.camel@haakon2.linux-iscsi.org> <20130327215625.GC10678@redhat.com> <1364423629.17698.25.camel@haakon2.linux-iscsi.org> <1364453115.17698.106.camel@haakon2.linux-iscsi.org> <1364456142.10253.6.camel@haakon2.linux-iscsi.org> <20130328090416.GA18482@redhat.com> Content-Type: text/plain; charset="UTF-8" Date: Thu, 28 Mar 2013 20:28:57 -0700 Message-ID: <1364527737.10253.74.camel@haakon2.linux-iscsi.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Kevin O'Connor , kvm@vger.kernel.org, Stefan Hajnoczi , seabios-devel , qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, target-devel@vger.kernel.org, Stefan Hajnoczi , Paolo Bonzini , Asias He On Thu, 2013-03-28 at 11:04 +0200, Michael S. Tsirkin wrote: > On Thu, Mar 28, 2013 at 12:35:42AM -0700, Nicholas A. Bellinger wrote: > > On Wed, 2013-03-27 at 23:45 -0700, Nicholas A. Bellinger wrote: > > > On Wed, 2013-03-27 at 15:33 -0700, Nicholas A. Bellinger wrote: > > > > On Wed, 2013-03-27 at 23:56 +0200, Michael S. Tsirkin wrote: > > > > > On Wed, Mar 27, 2013 at 02:31:27PM -0700, Nicholas A. Bellinger wrote: > > > > locking shadow ram > > romend: 0x000cb800 romtop: 0x000ec000 > > mem: 0x000c0000, pam: 0x0000005a > > Calling pci_config_writeb(0x11): bdf: 0x0000 pam: 0x0000005a > > > > > > > > > > > Calling pci_config_writeb(0x31): bdf: 0x0000 pam: 0x0000005b > > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > > > > mem: 0x000c8000, pam: 0x0000005b > > romend: 0x000cb800 mem + 16*1024: 0x000cc000 > > romtop: 0x000ec000 mem + 32*1024: 0x000d0000 > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > romend: 0x000cb800, mem: 0x000c8000, romtop: 0x000ec000, mem + 16*1024: 0x000cc000 > > Calling pci_config_writeb(0x31): bdf: 0x0000 pam: 0x0000005b > > > > > > > > > > > > > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 2146697216 add: 0 > > > Before vhost_verify_ring_mappings: start_addr: c0000 size: 2146697216 > > > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. > > This is also a bug. -net always initializes VQs 0..N so this is what > vhost assumed. Please teach vhost that it should skip uninitialized > VQs. There are more places to fix. > Basically look for if (!virtio_queue_get_num(vdev, queue_no)), > all of them need to be updated to skip uninitialized vqs. > Probably switch to a new API checking PA too. > See patch below. > > > > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > > > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. > > > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > > > Checking vq: 2 ring_phys: ed000 ring_size: 5124 >>>>>>>>>>>>>>>>>>. > > > Calling l: 5124 for start_addr: c0000 for vq 2 > > > Unable to map ring buffer for ring 2 > > > l: 4096 ring_size: 5124 > > okay so the ring address is within ROM. > Unsurprisingly it fails. > bios should stop device before write protect. > --- > > virtio: add API to check that ring is setup > > virtio scsi makes it legal to only setup a subset of rings. The only > way to detect the ring is setup seems to be to check whether PA was > written to. Add API to do this, and teach code to use it instead of > checking hardware queue size. > > Signed-off-by: Michael S. Tsirkin > > ---> > > diff --git a/hw/virtio.c b/hw/virtio.c > index 26fbc79..ac12c01 100644 > --- a/hw/virtio.c > +++ b/hw/virtio.c > @@ -651,6 +651,11 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n) > return vdev->vq[n].vring.num; > } > > +bool virtio_queue_valid(VirtIODevice *vdev, int n) > +{ > + return vdev->vq[n].vring.num && vdev->vq[n].vring.pa; > +} I assume you mean vring.desc here, right..? Sending out these as a separate patch series shortly. --nab