diff mbox

[Xen-devel,v3,05/13] xen/passthrough: rework dom0_pvh_reqs to use it also on ARM

Message ID 1394552999-14171-6-git-send-email-julien.grall@linaro.org
State Superseded, archived
Headers show

Commit Message

Julien Grall March 11, 2014, 3:49 p.m. UTC
DOM0 on ARM will have the same requirements as DOM0 PVH when iommu is enabled.
Both PVH and ARM guest has paging mode translate enabled, so Xen can use it
to know if it needs to check the requirements.

Rename the function and remove "pvh" word in the panic message.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Cc: Xiantao Zhang <xiantao.zhang@intel.com>

---
    Changes in v2:
        - IOMMU can be disabled on ARM if the platform doesn't have
        IOMMU.
---
 xen/drivers/passthrough/iommu.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Ian Campbell March 18, 2014, 4:22 p.m. UTC | #1
On Tue, 2014-03-11 at 15:49 +0000, Julien Grall wrote:
> DOM0 on ARM will have the same requirements as DOM0 PVH when iommu is enabled.
> Both PVH and ARM guest has paging mode translate enabled, so Xen can use it
> to know if it needs to check the requirements.
> 
> Rename the function and remove "pvh" word in the panic message.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> Cc: Xiantao Zhang <xiantao.zhang@intel.com>
> 
> ---
>     Changes in v2:
>         - IOMMU can be disabled on ARM if the platform doesn't have
>         IOMMU.
> ---
>  xen/drivers/passthrough/iommu.c |   13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> index c70165a..3c63f87 100644
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -130,13 +130,17 @@ int iommu_domain_init(struct domain *d)
>      return hd->platform_ops->init(d);
>  }
>  
> -static __init void check_dom0_pvh_reqs(struct domain *d)
> +static __init void check_dom0_reqs(struct domain *d)
>  {
> -    if ( !iommu_enabled )
> +    if ( !paging_mode_translate(d) )
> +        return;
> +
> +    if ( is_pvh_domain(d) && !iommu_enabled )

Is is_pvh_domain going to be exposed to common code on ARM?

Or would a arch_check_dom0_reqs be useful here?

>          panic("Presently, iommu must be enabled for pvh dom0\n");
>  
>      if ( iommu_passthrough )
> -        panic("For pvh dom0, dom0-passthrough must not be enabled\n");
> +        panic("Dom0 uses translate paging mode, dom0-passthrough must not be "

"paging translated mode" reads more natural to me.

> +              "enabled\n");
>  
>      iommu_dom0_strict = 1;
>  }
> @@ -145,8 +149,7 @@ void __init iommu_dom0_init(struct domain *d)
>  {
>      struct hvm_iommu *hd = domain_hvm_iommu(d);
>  
> -    if ( is_pvh_domain(d) )
> -        check_dom0_pvh_reqs(d);
> +    check_dom0_reqs(d);
>  
>      if ( !iommu_enabled )
>          return;
Julien Grall March 18, 2014, 5:28 p.m. UTC | #2
Hi Ian,

On 03/18/2014 04:22 PM, Ian Campbell wrote:
> On Tue, 2014-03-11 at 15:49 +0000, Julien Grall wrote:
>> DOM0 on ARM will have the same requirements as DOM0 PVH when iommu is enabled.
>> Both PVH and ARM guest has paging mode translate enabled, so Xen can use it
>> to know if it needs to check the requirements.
>>
>> Rename the function and remove "pvh" word in the panic message.
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>> Acked-by: Jan Beulich <jbeulich@suse.com>
>> Cc: Xiantao Zhang <xiantao.zhang@intel.com>
>>
>> ---
>>     Changes in v2:
>>         - IOMMU can be disabled on ARM if the platform doesn't have
>>         IOMMU.
>> ---
>>  xen/drivers/passthrough/iommu.c |   13 ++++++++-----
>>  1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
>> index c70165a..3c63f87 100644
>> --- a/xen/drivers/passthrough/iommu.c
>> +++ b/xen/drivers/passthrough/iommu.c
>> @@ -130,13 +130,17 @@ int iommu_domain_init(struct domain *d)
>>      return hd->platform_ops->init(d);
>>  }
>>  
>> -static __init void check_dom0_pvh_reqs(struct domain *d)
>> +static __init void check_dom0_reqs(struct domain *d)
>>  {
>> -    if ( !iommu_enabled )
>> +    if ( !paging_mode_translate(d) )
>> +        return;
>> +
>> +    if ( is_pvh_domain(d) && !iommu_enabled )
> 
> Is is_pvh_domain going to be exposed to common code on ARM?

It will be exposed to common code. For now is_pvh_domain is part of
xen/sched.h, do you plan to move it in asm-x86?

> Or would a arch_check_dom0_reqs be useful here?

I will update patch #7 to create this function.

>>          panic("Presently, iommu must be enabled for pvh dom0\n");
>>  
>>      if ( iommu_passthrough )
>> -        panic("For pvh dom0, dom0-passthrough must not be enabled\n");
>> +        panic("Dom0 uses translate paging mode, dom0-passthrough must not be "
> 
> "paging translated mode" reads more natural to me.

I will change in the next version.

Regards,
Ian Campbell March 18, 2014, 5:50 p.m. UTC | #3
On Tue, 2014-03-18 at 17:28 +0000, Julien Grall wrote:
> Hi Ian,
> 
> On 03/18/2014 04:22 PM, Ian Campbell wrote:
> > On Tue, 2014-03-11 at 15:49 +0000, Julien Grall wrote:
> >> DOM0 on ARM will have the same requirements as DOM0 PVH when iommu is enabled.
> >> Both PVH and ARM guest has paging mode translate enabled, so Xen can use it
> >> to know if it needs to check the requirements.
> >>
> >> Rename the function and remove "pvh" word in the panic message.
> >>
> >> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> >> Acked-by: Jan Beulich <jbeulich@suse.com>
> >> Cc: Xiantao Zhang <xiantao.zhang@intel.com>
> >>
> >> ---
> >>     Changes in v2:
> >>         - IOMMU can be disabled on ARM if the platform doesn't have
> >>         IOMMU.
> >> ---
> >>  xen/drivers/passthrough/iommu.c |   13 ++++++++-----
> >>  1 file changed, 8 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> >> index c70165a..3c63f87 100644
> >> --- a/xen/drivers/passthrough/iommu.c
> >> +++ b/xen/drivers/passthrough/iommu.c
> >> @@ -130,13 +130,17 @@ int iommu_domain_init(struct domain *d)
> >>      return hd->platform_ops->init(d);
> >>  }
> >>  
> >> -static __init void check_dom0_pvh_reqs(struct domain *d)
> >> +static __init void check_dom0_reqs(struct domain *d)
> >>  {
> >> -    if ( !iommu_enabled )
> >> +    if ( !paging_mode_translate(d) )
> >> +        return;
> >> +
> >> +    if ( is_pvh_domain(d) && !iommu_enabled )
> > 
> > Is is_pvh_domain going to be exposed to common code on ARM?
> 
> It will be exposed to common code. For now is_pvh_domain is part of
> xen/sched.h, do you plan to move it in asm-x86?

Oh, I hadn't realised it was already common. I don't plan to move it
myself.

> > Or would a arch_check_dom0_reqs be useful here?
> 
> I will update patch #7 to create this function.

I suppose given that is_pvh_domain is already common this isn't really
necessary, although maybe someone would thank you in the future for
reducing the common code use of is_pvh_domain a little...

> 
> >>          panic("Presently, iommu must be enabled for pvh dom0\n");
> >>  
> >>      if ( iommu_passthrough )
> >> -        panic("For pvh dom0, dom0-passthrough must not be enabled\n");
> >> +        panic("Dom0 uses translate paging mode, dom0-passthrough must not be "
> > 
> > "paging translated mode" reads more natural to me.
> 
> I will change in the next version.

Thanks.
Ian.
Julien Grall March 18, 2014, 6:19 p.m. UTC | #4
On 03/18/2014 05:50 PM, Ian Campbell wrote:
> On Tue, 2014-03-18 at 17:28 +0000, Julien Grall wrote:
>> It will be exposed to common code. For now is_pvh_domain is part of
>> xen/sched.h, do you plan to move it in asm-x86?
> 
> Oh, I hadn't realised it was already common. I don't plan to move it
> myself.

It might be a good thing to prevent people using is_{hvm,pv,pvh}_domain
in common code.

Regards,
Ian Campbell March 19, 2014, 10:01 a.m. UTC | #5
On Tue, 2014-03-18 at 18:19 +0000, Julien Grall wrote:
> On 03/18/2014 05:50 PM, Ian Campbell wrote:
> > On Tue, 2014-03-18 at 17:28 +0000, Julien Grall wrote:
> >> It will be exposed to common code. For now is_pvh_domain is part of
> >> xen/sched.h, do you plan to move it in asm-x86?
> > 
> > Oh, I hadn't realised it was already common. I don't plan to move it
> > myself.
> 
> It might be a good thing to prevent people using is_{hvm,pv,pvh}_domain
> in common code.

Certainly it's a worth cause.

Ian.
diff mbox

Patch

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index c70165a..3c63f87 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -130,13 +130,17 @@  int iommu_domain_init(struct domain *d)
     return hd->platform_ops->init(d);
 }
 
-static __init void check_dom0_pvh_reqs(struct domain *d)
+static __init void check_dom0_reqs(struct domain *d)
 {
-    if ( !iommu_enabled )
+    if ( !paging_mode_translate(d) )
+        return;
+
+    if ( is_pvh_domain(d) && !iommu_enabled )
         panic("Presently, iommu must be enabled for pvh dom0\n");
 
     if ( iommu_passthrough )
-        panic("For pvh dom0, dom0-passthrough must not be enabled\n");
+        panic("Dom0 uses translate paging mode, dom0-passthrough must not be "
+              "enabled\n");
 
     iommu_dom0_strict = 1;
 }
@@ -145,8 +149,7 @@  void __init iommu_dom0_init(struct domain *d)
 {
     struct hvm_iommu *hd = domain_hvm_iommu(d);
 
-    if ( is_pvh_domain(d) )
-        check_dom0_pvh_reqs(d);
+    check_dom0_reqs(d);
 
     if ( !iommu_enabled )
         return;