[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 3/5] vhost-user: support registering external
From: |
Tiwei Bie |
Subject: |
Re: [Qemu-devel] [PATCH v2 3/5] vhost-user: support registering external host notifiers |
Date: |
Fri, 25 May 2018 19:35:49 +0800 |
User-agent: |
Mutt/1.9.5 (2018-04-13) |
On Fri, May 25, 2018 at 07:26:05PM +0800, Jason Wang wrote:
> On 2018年05月25日 19:04, Tiwei Bie wrote:
[...]
> > +static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev
> > *dev,
> > + VhostUserVringArea
> > *area,
> > + int fd)
> > +{
> > + int queue_idx = area->u64 & VHOST_USER_VRING_IDX_MASK;
> > + size_t page_size = qemu_real_host_page_size;
> > + struct vhost_user *u = dev->opaque;
> > + VhostUserState *user = u->user;
> > + VirtIODevice *vdev = dev->vdev;
> > + VhostUserHostNotifier *n;
> > + int ret = 0;
> > + void *addr;
> > + char *name;
> > +
> > + if (!virtio_has_feature(dev->protocol_features,
> > + VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) ||
> > + vdev == NULL || queue_idx >= virtio_get_num_queues(vdev)) {
> > + ret = -1;
> > + goto out;
> > + }
> > +
> > + n = &user->notifier[queue_idx];
> > +
> > + if (n->addr) {
> > + virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
> > + object_unparent(OBJECT(&n->mr));
> > + munmap(n->addr, page_size);
> > + n->addr = NULL;
> > + }
> > +
> > + if (area->u64 & VHOST_USER_VRING_NOFD_MASK) {
> > + goto out;
> > + }
> > +
> > + /* Sanity check. */
> > + if (area->size != page_size) {
> > + ret = -1;
> > + goto out;
> > + }
> > +
> > + addr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
>
> It looks to me that PROT_WRITE is sufficient here?
>
> Thanks
>
I think it's safer to add PROT_READ. And there's
no harm to do that.
Best regards,
Tiwei Bie
- [Qemu-devel] [PATCH v2 0/5] Support host notifiers in vhost-user, Tiwei Bie, 2018/05/25
- [Qemu-devel] [PATCH v2 4/5] libvhost-user: support host notifier, Tiwei Bie, 2018/05/25
- [Qemu-devel] [PATCH v2 5/5] vhost-user-bridge: support host notifier, Tiwei Bie, 2018/05/25
- [Qemu-devel] [PATCH v2 3/5] vhost-user: support registering external host notifiers, Tiwei Bie, 2018/05/25
- [Qemu-devel] [PATCH v2 2/5] vhost-user: introduce shared vhost-user state, Tiwei Bie, 2018/05/25
- [Qemu-devel] [PATCH v2 1/5] vhost: allow backends to filter memory sections, Tiwei Bie, 2018/05/25