From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/7] virtio: use address_space_map/unmap to access descriptors
Date: Tue, 24 Jan 2017 17:06:57 +0100 [thread overview]
Message-ID: <4b7fe6d3-f9f5-641c-706a-b7f782c5b213@redhat.com> (raw)
In-Reply-To: <20170124123031.GC17221@stefanha-x1.localdomain>
On 24/01/2017 13:30, Stefan Hajnoczi wrote:
> On Fri, Jan 20, 2017 at 06:07:53PM +0100, Paolo Bonzini wrote:
>> @@ -455,10 +455,18 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
>> goto err;
>> }
>>
>> - desc_pa = vq->vring.desc;
>> - vring_desc_read(vdev, &desc, desc_pa, i);
>> + len = max * sizeof(VRingDesc);
>> + desc_ptr = address_space_map(vdev->dma_as, vq->vring.desc, &len, false);
>> + if (len < max * sizeof(VRingDesc)) {
>> + virtio_error(vdev, "Cannot map descriptor ring");
>> + goto err;
>> + }
>> +
>> + vring_desc_read(vdev, &desc, desc_ptr, i);
>>
>> if (desc.flags & VRING_DESC_F_INDIRECT) {
>> + address_space_unmap(vdev->dma_as, desc_ptr, len, false, 0);
>
> Missing "dest_ptr = NULL" to prevent double unmap if the next goto err
> is taken.
>
>> @@ -689,18 +706,33 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
>> }
>>
>> i = head;
>> - vring_desc_read(vdev, &desc, desc_pa, i);
>> +
>> + len = max * sizeof(VRingDesc);
>> + desc_ptr = address_space_map(vdev->dma_as, vq->vring.desc, &len, false);
>> + if (len < max * sizeof(VRingDesc)) {
>> + virtio_error(vdev, "Cannot map descriptor ring");
>> + return NULL;
>
> desc_ptr still needs to be unmapped if non-NULL. The same applies
> below in virtqueue_pop().
>
I'll redo this patch to look a lot more like 4/7.
Paolo
next prev parent reply other threads:[~2017-01-24 16:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 17:07 [Qemu-devel] [PATCH 0/7] virtio: use MemoryRegionCache for descriptors and rings Paolo Bonzini
2017-01-20 17:07 ` [Qemu-devel] [PATCH 1/7] virtio: make virtio_should_notify static Paolo Bonzini
2017-01-24 12:42 ` Stefan Hajnoczi
2017-01-20 17:07 ` [Qemu-devel] [PATCH 2/7] virtio: add virtio_*_phys_cached Paolo Bonzini
2017-01-24 12:43 ` Stefan Hajnoczi
2017-01-20 17:07 ` [Qemu-devel] [PATCH 3/7] virtio: use address_space_map/unmap to access descriptors Paolo Bonzini
2017-01-24 12:30 ` Stefan Hajnoczi
2017-01-24 16:06 ` Paolo Bonzini [this message]
2017-01-20 17:07 ` [Qemu-devel] [PATCH 4/7] virtio: use MemoryRegionCache " Paolo Bonzini
2017-01-24 12:32 ` Stefan Hajnoczi
2017-01-20 17:07 ` [Qemu-devel] [PATCH 5/7] virtio: add MemoryListener to cache ring translations Paolo Bonzini
2017-01-24 12:37 ` Stefan Hajnoczi
2017-01-20 17:07 ` [Qemu-devel] [PATCH 6/7] virtio: use VRingMemoryRegionCaches for descriptor ring Paolo Bonzini
2017-01-24 12:38 ` Stefan Hajnoczi
2017-01-20 17:07 ` [Qemu-devel] [PATCH 7/7] virtio: use VRingMemoryRegionCaches for avail and used rings Paolo Bonzini
2017-01-24 12:42 ` Stefan Hajnoczi
2017-01-20 17:54 ` [Qemu-devel] [PATCH 0/7] virtio: use MemoryRegionCache for descriptors and rings Michael S. Tsirkin
2017-01-24 16:37 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4b7fe6d3-f9f5-641c-706a-b7f782c5b213@redhat.com \
--to=pbonzini@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).