From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Don't pass RAM blocks that are marked as ram devices to vhost.
There's normally something special about them and they're not
normally just shared memory.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
hw/virtio/vhost.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 4da0d5a6c5..c81f0be71b 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -402,6 +402,7 @@ static bool vhost_section(struct vhost_dev *dev, MemoryRegionSection *section)
bool log_dirty = memory_region_get_dirty_log_mask(section->mr) &
~(1 << DIRTY_MEMORY_MIGRATION);
result = memory_region_is_ram(section->mr) &&
+ !memory_region_is_ram_device(section->mr) &&
!memory_region_is_rom(section->mr);
/* Vhost doesn't handle any block which is doing dirty-tracking other
--
2.24.1
On Wed, Jan 08, 2020 at 01:53:52PM +0000, Dr. David Alan Gilbert (git) wrote: > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > Don't pass RAM blocks that are marked as ram devices to vhost. > There's normally something special about them and they're not > normally just shared memory. > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> So I think this is good by itself. > --- > hw/virtio/vhost.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index 4da0d5a6c5..c81f0be71b 100644 > --- a/hw/virtio/vhost.c > +++ b/hw/virtio/vhost.c > @@ -402,6 +402,7 @@ static bool vhost_section(struct vhost_dev *dev, MemoryRegionSection *section) > bool log_dirty = memory_region_get_dirty_log_mask(section->mr) & > ~(1 << DIRTY_MEMORY_MIGRATION); > result = memory_region_is_ram(section->mr) && > + !memory_region_is_ram_device(section->mr) && > !memory_region_is_rom(section->mr); > > /* Vhost doesn't handle any block which is doing dirty-tracking other > -- > 2.24.1
On Thu, Jan 09, 2020 at 06:45:24AM -0500, Michael S. Tsirkin wrote: > On Wed, Jan 08, 2020 at 01:53:52PM +0000, Dr. David Alan Gilbert (git) wrote: > > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > > > Don't pass RAM blocks that are marked as ram devices to vhost. > > There's normally something special about them and they're not > > normally just shared memory. > > > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > > Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > > So I think this is good by itself. Hmm second thoughts. vhost kernel can handle any pointer. And what we care about for vhost-user is that memory_region_get_fd gives us an fd. So why does it matter that there's something special about it? I worry that this will break things like pass through of virtio-pmem for nested virt. > > --- > > hw/virtio/vhost.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > > index 4da0d5a6c5..c81f0be71b 100644 > > --- a/hw/virtio/vhost.c > > +++ b/hw/virtio/vhost.c > > @@ -402,6 +402,7 @@ static bool vhost_section(struct vhost_dev *dev, MemoryRegionSection *section) > > bool log_dirty = memory_region_get_dirty_log_mask(section->mr) & > > ~(1 << DIRTY_MEMORY_MIGRATION); > > result = memory_region_is_ram(section->mr) && > > + !memory_region_is_ram_device(section->mr) && > > !memory_region_is_rom(section->mr); > > > > /* Vhost doesn't handle any block which is doing dirty-tracking other > > -- > > 2.24.1
On Wed, Jan 08, 2020 at 01:53:52PM +0000, Dr. David Alan Gilbert (git) wrote: > Don't pass RAM blocks that are marked as ram devices to vhost. > There's normally something special about them and they're not > normally just shared memory. Does this something special about them, whatever it is, make them automatically ineligible for DMA? Why should vhost ignore them? /me goes reading what ram_device memory regions are... Roman. > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > hw/virtio/vhost.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index 4da0d5a6c5..c81f0be71b 100644 > --- a/hw/virtio/vhost.c > +++ b/hw/virtio/vhost.c > @@ -402,6 +402,7 @@ static bool vhost_section(struct vhost_dev *dev, MemoryRegionSection *section) > bool log_dirty = memory_region_get_dirty_log_mask(section->mr) & > ~(1 << DIRTY_MEMORY_MIGRATION); > result = memory_region_is_ram(section->mr) && > + !memory_region_is_ram_device(section->mr) && > !memory_region_is_rom(section->mr); > > /* Vhost doesn't handle any block which is doing dirty-tracking other > -- > 2.24.1 > >
On Thu, Jan 09, 2020 at 12:38:07PM +0000, Roman Kagan wrote: > On Wed, Jan 08, 2020 at 01:53:52PM +0000, Dr. David Alan Gilbert (git) wrote: > > Don't pass RAM blocks that are marked as ram devices to vhost. > > There's normally something special about them and they're not > > normally just shared memory. > > Does this something special about them, whatever it is, make them > automatically ineligible for DMA? Why should vhost ignore them? > /me goes reading what ram_device memory regions are... > > Roman. Well device RAM can be DMA'd into. But vhost is a host side of virtio as opposed to a random device, we know what it's doing, so skipping specific areas that we know are of no interest to virtio devices for performance/internal implementation reasons is OK. > > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > > --- > > hw/virtio/vhost.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > > index 4da0d5a6c5..c81f0be71b 100644 > > --- a/hw/virtio/vhost.c > > +++ b/hw/virtio/vhost.c > > @@ -402,6 +402,7 @@ static bool vhost_section(struct vhost_dev *dev, MemoryRegionSection *section) > > bool log_dirty = memory_region_get_dirty_log_mask(section->mr) & > > ~(1 << DIRTY_MEMORY_MIGRATION); > > result = memory_region_is_ram(section->mr) && > > + !memory_region_is_ram_device(section->mr) && > > !memory_region_is_rom(section->mr); > > > > /* Vhost doesn't handle any block which is doing dirty-tracking other > > -- > > 2.24.1 > > > >
© 2016 - 2026 Red Hat, Inc.