diff mbox

[v2,4/4] x86/dom0: re-order DMA remapping enabling for PVH Dom0

Message ID 20170811164320.92899-5-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné Aug. 11, 2017, 4:43 p.m. UTC
Make sure the reserved regions are setup before enabling the DMA
remapping in the IOMMU, by calling dom0_setup_permissions before
iommu_hwdom_init. Also, in order to workaround IOMMU issues seen on
pre-Haswell Intel hardware, as described in patch "introduce a PVH
implementation of iommu_inclusive_mapping" make sure the DMA remapping
is enabled after populating Dom0 p2m.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
Changes since RFC:
 - Expand commit message to reference patch #3.
---
 xen/arch/x86/hvm/dom0_build.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Jan Beulich Aug. 22, 2017, 12:37 p.m. UTC | #1
>>> On 11.08.17 at 18:43, <roger.pau@citrix.com> wrote:
> Make sure the reserved regions are setup before enabling the DMA
> remapping in the IOMMU, by calling dom0_setup_permissions before
> iommu_hwdom_init.

I can't match up this part with ...

> --- a/xen/arch/x86/hvm/dom0_build.c
> +++ b/xen/arch/x86/hvm/dom0_build.c
> @@ -605,13 +605,6 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,
>          return rc;
>      }
>  
> -    rc = dom0_setup_permissions(d);
> -    if ( rc )
> -    {
> -        panic("Unable to setup Dom0 permissions: %d\n", rc);
> -        return rc;
> -    }
> -
>      update_domain_wallclock_time(d);
>  
>      clear_bit(_VPF_down, &v->pause_flags);
> @@ -1059,7 +1052,12 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
>  
>      printk("** Building a PVH Dom0 **\n");
>  
> -    iommu_hwdom_init(d);
> +    rc = dom0_setup_permissions(d);
> +    if ( rc )
> +    {
> +        printk("Unable to setup Dom0 permissions: %d\n", rc);
> +        return rc;
> +    }
>  
>      rc = pvh_setup_p2m(d);
>      if ( rc )
> @@ -1068,6 +1066,8 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
>          return rc;
>      }
>  
> +    iommu_hwdom_init(d);

... you not changing the relative order between these two function
calls. As to the other half I'm inclined to also wait for better
understanding of what's going on here, as said in reply to patch 3.

Jan
Roger Pau Monné Aug. 22, 2017, 2:05 p.m. UTC | #2
On Tue, Aug 22, 2017 at 06:37:15AM -0600, Jan Beulich wrote:
> >>> On 11.08.17 at 18:43, <roger.pau@citrix.com> wrote:
> > Make sure the reserved regions are setup before enabling the DMA
> > remapping in the IOMMU, by calling dom0_setup_permissions before
> > iommu_hwdom_init.
> 
> I can't match up this part with ...
> 
> > --- a/xen/arch/x86/hvm/dom0_build.c
> > +++ b/xen/arch/x86/hvm/dom0_build.c
> > @@ -605,13 +605,6 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,
> >          return rc;
> >      }
> >  
> > -    rc = dom0_setup_permissions(d);
> > -    if ( rc )
> > -    {
> > -        panic("Unable to setup Dom0 permissions: %d\n", rc);
> > -        return rc;
> > -    }
> > -
> >      update_domain_wallclock_time(d);
> >  
> >      clear_bit(_VPF_down, &v->pause_flags);
> > @@ -1059,7 +1052,12 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
> >  
> >      printk("** Building a PVH Dom0 **\n");
> >  
> > -    iommu_hwdom_init(d);
> > +    rc = dom0_setup_permissions(d);
> > +    if ( rc )
> > +    {
> > +        printk("Unable to setup Dom0 permissions: %d\n", rc);
> > +        return rc;
> > +    }
> >  
> >      rc = pvh_setup_p2m(d);
> >      if ( rc )
> > @@ -1068,6 +1066,8 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
> >          return rc;
> >      }
> >  
> > +    iommu_hwdom_init(d);
> 
> ... you not changing the relative order between these two function
> calls. As to the other half I'm inclined to also wait for better
> understanding of what's going on here, as said in reply to patch 3.

Why not?

dom0_setup_permissions was called from pvh_setup_cpus, while
iommu_hwdom_init was the first function called in
dom0_construct_pvh.

After this patch dom0_setup_permissions is always called before
iommu_hwdom_init.

Roger.
Jan Beulich Aug. 23, 2017, 8:21 a.m. UTC | #3
>>> On 22.08.17 at 16:05, <roger.pau@citrix.com> wrote:
> On Tue, Aug 22, 2017 at 06:37:15AM -0600, Jan Beulich wrote:
>> >>> On 11.08.17 at 18:43, <roger.pau@citrix.com> wrote:
>> > Make sure the reserved regions are setup before enabling the DMA
>> > remapping in the IOMMU, by calling dom0_setup_permissions before
>> > iommu_hwdom_init.
>> 
>> I can't match up this part with ...
>> 
>> > --- a/xen/arch/x86/hvm/dom0_build.c
>> > +++ b/xen/arch/x86/hvm/dom0_build.c
>> > @@ -605,13 +605,6 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,
>> >          return rc;
>> >      }
>> >  
>> > -    rc = dom0_setup_permissions(d);
>> > -    if ( rc )
>> > -    {
>> > -        panic("Unable to setup Dom0 permissions: %d\n", rc);
>> > -        return rc;
>> > -    }
>> > -
>> >      update_domain_wallclock_time(d);
>> >  
>> >      clear_bit(_VPF_down, &v->pause_flags);
>> > @@ -1059,7 +1052,12 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
>> >  
>> >      printk("** Building a PVH Dom0 **\n");
>> >  
>> > -    iommu_hwdom_init(d);
>> > +    rc = dom0_setup_permissions(d);
>> > +    if ( rc )
>> > +    {
>> > +        printk("Unable to setup Dom0 permissions: %d\n", rc);
>> > +        return rc;
>> > +    }
>> >  
>> >      rc = pvh_setup_p2m(d);
>> >      if ( rc )
>> > @@ -1068,6 +1066,8 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
>> >          return rc;
>> >      }
>> >  
>> > +    iommu_hwdom_init(d);
>> 
>> ... you not changing the relative order between these two function
>> calls. As to the other half I'm inclined to also wait for better
>> understanding of what's going on here, as said in reply to patch 3.
> 
> Why not?

Oh, I'm sorry - I should have looked at function names in the
hunk headers instead of just the sequence of hunks.

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index 020c355faf..0e7d06be95 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -605,13 +605,6 @@  static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,
         return rc;
     }
 
-    rc = dom0_setup_permissions(d);
-    if ( rc )
-    {
-        panic("Unable to setup Dom0 permissions: %d\n", rc);
-        return rc;
-    }
-
     update_domain_wallclock_time(d);
 
     clear_bit(_VPF_down, &v->pause_flags);
@@ -1059,7 +1052,12 @@  int __init dom0_construct_pvh(struct domain *d, const module_t *image,
 
     printk("** Building a PVH Dom0 **\n");
 
-    iommu_hwdom_init(d);
+    rc = dom0_setup_permissions(d);
+    if ( rc )
+    {
+        printk("Unable to setup Dom0 permissions: %d\n", rc);
+        return rc;
+    }
 
     rc = pvh_setup_p2m(d);
     if ( rc )
@@ -1068,6 +1066,8 @@  int __init dom0_construct_pvh(struct domain *d, const module_t *image,
         return rc;
     }
 
+    iommu_hwdom_init(d);
+
     rc = pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map(image),
                          cmdline, &entry, &start_info);
     if ( rc )