mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xen/arm: Clean-up in p2m_init() and p2m_final_teardown()
With the change in previous patch, the initial 16 pages in the P2M pool is not necessary anymore. Drop them for code simplification. Also the call to p2m_teardown() from arch_domain_destroy() is not necessary anymore since the movement of the P2M allocation out of arch_domain_create(). Drop the code and the above in-code comment mentioning it. Take the opportunity to fix a typo in the original in-code comment. With above clean-up, the second parameter of p2m_teardown() is also not needed anymore. Drop this parameter and the logic related to this parameter. Signed-off-by: Henry Wang <Henry.Wang@arm.com> Reviewed-by: Michal Orzel <michal.orzel@amd.com>
This commit is contained in:
1 parent
4dbcb06536
commit
9c962e07fb
3 files changed
+9
-31
No files matched your search
@@ -1030,7 +1030,7 @@ int domain_relinquish_resources(struct domain *d)
|
||||
p2m_clear_root_pages(&d->arch.p2m);
|
||||
|
||||
PROGRESS(p2m):
|
||||
ret = p2m_teardown(d, true);
|
||||
ret = p2m_teardown(d);
|
||||
if ( ret )
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -194,18 +194,14 @@ int p2m_init(struct domain *d);
|
||||
|
||||
/*
|
||||
* The P2M resources are freed in two parts:
|
||||
* - p2m_teardown() will be called preemptively when relinquish the
|
||||
* resources, in which case it will free large resources (e.g. intermediate
|
||||
* page-tables) that requires preemption.
|
||||
* - p2m_teardown() will be called when relinquish the resources. It
|
||||
* will free large resources (e.g. intermediate page-tables) that
|
||||
* requires preemption.
|
||||
* - p2m_final_teardown() will be called when domain struct is been
|
||||
* freed. This *cannot* be preempted and therefore one small
|
||||
* freed. This *cannot* be preempted and therefore only small
|
||||
* resources should be freed here.
|
||||
* Note that p2m_final_teardown() will also call p2m_teardown(), to properly
|
||||
* free the P2M when failures happen in the domain creation with P2M pages
|
||||
* already in use. In this case p2m_teardown() is called non-preemptively and
|
||||
* p2m_teardown() will always return 0.
|
||||
*/
|
||||
int p2m_teardown(struct domain *d, bool allow_preemption);
|
||||
int p2m_teardown(struct domain *d);
|
||||
void p2m_final_teardown(struct domain *d);
|
||||
|
||||
/*
|
||||
|
||||
+3
-21
@@ -1713,7 +1713,7 @@ static void p2m_free_vmid(struct domain *d)
|
||||
spin_unlock(&vmid_alloc_lock);
|
||||
}
|
||||
|
||||
int p2m_teardown(struct domain *d, bool allow_preemption)
|
||||
int p2m_teardown(struct domain *d)
|
||||
{
|
||||
struct p2m_domain *p2m = p2m_get_hostp2m(d);
|
||||
unsigned long count = 0;
|
||||
@@ -1727,7 +1727,7 @@ int p2m_teardown(struct domain *d, bool allow_preemption)
|
||||
p2m_free_page(p2m->domain, pg);
|
||||
count++;
|
||||
/* Arbitrarily preempt every 512 iterations */
|
||||
if ( allow_preemption && !(count % 512) && hypercall_preempt_check() )
|
||||
if ( !(count % 512) && hypercall_preempt_check() )
|
||||
{
|
||||
rc = -ERESTART;
|
||||
break;
|
||||
@@ -1750,13 +1750,9 @@ void p2m_final_teardown(struct domain *d)
|
||||
/*
|
||||
* No need to call relinquish_p2m_mapping() here because
|
||||
* p2m_final_teardown() is called either after domain_relinquish_resources()
|
||||
* where relinquish_p2m_mapping() has been called, or from failure path of
|
||||
* domain_create()/arch_domain_create() where mappings that require
|
||||
* p2m_put_l3_page() should never be created. For the latter case, also see
|
||||
* comment on top of the p2m_set_entry() for more info.
|
||||
* where relinquish_p2m_mapping() has been called.
|
||||
*/
|
||||
|
||||
BUG_ON(p2m_teardown(d, false));
|
||||
ASSERT(page_list_empty(&p2m->pages));
|
||||
|
||||
while ( p2m_teardown_allocation(d) == -ERESTART )
|
||||
@@ -1827,20 +1823,6 @@ int p2m_init(struct domain *d)
|
||||
if ( rc )
|
||||
return rc;
|
||||
|
||||
/*
|
||||
* Hardware using GICv2 needs to create a P2M mapping of 8KB GICv2 area
|
||||
* when the domain is created. Considering the worst case for page
|
||||
* tables and keep a buffer, populate 16 pages to the P2M pages pool here.
|
||||
* For GICv3, the above-mentioned P2M mapping is not necessary, but since
|
||||
* the allocated 16 pages here would not be lost, hence populate these
|
||||
* pages unconditionally.
|
||||
*/
|
||||
spin_lock(&d->arch.paging.lock);
|
||||
rc = p2m_set_allocation(d, 16, NULL);
|
||||
spin_unlock(&d->arch.paging.lock);
|
||||
if ( rc )
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||