|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/P2M: p2m_{alloc,free}_ptp() and p2m_alloc_table() are HVM-only
commit 033ff90aa9c17306ae0026fd10f6532b2ea3fca2
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Apr 8 14:40:46 2022 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Apr 8 14:40:46 2022 +0200
x86/P2M: p2m_{alloc,free}_ptp() and p2m_alloc_table() are HVM-only
This also includes the two p2m related fields.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
xen/arch/x86/include/asm/p2m.h | 12 ++++++------
xen/arch/x86/mm/p2m.c | 13 ++++++++++++-
xen/arch/x86/mm/shadow/common.c | 2 ++
xen/drivers/passthrough/vtd/iommu.c | 2 ++
4 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 2d0783693e..30236daba3 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -208,9 +208,6 @@ struct p2m_domain {
/* Lock that protects updates to the p2m */
mm_rwlock_t lock;
- /* Shadow translated domain: p2m mapping */
- pagetable_t phys_table;
-
/*
* Same as a domain's dirty_cpumask but limited to
* this p2m and those physical cpus whose vcpu's are in
@@ -229,9 +226,6 @@ struct p2m_domain {
*/
p2m_access_t default_access;
- /* Pages used to construct the p2m */
- struct page_list_head pages;
-
/* Host p2m: Log-dirty ranges registered for the domain. */
struct rangeset *logdirty_ranges;
@@ -239,6 +233,12 @@ struct p2m_domain {
bool global_logdirty;
#ifdef CONFIG_HVM
+ /* Translated domain: p2m mapping */
+ pagetable_t phys_table;
+
+ /* Pages used to construct the p2m */
+ struct page_list_head pages;
+
/* Alternate p2m: count of vcpu's currently using this p2m. */
atomic_t active_vcpus;
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 4f739e27e4..48bff44a6a 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -93,7 +93,9 @@ static int p2m_initialise(struct domain *d, struct p2m_domain
*p2m)
int ret = 0;
mm_rwlock_init(&p2m->lock);
+#ifdef CONFIG_HVM
INIT_PAGE_LIST_HEAD(&p2m->pages);
+#endif
p2m->domain = d;
p2m->default_access = p2m_access_rwx;
@@ -627,6 +629,7 @@ struct page_info *p2m_get_page_from_gfn(
}
#ifdef CONFIG_HVM
+
/* Returns: 0 for success, -errno for failure */
int p2m_set_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn,
unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma)
@@ -666,7 +669,6 @@ int p2m_set_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t
mfn,
return rc;
}
-#endif
mfn_t p2m_alloc_ptp(struct p2m_domain *p2m, unsigned int level)
{
@@ -745,6 +747,8 @@ int p2m_alloc_table(struct p2m_domain *p2m)
return 0;
}
+#endif /* CONFIG_HVM */
+
/*
* hvm fixme: when adding support for pvh non-hardware domains, this path must
* cleanup any foreign p2m types (release refcnts on them).
@@ -753,7 +757,9 @@ void p2m_teardown(struct p2m_domain *p2m)
/* Return all the p2m pages to Xen.
* We know we don't have any extra mappings to these pages */
{
+#ifdef CONFIG_HVM
struct page_info *pg;
+#endif
struct domain *d;
if (p2m == NULL)
@@ -762,11 +768,16 @@ void p2m_teardown(struct p2m_domain *p2m)
d = p2m->domain;
p2m_lock(p2m);
+
ASSERT(atomic_read(&d->shr_pages) == 0);
+
+#ifdef CONFIG_HVM
p2m->phys_table = pagetable_null();
while ( (pg = page_list_remove_head(&p2m->pages)) )
d->arch.paging.free_page(d, pg);
+#endif
+
p2m_unlock(p2m);
}
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index 8f11190173..06a0f22906 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -2701,8 +2701,10 @@ int shadow_enable(struct domain *d, u32 mode)
out_locked:
paging_unlock(d);
out_unlocked:
+#ifdef CONFIG_HVM
if ( rv != 0 && !pagetable_is_null(p2m_get_pagetable(p2m)) )
p2m_teardown(p2m);
+#endif
if ( rv != 0 && pg != NULL )
{
pg->count_info &= ~PGC_count_mask;
diff --git a/xen/drivers/passthrough/vtd/iommu.c
b/xen/drivers/passthrough/vtd/iommu.c
index 069427abb2..42b76af73f 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -374,6 +374,7 @@ static paddr_t domain_pgd_maddr(struct domain *d, paddr_t
pgd_maddr,
if ( pgd_maddr )
/* nothing */;
+#ifdef CONFIG_HVM
else if ( iommu_use_hap_pt(d) )
{
pagetable_t pgt = p2m_get_pagetable(p2m_get_hostp2m(d));
@@ -381,6 +382,7 @@ static paddr_t domain_pgd_maddr(struct domain *d, paddr_t
pgd_maddr,
pgd_maddr = pagetable_get_paddr(pgt);
}
else
+#endif
{
if ( !hd->arch.vtd.pgd_maddr )
{
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |