diff mbox

[qemu,v14,12/18] vfio: Check that IOMMU MR translates to system address space

Message ID 1458546426-26222-13-git-send-email-aik@ozlabs.ru (mailing list archive)
State New, archived
Headers show

Commit Message

Alexey Kardashevskiy March 21, 2016, 7:47 a.m. UTC
At the moment IOMMU MR only translate to the system memory.
However if some new code changes this, we will need clear indication why
it is not working so here is the check.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v14:
* new to the series
---
 hw/vfio/common.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

David Gibson March 22, 2016, 3:05 a.m. UTC | #1
On Mon, Mar 21, 2016 at 06:47:00PM +1100, Alexey Kardashevskiy wrote:
> At the moment IOMMU MR only translate to the system memory.
> However if some new code changes this, we will need clear indication why
> it is not working so here is the check.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

Alex, any chance we could merge this quickly, since it is a reasonable
sanity check even without the rest of the changes.

> ---
> Changes:
> v14:
> * new to the series
> ---
>  hw/vfio/common.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 55723c9..9587c25 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -266,6 +266,12 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
>  
>      trace_vfio_iommu_map_notify(iova, iova + iotlb->addr_mask);
>  
> +    if (iotlb->target_as != &address_space_memory) {
> +        error_report("Wrong target AS \"%s\", only system memory is allowed",
> +                     iotlb->target_as->name?iotlb->target_as->name:"noname");
> +        return;
> +    }
> +
>      /*
>       * The IOMMU TLB entry we have just covers translation through
>       * this IOMMU to its immediate target.  We need to translate
Alex Williamson March 22, 2016, 3:47 p.m. UTC | #2
On Tue, 22 Mar 2016 14:05:15 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Mon, Mar 21, 2016 at 06:47:00PM +1100, Alexey Kardashevskiy wrote:
> > At the moment IOMMU MR only translate to the system memory.
> > However if some new code changes this, we will need clear indication why
> > it is not working so here is the check.
> > 
> > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>  
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 
> Alex, any chance we could merge this quickly, since it is a reasonable
> sanity check even without the rest of the changes.

It all sounds very theoretical to inspire some rush to merge it
quickly, is there any chance we could actually hit this currently?

> > ---
> > Changes:
> > v14:
> > * new to the series
> > ---
> >  hw/vfio/common.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > index 55723c9..9587c25 100644
> > --- a/hw/vfio/common.c
> > +++ b/hw/vfio/common.c
> > @@ -266,6 +266,12 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
> >  
> >      trace_vfio_iommu_map_notify(iova, iova + iotlb->addr_mask);
> >  
> > +    if (iotlb->target_as != &address_space_memory) {
> > +        error_report("Wrong target AS \"%s\", only system memory is allowed",
> > +                     iotlb->target_as->name?iotlb->target_as->name:"noname");

Spaces please.

> > +        return;
> > +    }
> > +
> >      /*
> >       * The IOMMU TLB entry we have just covers translation through
> >       * this IOMMU to its immediate target.  We need to translate  
>
David Gibson March 23, 2016, 12:43 a.m. UTC | #3
On Tue, Mar 22, 2016 at 09:47:10AM -0600, Alex Williamson wrote:
> On Tue, 22 Mar 2016 14:05:15 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Mon, Mar 21, 2016 at 06:47:00PM +1100, Alexey Kardashevskiy wrote:
> > > At the moment IOMMU MR only translate to the system memory.
> > > However if some new code changes this, we will need clear indication why
> > > it is not working so here is the check.
> > > 
> > > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>  
> > 
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > 
> > Alex, any chance we could merge this quickly, since it is a reasonable
> > sanity check even without the rest of the changes.
> 
> It all sounds very theoretical to inspire some rush to merge it
> quickly, is there any chance we could actually hit this currently?

Hm, I guess not.  Ok, let's leave it for now.

> 
> > > ---
> > > Changes:
> > > v14:
> > > * new to the series
> > > ---
> > >  hw/vfio/common.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > > index 55723c9..9587c25 100644
> > > --- a/hw/vfio/common.c
> > > +++ b/hw/vfio/common.c
> > > @@ -266,6 +266,12 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
> > >  
> > >      trace_vfio_iommu_map_notify(iova, iova + iotlb->addr_mask);
> > >  
> > > +    if (iotlb->target_as != &address_space_memory) {
> > > +        error_report("Wrong target AS \"%s\", only system memory is allowed",
> > > +                     iotlb->target_as->name?iotlb->target_as->name:"noname");
> 
> Spaces please.
> 
> > > +        return;
> > > +    }
> > > +
> > >      /*
> > >       * The IOMMU TLB entry we have just covers translation through
> > >       * this IOMMU to its immediate target.  We need to translate  
> > 
>
Alexey Kardashevskiy March 23, 2016, 12:44 a.m. UTC | #4
On 03/23/2016 02:47 AM, Alex Williamson wrote:
> On Tue, 22 Mar 2016 14:05:15 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
>> On Mon, Mar 21, 2016 at 06:47:00PM +1100, Alexey Kardashevskiy wrote:
>>> At the moment IOMMU MR only translate to the system memory.
>>> However if some new code changes this, we will need clear indication why
>>> it is not working so here is the check.
>>>
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>
>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>>
>> Alex, any chance we could merge this quickly, since it is a reasonable
>> sanity check even without the rest of the changes.
>
> It all sounds very theoretical to inspire some rush to merge it
> quickly, is there any chance we could actually hit this currently?


The chances are as big as chances that some platform starts supporting VFIO 
soon, for these new folks such a check would be a good piece of 
documentation or at least a warning trigger to ask a question in the lists.



>>> ---
>>> Changes:
>>> v14:
>>> * new to the series
>>> ---
>>>   hw/vfio/common.c | 6 ++++++
>>>   1 file changed, 6 insertions(+)
>>>
>>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>>> index 55723c9..9587c25 100644
>>> --- a/hw/vfio/common.c
>>> +++ b/hw/vfio/common.c
>>> @@ -266,6 +266,12 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
>>>
>>>       trace_vfio_iommu_map_notify(iova, iova + iotlb->addr_mask);
>>>
>>> +    if (iotlb->target_as != &address_space_memory) {
>>> +        error_report("Wrong target AS \"%s\", only system memory is allowed",
>>> +                     iotlb->target_as->name?iotlb->target_as->name:"noname");
>
> Spaces please.
>
>>> +        return;
>>> +    }
>>> +
>>>       /*
>>>        * The IOMMU TLB entry we have just covers translation through
>>>        * this IOMMU to its immediate target.  We need to translate
>>
>
diff mbox

Patch

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 55723c9..9587c25 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -266,6 +266,12 @@  static void vfio_iommu_map_notify(Notifier *n, void *data)
 
     trace_vfio_iommu_map_notify(iova, iova + iotlb->addr_mask);
 
+    if (iotlb->target_as != &address_space_memory) {
+        error_report("Wrong target AS \"%s\", only system memory is allowed",
+                     iotlb->target_as->name?iotlb->target_as->name:"noname");
+        return;
+    }
+
     /*
      * The IOMMU TLB entry we have just covers translation through
      * this IOMMU to its immediate target.  We need to translate