[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [PATCH v2 3/5] vhost-user: support registering external host notifiers
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
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]