/*
* 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);
/*
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;
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;
/*
* 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 )
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;
}