All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/vtd: fix iommu_share_p2m_table
@ 2018-10-08 13:52 Roger Pau Monne
  2018-10-08 14:00 ` Paul Durrant
  2018-10-08 14:26 ` Jan Beulich
  0 siblings, 2 replies; 3+ messages in thread
From: Roger Pau Monne @ 2018-10-08 13:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Paul Durrant, Jan Beulich, Roger Pau Monne

Commit 2916951c1 "mm / iommu: include need_iommu() test in
iommu_use_hap_pt()" changed the check in iommu_share_p2m_table to use
need_iommu(d) (as part of iommu_use_hap_pt) instead of iommu_enabled,
which broke the check because at the point in domain construction
where iommu_share_p2m_table is called need_iommu(d) will always return
false.

Fix this by reverting to the previous logic.

While there turn the hap_enabled check into an ASSERT, since the only
caller of iommu_share_p2m_table already performs the hap_enabled check
before calling the function.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Paul Durrant <paul.durrant@citrix.com>
---
Changes since v1:
 - Add a comment about why iommu_use_hap_pt cannot be used in
   iommu_share_p2m_table.
 - Expand commit message.
 - Convert the hap_enabled check into an ASSERT.
---
 xen/drivers/passthrough/iommu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index debb5e6fe1..75bc410c2c 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -505,7 +505,13 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    ASSERT(hap_enabled(d));
+    /*
+     * iommu_use_hap_pt cannot be used here because at the point in the domain
+     * construction where iommu_share_p2m_table get called need_iommu(d) will
+     * always return false.
+     */
+    if ( iommu_enabled && iommu_hap_pt_share )
         iommu_get_ops()->share_p2m(d);
 }
 
-- 
2.19.0


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

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

* Re: [PATCH v2] x86/vtd: fix iommu_share_p2m_table
  2018-10-08 13:52 [PATCH v2] x86/vtd: fix iommu_share_p2m_table Roger Pau Monne
@ 2018-10-08 14:00 ` Paul Durrant
  2018-10-08 14:26 ` Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Durrant @ 2018-10-08 14:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Jan Beulich, Roger Pau Monne

> -----Original Message-----
> From: Roger Pau Monne [mailto:roger.pau@citrix.com]
> Sent: 08 October 2018 14:53
> To: xen-devel@lists.xenproject.org
> Cc: Roger Pau Monne <roger.pau@citrix.com>; Jan Beulich
> <jbeulich@suse.com>; Paul Durrant <Paul.Durrant@citrix.com>
> Subject: [PATCH v2] x86/vtd: fix iommu_share_p2m_table
> 
> Commit 2916951c1 "mm / iommu: include need_iommu() test in
> iommu_use_hap_pt()" changed the check in iommu_share_p2m_table to use
> need_iommu(d) (as part of iommu_use_hap_pt) instead of iommu_enabled,
> which broke the check because at the point in domain construction
> where iommu_share_p2m_table is called need_iommu(d) will always return
> false.
> 
> Fix this by reverting to the previous logic.
> 
> While there turn the hap_enabled check into an ASSERT, since the only
> caller of iommu_share_p2m_table already performs the hap_enabled check
> before calling the function.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Paul Durrant <paul.durrant@citrix.com>
> ---
> Changes since v1:
>  - Add a comment about why iommu_use_hap_pt cannot be used in
>    iommu_share_p2m_table.
>  - Expand commit message.
>  - Convert the hap_enabled check into an ASSERT.
> ---
>  xen/drivers/passthrough/iommu.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/passthrough/iommu.c
> b/xen/drivers/passthrough/iommu.c
> index debb5e6fe1..75bc410c2c 100644
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -505,7 +505,13 @@ int iommu_do_domctl(
> 
>  void iommu_share_p2m_table(struct domain* d)
>  {
> -    if ( iommu_use_hap_pt(d) )
> +    ASSERT(hap_enabled(d));
> +    /*
> +     * iommu_use_hap_pt cannot be used here because at the point in the
> domain
> +     * construction where iommu_share_p2m_table get called need_iommu(d)
> will
> +     * always return false.
> +     */
> +    if ( iommu_enabled && iommu_hap_pt_share )
>          iommu_get_ops()->share_p2m(d);
>  }
> 
> --
> 2.19.0

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

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

* Re: [PATCH v2] x86/vtd: fix iommu_share_p2m_table
  2018-10-08 13:52 [PATCH v2] x86/vtd: fix iommu_share_p2m_table Roger Pau Monne
  2018-10-08 14:00 ` Paul Durrant
@ 2018-10-08 14:26 ` Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2018-10-08 14:26 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, Paul Durrant

>>> On 08.10.18 at 15:52, <roger.pau@citrix.com> wrote:
> Commit 2916951c1 "mm / iommu: include need_iommu() test in
> iommu_use_hap_pt()" changed the check in iommu_share_p2m_table to use
> need_iommu(d) (as part of iommu_use_hap_pt) instead of iommu_enabled,
> which broke the check because at the point in domain construction
> where iommu_share_p2m_table is called need_iommu(d) will always return
> false.
> 
> Fix this by reverting to the previous logic.
> 
> While there turn the hap_enabled check into an ASSERT, since the only
> caller of iommu_share_p2m_table already performs the hap_enabled check
> before calling the function.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -505,7 +505,13 @@ int iommu_do_domctl(
>  
>  void iommu_share_p2m_table(struct domain* d)
>  {
> -    if ( iommu_use_hap_pt(d) )
> +    ASSERT(hap_enabled(d));
> +    /*
> +     * iommu_use_hap_pt cannot be used here because at the point in the domain
> +     * construction where iommu_share_p2m_table get called need_iommu(d) will
> +     * always return false.
> +     */

I'm fighting with myself whether to shorten this comment while
committing - it's certainly not "brief".

Jan


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

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

end of thread, other threads:[~2018-10-08 14:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 13:52 [PATCH v2] x86/vtd: fix iommu_share_p2m_table Roger Pau Monne
2018-10-08 14:00 ` Paul Durrant
2018-10-08 14:26 ` Jan Beulich

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.