Skip to contentSkip to conversation

vhost: check region type before casting

PATCH In review Tiwei Bie 5 participants 10 messages Jul 20, 2018 – Aug 2, 2018

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 vhost: check region type before casting

Check region type first before casting the memory region to IOMMUMemoryRegion. Otherwise QEMU will abort with below error message when casting non-IOMMU memory region:

vhost_iommu_region_add: Object 0x561f28bce4f0 is not an instance of type qemu:iommu-memory-region

Fixes cb1efcf462a2 ("iommu: Add IOMMU index argument to notifier APIs")
Cc Peter Maydell <[email protected]>
---
 hw/virtio/vhost.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +3 -1
index b129cb9ddd..d4cb5894a8 100644
@@ -663,12 +663,14 @@ static void vhost_iommu_region_add(MemoryListener *listener,
     struct vhost_iommu *iommu;
     Int128 end;
     int iommu_idx;
-    IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+    IOMMUMemoryRegion *iommu_mr;
 
     if (!memory_region_is_iommu(section->mr)) {
         return;
     }
 
+    iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+
     iommu = g_malloc0(sizeof(*iommu));
     end = int128_add(int128_make64(section->offset_within_region),
                      section->size);
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Tiwei Bie

Check region type first before casting the memory region to IOMMUMemoryRegion. Otherwise QEMU will abort with below error message when casting non-IOMMU memory region:

Quoted 8 lines

vhost_iommu_region_add: Object 0x561f28bce4f0 is not an instance of type qemu:iommu-memory-region

Fixes cb1efcf462a2 ("iommu: Add IOMMU index argument to notifier APIs")
Cc Peter Maydell <[email protected]>

---

thanks
-- PMM

#2 lore raw
In reply to Tiwei Bie
This series failed docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

Hi,

This series failed docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH] vhost: check region type before casting

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
fatal: unable to access 'https://github.com/patchew-project/qemu/': Encountered end of file
error: Could not fetch 3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
File "/usr/bin/patchew", line 442, in test_one

    git_clone_repo(clone, r["repo"], r["head"], logf)

File "/usr/bin/patchew", line 48, in git_clone_repo
stdout=logf, stderr=logf)
File "/usr/lib64/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'remote', 'add', '-f', '--mirror=fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384', 'https://github.com/patchew-project/qemu']' returned non-zero exit status 1.

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

author
#3 lore raw
In reply to Tiwei Bie

Ping..

It seems that the final release for QEMU 3.0 will be out soon [1]. But this fix hasn't been merged yet.

[1] https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg06004.html

Thanks,
Tiwei

Quoted 39 lines · Tiwei Bie

Check region type first before casting the memory region to IOMMUMemoryRegion. Otherwise QEMU will abort with below error message when casting non-IOMMU memory region:

vhost_iommu_region_add: Object 0x561f28bce4f0 is not an instance of type qemu:iommu-memory-region

Fixes cb1efcf462a2 ("iommu: Add IOMMU index argument to notifier APIs")
Cc Peter Maydell <[email protected]>
---
 hw/virtio/vhost.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +3 -1
index b129cb9ddd..d4cb5894a8 100644
@@ -663,12 +663,14 @@ static void vhost_iommu_region_add(MemoryListener *listener,
     struct vhost_iommu *iommu;
     Int128 end;
     int iommu_idx;
-    IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+    IOMMUMemoryRegion *iommu_mr;
 
     if (!memory_region_is_iommu(section->mr)) {
         return;
     }
 
+    iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+
     iommu = g_malloc0(sizeof(*iommu));
     end = int128_add(int128_make64(section->offset_within_region),
                      section->size);
Signature · 1 line
2.18.0
Acked-by
#4 lore raw
Quoted 9 lines · Tiwei Bie

Ping..

It seems that the final release for QEMU 3.0 will be out soon [1]. But this fix hasn't been merged yet.

[1] https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg06004.html

Thanks,
Tiwei

Quoted 41 lines · Tiwei Bie
Quoted 39 lines

Check region type first before casting the memory region to IOMMUMemoryRegion. Otherwise QEMU will abort with below error message when casting non-IOMMU memory region:

vhost_iommu_region_add: Object 0x561f28bce4f0 is not an instance of type qemu:iommu-memory-region

Fixes cb1efcf462a2 ("iommu: Add IOMMU index argument to notifier APIs")
Cc Peter Maydell <[email protected]>
---
  hw/virtio/vhost.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +3 -1
index b129cb9ddd..d4cb5894a8 100644
@@ -663,12 +663,14 @@ static void vhost_iommu_region_add(MemoryListener *listener,
      struct vhost_iommu *iommu;
      Int128 end;
      int iommu_idx;
-    IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+    IOMMUMemoryRegion *iommu_mr;
 
      if (!memory_region_is_iommu(section->mr)) {
          return;
      }
 
+    iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+
      iommu = g_malloc0(sizeof(*iommu));
      end = int128_add(int128_make64(section->offset_within_region),
                       section->size);
Signature · 1 line
2.18.0
#5 lore raw
In reply to Tiwei Bie
Quoted 6 lines · Tiwei Bie

Ping..

It seems that the final release for QEMU 3.0 will be out soon [1]. But this fix hasn't been merged yet.

[1] https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg06004.html

:-(

You just missed rc3 (which we tagged yesterday), and I'm not sure if this meets the barrier for causing us to put out an rc4. It is a regression, but when does it happen? The commit message isn't very clear whether this is a corner case or not.

thanks
-- PMM

author
#6 lore raw
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Tiwei Bie

Ping..

It seems that the final release for QEMU 3.0 will be out soon [1]. But this fix hasn't been merged yet.

Quoted 7 lines
Quoted 1 line

[1] https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg06004.html

:-(

You just missed rc3 (which we tagged yesterday), and I'm not sure if this meets the barrier for causing us to put out an rc4.

This is just a very simple fix. I'm not sure whether an rc4 is really needed.

Quoted 3 lines

It is a regression, but when does it happen? The commit message isn't very clear whether this is a corner case or not.

It always happens when I try to use vIOMMU in vhost, as long as qom-cast-debug isn't disabled during ./configure.

Thanks,
Tiwei

#7 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell
Quoted 6 lines · Tiwei Bie

Ping..

It seems that the final release for QEMU 3.0 will be out soon [1]. But this fix hasn't been merged yet.

[1] https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg06004.html

:-(

Quoted 8 lines

You just missed rc3 (which we tagged yesterday), and I'm not sure if this meets the barrier for causing us to put out an rc4. It is a regression, but when does it happen? The commit message isn't very clear whether this is a corner case or not.

thanks
-- PMM

There's also Igor's fix for memory hotplug.
Pretty small fixes for sure, and I'd like to have them in if possible, but if I'm the only one maybe we can put it in stable ...

I have collected these two in my tree meanwhile. Let me know.

Signature · 1 line
MST
#8 lore raw
Quoted 3 lines · Michael S. Tsirkin

There's also Igor's fix for memory hotplug.
Pretty small fixes for sure, and I'd like to have them in if possible, but if I'm the only one maybe we can put it in stable ...

Can you make sure that's listed on the release planning page:
https://wiki.qemu.org/Planning/3.0#Not_yet_fixed_in_any_rc

We have a handful of maybe-we-should-put-these in bugs, so I'll make a call one way or the other on whether to do an rc4 depending on what we've got...

thanks
-- PMM

#9 lore raw
Quoted 8 lines · Peter Maydell
Quoted 3 lines · Michael S. Tsirkin

There's also Igor's fix for memory hotplug.
Pretty small fixes for sure, and I'd like to have them in if possible, but if I'm the only one maybe we can put it in stable ...

Can you make sure that's listed on the release planning page:
https://wiki.qemu.org/Planning/3.0#Not_yet_fixed_in_any_rc

Quoted 6 lines

We have a handful of maybe-we-should-put-these in bugs, so I'll make a call one way or the other on whether to do an rc4 depending on what we've got...

thanks
-- PMM

Done. There's one regression and one non-regression.

Signature · 1 line
MST