xen/iommu: fix usage of shared EPT/IOMMU page tables on PVH guests
PATCH v2 1/1 xen/iommu: fix usage of shared EPT/IOMMU page tables on PVH guests
iommu_share_p2m_table should not prevent PVH guests from using a shared page table between the IOMMU and EPT. Clean the code by removing the asserts in the vendor specific implementations (amd_iommu_share_p2m, iommu_set_pgd), and moving the hap_enabled assert to the caller (iommu_share_p2m_table).
Also fix another incorrect usage of is_hvm_domain usage in arch_iommu_populate_page_table. This has not given problems so far because all the pages in PVH guests are of type PGT_writable_page.
---
Changes since v1:
- Reword commit message.
- Move the hap_enabled assert from vendor implementation to the generic code.
- Remove the has_hvm_container_domain condition from iommu_share_p2m_table, hap_enabled is more restrictive.
--- xen/drivers/passthrough/amd/iommu_map.c | 2 -- xen/drivers/passthrough/iommu.c | 3 ++- xen/drivers/passthrough/vtd/iommu.c | 2 -- xen/drivers/passthrough/x86/iommu.c | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-)
xen/drivers/passthrough/amd/iommu_map.c +0 -2
@@ -785,8 +785,6 @@ void amd_iommu_share_p2m(struct domain *d)struct page_info *p2m_table;mfn_t pgd_mfn; -ASSERT (is_hvm_domain (d) && d->arch.hvm_domain.hap_enabled ); -if ( !iommu_use_hap_pt (d) )return ;
xen/drivers/passthrough/iommu.c +2 -1
@@ -332,7 +332,8 @@ void iommu_share_p2m_table(struct domain* d) {const struct iommu_ops *ops =iommu_get_ops (); -if ( iommu_enabled &&is_hvm_domain (d) ) +ASSERT (hap_enabled (d) ); +if ( iommu_enabled ) ops->share_p2m (d); }
xen/drivers/passthrough/vtd/iommu.c +0 -2
@@ -1788,8 +1788,6 @@ static void iommu_set_pgd(struct domain *d)struct hvm_iommu *hd =domain_hvm_iommu (d);mfn_t pgd_mfn; -ASSERT (is_hvm_domain (d) && d->arch.hvm_domain.hap_enabled ); -if ( !iommu_use_hap_pt (d) )return ;
xen/drivers/passthrough/x86/iommu.c +1 -1
@@ -56,7 +56,7 @@ int arch_iommu_populate_page_table(struct domain *d)while ( !rc && (page =page_list_remove_head (&d->page_list)) ) { -if (is_hvm_domain (d) || +if (has_hvm_container_domain (d) || (page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page ) {BUG_ON (SHARED_M2P (mfn_to_gmfn (d,page_to_mfn (page))));
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 8 lines · Roger Pau Monne
iommu_share_p2m_tableshould not prevent PVH guests from using a shared page table between the IOMMU and EPT. Clean the code by removing the asserts in the vendor specific implementations (amd_iommu_share_p2m,iommu_set_pgd), and moving thehap_enabledassert to the caller (iommu_share_p2m_table).Also fix another incorrect usage of
is_hvm_domainusage inarch_iommu_populate_page_table. This has not given problems so far because all the pages in PVH guests are of typePGT_writable_page.
dom0 PVH failed to boot on my test system without this patch so:
Thanks.
David
Quoted 10 lines · Roger Pau Monne
iommu_share_p2m_tableshould not prevent PVH guests from using a shared page table between the IOMMU and EPT. Clean the code by removing the asserts in the vendor specific implementations (amd_iommu_share_p2m,iommu_set_pgd), and moving thehap_enabledassert to the caller (iommu_share_p2m_table).Also fix another incorrect usage of
is_hvm_domainusage inarch_iommu_populate_page_table. This has not given problems so far because all the pages in PVH guests are of typePGT_writable_page.Signed-off-by Roger Pau Monné <[email protected]>
Quoted 15 lines
From: Roger Pau Monne [mailto:[email protected]]
Sent: Friday, February 27, 2015 7:34 PM
iommu_share_p2m_tableshould not prevent PVH guests from using a shared page
table between the IOMMU and EPT. Clean the code by removing the asserts in the vendor specific implementations (amd_iommu_share_p2m,iommu_set_pgd),
and moving thehap_enabledassert to the caller (iommu_share_p2m_table).Also fix another incorrect usage of
is_hvm_domainusage inarch_iommu_populate_page_table. This has not given problems so far because
all the pages in PVH guests are of typePGT_writable_page.
Quoted 6 lines
Signed-off-by Roger Pau Monné <[email protected]>Cc Suravee Suthikulpanit <[email protected]>Cc Aravind Gopalakrishnan <[email protected]>Cc Jan Beulich <[email protected]>Cc Yang Zhang <[email protected]>Cc Kevin Tian <[email protected]>
btw, does this patch fix your earlier iommu faults with PVH Dom0?
Thanks
Kevin
Quoted 73 lines
---
Changes since v1:
- Reword commit message.
- Move thehap_enabledassert from vendor implementation to the generic code.
- Remove thehas_hvm_container_domaincondition fromiommu_share_p2m_table,
hap_enabledis more restrictive.--- xen/drivers/passthrough/amd/iommu_map.c | 2 -- xen/drivers/passthrough/iommu.c | 3 ++- xen/drivers/passthrough/vtd/iommu.c | 2 -- xen/drivers/passthrough/x86/iommu.c | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-)xen/drivers/passthrough/amd/iommu_map.c +0
-2@@ -785,8 +785,6 @@ void amd_iommu_share_p2m(struct domain *d)struct page_info *p2m_table;mfn_t pgd_mfn; -ASSERT (is_hvm_domain (d) && d->arch.hvm_domain.hap_enabled ); -if ( !iommu_use_hap_pt (d) )return ;xen/drivers/passthrough/iommu.c +2
-1@@ -332,7 +332,8 @@ void iommu_share_p2m_table(struct domain* d) {const struct iommu_ops *ops =iommu_get_ops (); -if ( iommu_enabled &&is_hvm_domain (d) ) +ASSERT (hap_enabled (d) ); +if ( iommu_enabled ) ops->share_p2m (d); }xen/drivers/passthrough/vtd/iommu.c +0
-2@@ -1788,8 +1788,6 @@ static void iommu_set_pgd(struct domain *d)struct hvm_iommu *hd =domain_hvm_iommu (d);mfn_t pgd_mfn; -ASSERT (is_hvm_domain (d) && d->arch.hvm_domain.hap_enabled ); -if ( !iommu_use_hap_pt (d) )return ;xen/drivers/passthrough/x86/iommu.c +1
-1@@ -56,7 +56,7 @@ int arch_iommu_populate_page_table(struct domain *d)while ( !rc && (page =page_list_remove_head (&d->page_list)) ) { -if (is_hvm_domain (d) || +if (has_hvm_container_domain (d) || (page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page ) {BUG_ON(SHARED_M2P(mfn_to_gmfn(d,
Quoted 3 lines
page_to_mfn(page))));
--
1.9.3 (Apple Git-50)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
El 09/03/15 a les 4.30, Tian, Kevin ha escrit:
Quoted 22 lines
Quoted 15 lines
From: Roger Pau Monne [mailto:[email protected]]
Sent: Friday, February 27, 2015 7:34 PM
iommu_share_p2m_tableshould not prevent PVH guests from using a shared page
table between the IOMMU and EPT. Clean the code by removing the asserts in the vendor specific implementations (amd_iommu_share_p2m,iommu_set_pgd),
and moving thehap_enabledassert to the caller (iommu_share_p2m_table).Also fix another incorrect usage of
is_hvm_domainusage inarch_iommu_populate_page_table. This has not given problems so far because
all the pages in PVH guests are of typePGT_writable_page.Quoted 6 lines
Signed-off-by Roger Pau Monné <[email protected]>Cc Suravee Suthikulpanit <[email protected]>Cc Aravind Gopalakrishnan <[email protected]>Cc Jan Beulich <[email protected]>Cc Yang Zhang <[email protected]>Cc Kevin Tian <[email protected]>
Quoted 3 lines
Acked-by Kevin Tian <[email protected]>btw, does this patch fix your earlier iommu faults with PVH Dom0?
Yes, it fixes booting a PVH Dom0 on hosts that share the page tables between EPT and the IOMMU(s).
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hi,
xen/drivers/passthrough/iommu.c void iommu_share_p2m_table(struct domain* d) · line 335
Quoted 10 lines · Roger Pau Monne
xen/drivers/passthrough/iommu.c +1
-1@@ -332,7 +332,8 @@ void iommu_share_p2m_table(struct domain* d) {const struct iommu_ops *ops =iommu_get_ops (); -if ( iommu_enabled &&is_hvm_domain (d) ) +ASSERT (hap_enabled (d) );
This line is breaking compilation on ARM.
Shouldn't it be replaced by iommu_use_hap_pt?
xen/drivers/passthrough/iommu.c void iommu_share_p2m_table(struct domain* d) · line 336
Quoted 1 line
xen/drivers/passthrough/iommu.c +1
-0+if ( iommu_enabled )
Regards,
Signature · 1 line
Julien Grall
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 10.03.15 at 13:51, <[email protected]> wrote:
Hi,
Review
Quoted 1 line · Roger Pau Monne
(quoted diff) +0
-0
b/xen/drivers/passthrough/iommu.cQuoted 7 lines
index cc12735..7fcbbb1 100644
xen/drivers/passthrough/iommu.c +0
-0@@ -332,7 +332,8 @@ void iommu_share_p2m_table(struct domain* d) {const struct iommu_ops *ops =iommu_get_ops ();
Quoted 6 lines
xen/drivers/passthrough/iommu.c void iommu_share_p2m_table(struct domain* d) · line 335
Quoted 2 lines
xen/drivers/passthrough/iommu.c +1
-1-if ( iommu_enabled &&is_hvm_domain (d) ) +ASSERT (hap_enabled (d) );This line is breaking compilation on ARM.
Shouldn't it be replaced by
iommu_use_hap_pt?
No, that's a different thing. But shouldn't ARM have a stub hap_enabled() evaluating to constant true?
Jan
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 10.03.15 at 13:51, <[email protected]> wrote:
Hi,
Review
Quoted 1 line · Roger Pau Monne
(quoted diff) +0
-0
b/xen/drivers/passthrough/iommu.cxen/drivers/passthrough/iommu.c void iommu_share_p2m_table(struct domain* d) · line 335
Quoted 9 lines
index cc12735..7fcbbb1 100644
xen/drivers/passthrough/iommu.c +1
-1@@ -332,7 +332,8 @@ void iommu_share_p2m_table(struct domain* d) {const struct iommu_ops *ops =iommu_get_ops (); -if ( iommu_enabled &&is_hvm_domain (d) ) +ASSERT (hap_enabled (d) );This line is breaking compilation on ARM.
Quoted 4 lines
Quoted 1 line
Shouldn't it be replaced by
iommu_use_hap_pt?No, that's a different thing. But shouldn't ARM have a stub
hap_enabled()evaluating to constant true?
I'm not sure if we should introduce hap_enabled. It's not something that we should used in general.
What are we trying to catch with this ASSERT? I guess wrong caller?
If so, every share_p2m callbacks have a check "if iommu_use_hap_pt()" which contains a check to hap_enabled on x86.
So I don't think this check is worthwhile in the common iommu code.
Regards,
Signature · 1 line
Julien Grall
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 10.03.15 at 14:18, <[email protected]> wrote:
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 10.03.15 at 13:51, <[email protected]> wrote:
Hi,
Review
Quoted 1 line · Roger Pau Monne
(quoted diff) +0
-0
b/xen/drivers/passthrough/iommu.cxen/drivers/passthrough/iommu.c void iommu_share_p2m_table(struct domain* d) · line 335
Quoted 9 lines
index cc12735..7fcbbb1 100644
xen/drivers/passthrough/iommu.c +1
-1@@ -332,7 +332,8 @@ void iommu_share_p2m_table(struct domain* d) {const struct iommu_ops *ops =iommu_get_ops (); -if ( iommu_enabled &&is_hvm_domain (d) ) +ASSERT (hap_enabled (d) );This line is breaking compilation on ARM.
Quoted 4 lines
Quoted 1 line
Shouldn't it be replaced by
iommu_use_hap_pt?No, that's a different thing. But shouldn't ARM have a stub
hap_enabled()evaluating to constant true?
Quoted 7 lines
I'm not sure if we should introduce
hap_enabled. It's not something that we should used in general.What are we trying to catch with this ASSERT? I guess wrong caller?
If so, every
share_p2mcallbacks have a check "ifiommu_use_hap_pt()" which contains a check tohap_enabledon x86.
Ah, right, I mixed this up with iommu_hap_pt_share. Roger - looks like this could indeed be replaced by
if ( iommu_enabled && iommu_use_hap_pt(d) )
ops->share_p2m(d);and the corresponding check in VT-d and AMD Vi code could then also be dropped.
Jan
Hi Jan,
Quoted 8 lines · Jan Beulich
Ah, right, I mixed this up with
iommu_hap_pt_share. Roger - looks like this could indeed be replaced byif ( iommu_enabled && iommu_use_hap_pt(d) ) ops->share_p2m(d);and the corresponding check in VT-d and AMD Vi code could then also be dropped.
Royger seems to be away. As it break ARM support I will send a patch today.
Regards,
Signature · 1 line
Julien Grall