diff mbox

vhost: check region type before casting

Message ID 20180720083644.1431-1-tiwei.bie@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tiwei Bie July 20, 2018, 8:36 a.m. UTC
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 <peter.maydell@linaro.org>

Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
 hw/virtio/vhost.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

no-reply@patchew.org July 20, 2018, 8:52 a.m. UTC | #1
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: 20180720083644.1431-1-tiwei.bie@intel.com
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 patchew-devel@redhat.com
Peter Maydell July 20, 2018, 9:08 a.m. UTC | #2
On 20 July 2018 at 09:36, Tiwei Bie <tiwei.bie@intel.com> wrote:
> 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 <peter.maydell@linaro.org>
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Tiwei Bie Aug. 1, 2018, 8:22 a.m. UTC | #3
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

On Fri, Jul 20, 2018 at 04:36:44PM +0800, Tiwei Bie wrote:
> 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 <peter.maydell@linaro.org>
> 
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
>  hw/virtio/vhost.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index b129cb9ddd..d4cb5894a8 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -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);
> -- 
> 2.18.0
> 
>
Jason Wang Aug. 1, 2018, 8:33 a.m. UTC | #4
On 2018年08月01日 16:22, Tiwei Bie wrote:
> 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

Cc: qemu-stable@nongnu.org
Acked-by: Jason Wang <jasowang@redhat.com>

>
> On Fri, Jul 20, 2018 at 04:36:44PM +0800, Tiwei Bie wrote:
>> 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 <peter.maydell@linaro.org>
>>
>> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
>> ---
>>   hw/virtio/vhost.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>> index b129cb9ddd..d4cb5894a8 100644
>> --- a/hw/virtio/vhost.c
>> +++ b/hw/virtio/vhost.c
>> @@ -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);
>> -- 
>> 2.18.0
>>
>>
Peter Maydell Aug. 1, 2018, 10:13 a.m. UTC | #5
On 1 August 2018 at 09:22, Tiwei Bie <tiwei.bie@intel.com> wrote:
> 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
Tiwei Bie Aug. 1, 2018, 11:02 a.m. UTC | #6
On Wed, Aug 01, 2018 at 11:13:34AM +0100, Peter Maydell wrote:
> On 1 August 2018 at 09:22, Tiwei Bie <tiwei.bie@intel.com> wrote:
> > 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.

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

> 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
Michael S. Tsirkin Aug. 1, 2018, 9:58 p.m. UTC | #7
On Wed, Aug 01, 2018 at 11:13:34AM +0100, Peter Maydell wrote:
> On 1 August 2018 at 09:22, Tiwei Bie <tiwei.bie@intel.com> wrote:
> > 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

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.
Peter Maydell Aug. 2, 2018, 8:51 a.m. UTC | #8
On 1 August 2018 at 22:58, Michael S. Tsirkin <mst@redhat.com> wrote:
> 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
Michael S. Tsirkin Aug. 2, 2018, 9:13 a.m. UTC | #9
On Thu, Aug 02, 2018 at 09:51:10AM +0100, Peter Maydell wrote:
> On 1 August 2018 at 22:58, Michael S. Tsirkin <mst@redhat.com> wrote:
> > 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

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

Patch

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index b129cb9ddd..d4cb5894a8 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -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);