All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
@ 2019-09-26 10:03 Paul Durrant
  2019-09-26 11:24 ` Julien Grall
  2019-09-26 12:12 ` Jan Beulich
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Durrant @ 2019-09-26 10:03 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan, Oleksandr,
	Julien Grall, Paul Durrant, Jan Beulich

...when the IOMMU is not enabled.

80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync()
macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global
'iommu_hap_pt_share' option to be replaced with a #define-d value of true.
In this configuration, calling clear_iommu_hap_pt_share() will result
trigger the aforementioned ASSERT.

CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and,
because clear_iommu_hap_pt_share() is called by the common iommu_setup()
function if the IOMMU is not enabled, it is no longer safe to disable the
IOMMU on ARM systems.

However, running with the IOMMU disabled is a valid configuration for ARM
systems, so this patch rectifies the problem by removing the call to
clear_iommu_hap_pt_share() from common code. As a side effect of this,
however, it becomes possible on x86 systems for iommu_enabled to be false
but iommu_hap_pt_share to be true. Thus the code in sysctl.c
needs to be changed to make sure that XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share
is not erroneously advertised when the IOMMU has been disabled.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reported-by: Oleksandr <olekstysh@gmail.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wl@xen.org>
---
 xen/common/sysctl.c             | 6 ++++--
 xen/drivers/passthrough/iommu.c | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index e8763c7fdf..f88a285e7f 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -268,9 +268,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
         pi->max_mfn = get_upper_mfn_bound();
         arch_do_physinfo(pi);
         if ( iommu_enabled )
+        {
             pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio;
-        if ( iommu_hap_pt_share )
-            pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
+            if ( iommu_hap_pt_share )
+                pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
+        }
 
         if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index e8fddc2dc7..c33ca70ec9 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -456,7 +456,6 @@ int __init iommu_setup(void)
     if ( !iommu_enabled )
     {
         iommu_intremap = 0;
-        clear_iommu_hap_pt_share();
     }
 
     if ( (force_iommu && !iommu_enabled) ||
-- 
2.20.1.2.gb21ebb671


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
  2019-09-26 10:03 [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM Paul Durrant
@ 2019-09-26 11:24 ` Julien Grall
  2019-09-26 11:30   ` Oleksandr
  2019-09-26 11:32   ` Paul Durrant
  2019-09-26 12:12 ` Jan Beulich
  1 sibling, 2 replies; 6+ messages in thread
From: Julien Grall @ 2019-09-26 11:24 UTC (permalink / raw)
  To: Paul Durrant, xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan, Oleksandr,
	Jan Beulich

Hi Paul,

On 9/26/19 11:03 AM, Paul Durrant wrote:
> ...when the IOMMU is not enabled.
> 
> 80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync()
> macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global
> 'iommu_hap_pt_share' option to be replaced with a #define-d value of true.
> In this configuration, calling clear_iommu_hap_pt_share() will result
> trigger the aforementioned ASSERT.
> 
> CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and,
> because clear_iommu_hap_pt_share() is called by the common iommu_setup()
> function if the IOMMU is not enabled, it is no longer safe to disable the
> IOMMU on ARM systems.
> 
> However, running with the IOMMU disabled is a valid configuration for ARM
> systems, so this patch rectifies the problem by removing the call to
> clear_iommu_hap_pt_share() from common code. As a side effect of this,
> however, it becomes possible on x86 systems for iommu_enabled to be false
> but iommu_hap_pt_share to be true. Thus the code in sysctl.c
> needs to be changed to make sure that XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share
> is not erroneously advertised when the IOMMU has been disabled.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Reported-by: Oleksandr <olekstysh@gmail.com>

With one NIT below:

Acked-by: Julien Grall <julien.grall@arm.com>

> ---
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Julien Grall <julien.grall@arm.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Wei Liu <wl@xen.org>
> ---
>   xen/common/sysctl.c             | 6 ++++--
>   xen/drivers/passthrough/iommu.c | 1 -
>   2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
> index e8763c7fdf..f88a285e7f 100644
> --- a/xen/common/sysctl.c
> +++ b/xen/common/sysctl.c
> @@ -268,9 +268,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
>           pi->max_mfn = get_upper_mfn_bound();
>           arch_do_physinfo(pi);
>           if ( iommu_enabled )
> +        {
>               pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio;
> -        if ( iommu_hap_pt_share )
> -            pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
> +            if ( iommu_hap_pt_share )
> +                pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
> +        }
>   
>           if ( copy_to_guest(u_sysctl, op, 1) )
>               ret = -EFAULT;
> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> index e8fddc2dc7..c33ca70ec9 100644
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -456,7 +456,6 @@ int __init iommu_setup(void)
>       if ( !iommu_enabled )
>       {
>           iommu_intremap = 0;
> -        clear_iommu_hap_pt_share();
>       }

NIT: The {} can now be removed.

I can fix it on commit.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
  2019-09-26 11:24 ` Julien Grall
@ 2019-09-26 11:30   ` Oleksandr
  2019-09-26 11:32   ` Paul Durrant
  1 sibling, 0 replies; 6+ messages in thread
From: Oleksandr @ 2019-09-26 11:30 UTC (permalink / raw)
  To: Julien Grall, Paul Durrant, xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Jan Beulich


Hi Paul, Julien


On 26.09.19 14:24, Julien Grall wrote:
> Hi Paul,
>
> On 9/26/19 11:03 AM, Paul Durrant wrote:
>> ...when the IOMMU is not enabled.
>>
>> 80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync()
>> macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global
>> 'iommu_hap_pt_share' option to be replaced with a #define-d value of 
>> true.
>> In this configuration, calling clear_iommu_hap_pt_share() will result
>> trigger the aforementioned ASSERT.
>>
>> CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and,
>> because clear_iommu_hap_pt_share() is called by the common iommu_setup()
>> function if the IOMMU is not enabled, it is no longer safe to disable 
>> the
>> IOMMU on ARM systems.
>>
>> However, running with the IOMMU disabled is a valid configuration for 
>> ARM
>> systems, so this patch rectifies the problem by removing the call to
>> clear_iommu_hap_pt_share() from common code. As a side effect of this,
>> however, it becomes possible on x86 systems for iommu_enabled to be 
>> false
>> but iommu_hap_pt_share to be true. Thus the code in sysctl.c
>> needs to be changed to make sure that 
>> XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share
>> is not erroneously advertised when the IOMMU has been disabled.
>>
>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>> Reported-by: Oleksandr <olekstysh@gmail.com>
>
> With one NIT below:
>
> Acked-by: Julien Grall <julien.grall@arm.com>


Could you, please, change to:

Reported-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>


You can also add if really needed:

[with IOMMU disabled on Arm]

Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

-- 
Regards,

Oleksandr Tyshchenko


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
  2019-09-26 11:24 ` Julien Grall
  2019-09-26 11:30   ` Oleksandr
@ 2019-09-26 11:32   ` Paul Durrant
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Durrant @ 2019-09-26 11:32 UTC (permalink / raw)
  To: 'Julien Grall', xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	Andrew Cooper, Tim (Xen.org),
	George Dunlap, Oleksandr, Jan Beulich, Ian Jackson

> -----Original Message-----
> From: Julien Grall <julien.grall@arm.com>
> Sent: 26 September 2019 12:24
> To: Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xenproject.org
> Cc: Oleksandr <olekstysh@gmail.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Jan Beulich <jbeulich@suse.com>;
> Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>; Stefano Stabellini <sstabellini@kernel.org>; Tim
> (Xen.org) <tim@xen.org>; Wei Liu <wl@xen.org>
> Subject: Re: [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
> 
> Hi Paul,
> 
> On 9/26/19 11:03 AM, Paul Durrant wrote:
> > ...when the IOMMU is not enabled.
> >
> > 80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync()
> > macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global
> > 'iommu_hap_pt_share' option to be replaced with a #define-d value of true.
> > In this configuration, calling clear_iommu_hap_pt_share() will result
> > trigger the aforementioned ASSERT.
> >
> > CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and,
> > because clear_iommu_hap_pt_share() is called by the common iommu_setup()
> > function if the IOMMU is not enabled, it is no longer safe to disable the
> > IOMMU on ARM systems.
> >
> > However, running with the IOMMU disabled is a valid configuration for ARM
> > systems, so this patch rectifies the problem by removing the call to
> > clear_iommu_hap_pt_share() from common code. As a side effect of this,
> > however, it becomes possible on x86 systems for iommu_enabled to be false
> > but iommu_hap_pt_share to be true. Thus the code in sysctl.c
> > needs to be changed to make sure that XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share
> > is not erroneously advertised when the IOMMU has been disabled.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > Reported-by: Oleksandr <olekstysh@gmail.com>
> 
> With one NIT below:
> 
> Acked-by: Julien Grall <julien.grall@arm.com>
> 
> > ---
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Julien Grall <julien.grall@arm.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Tim Deegan <tim@xen.org>
> > Cc: Wei Liu <wl@xen.org>
> > ---
> >   xen/common/sysctl.c             | 6 ++++--
> >   xen/drivers/passthrough/iommu.c | 1 -
> >   2 files changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
> > index e8763c7fdf..f88a285e7f 100644
> > --- a/xen/common/sysctl.c
> > +++ b/xen/common/sysctl.c
> > @@ -268,9 +268,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
> >           pi->max_mfn = get_upper_mfn_bound();
> >           arch_do_physinfo(pi);
> >           if ( iommu_enabled )
> > +        {
> >               pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio;
> > -        if ( iommu_hap_pt_share )
> > -            pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
> > +            if ( iommu_hap_pt_share )
> > +                pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
> > +        }
> >
> >           if ( copy_to_guest(u_sysctl, op, 1) )
> >               ret = -EFAULT;
> > diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> > index e8fddc2dc7..c33ca70ec9 100644
> > --- a/xen/drivers/passthrough/iommu.c
> > +++ b/xen/drivers/passthrough/iommu.c
> > @@ -456,7 +456,6 @@ int __init iommu_setup(void)
> >       if ( !iommu_enabled )
> >       {
> >           iommu_intremap = 0;
> > -        clear_iommu_hap_pt_share();
> >       }
> 
> NIT: The {} can now be removed.
> 
> I can fix it on commit.

Good point. Thanks,

  Paul

> 
> Cheers,
> 
> --
> Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
  2019-09-26 10:03 [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM Paul Durrant
  2019-09-26 11:24 ` Julien Grall
@ 2019-09-26 12:12 ` Jan Beulich
  2019-09-26 13:53   ` Julien Grall
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2019-09-26 12:12 UTC (permalink / raw)
  To: Paul Durrant
  Cc: Stefano Stabellini, Wei Liu, KonradRzeszutek Wilk, George Dunlap,
	Andrew Cooper, Ian Jackson, Tim Deegan, Oleksandr, Julien Grall,
	xen-devel

On 26.09.2019 12:03, Paul Durrant wrote:
> ...when the IOMMU is not enabled.
> 
> 80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync()
> macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global
> 'iommu_hap_pt_share' option to be replaced with a #define-d value of true.
> In this configuration, calling clear_iommu_hap_pt_share() will result
> trigger the aforementioned ASSERT.
> 
> CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and,
> because clear_iommu_hap_pt_share() is called by the common iommu_setup()
> function if the IOMMU is not enabled, it is no longer safe to disable the
> IOMMU on ARM systems.
> 
> However, running with the IOMMU disabled is a valid configuration for ARM
> systems, so this patch rectifies the problem by removing the call to
> clear_iommu_hap_pt_share() from common code. As a side effect of this,
> however, it becomes possible on x86 systems for iommu_enabled to be false
> but iommu_hap_pt_share to be true. Thus the code in sysctl.c
> needs to be changed to make sure that XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share
> is not erroneously advertised when the IOMMU has been disabled.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Reported-by: Oleksandr <olekstysh@gmail.com>

Preferably with the adjustments mantioned elsewhere
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
  2019-09-26 12:12 ` Jan Beulich
@ 2019-09-26 13:53   ` Julien Grall
  0 siblings, 0 replies; 6+ messages in thread
From: Julien Grall @ 2019-09-26 13:53 UTC (permalink / raw)
  To: Jan Beulich, Paul Durrant
  Cc: Stefano Stabellini, Wei Liu, KonradRzeszutek Wilk, George Dunlap,
	Andrew Cooper, Ian Jackson, Tim Deegan, Oleksandr, xen-devel

Hi Jan,

On 9/26/19 1:12 PM, Jan Beulich wrote:
> On 26.09.2019 12:03, Paul Durrant wrote:
>> ...when the IOMMU is not enabled.
>>
>> 80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync()
>> macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global
>> 'iommu_hap_pt_share' option to be replaced with a #define-d value of true.
>> In this configuration, calling clear_iommu_hap_pt_share() will result
>> trigger the aforementioned ASSERT.
>>
>> CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and,
>> because clear_iommu_hap_pt_share() is called by the common iommu_setup()
>> function if the IOMMU is not enabled, it is no longer safe to disable the
>> IOMMU on ARM systems.
>>
>> However, running with the IOMMU disabled is a valid configuration for ARM
>> systems, so this patch rectifies the problem by removing the call to
>> clear_iommu_hap_pt_share() from common code. As a side effect of this,
>> however, it becomes possible on x86 systems for iommu_enabled to be false
>> but iommu_hap_pt_share to be true. Thus the code in sysctl.c
>> needs to be changed to make sure that XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share
>> is not erroneously advertised when the IOMMU has been disabled.
>>
>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>> Reported-by: Oleksandr <olekstysh@gmail.com>
> 
> Preferably with the adjustments mantioned elsewhere
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

I have done it while committing the patch.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-26 13:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-26 10:03 [Xen-devel] [PATCH] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM Paul Durrant
2019-09-26 11:24 ` Julien Grall
2019-09-26 11:30   ` Oleksandr
2019-09-26 11:32   ` Paul Durrant
2019-09-26 12:12 ` Jan Beulich
2019-09-26 13:53   ` Julien Grall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.