[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH for-next v3 07/12] x86/domain: factor out pv_domain_destroy
Now this function also frees the perdomain mapping. It is safe to do so because destroy_perdomain_mapping is idempotent. Move free_perdomain_mappings after pv_domain_destroy. It is safe to do so because both destroy_perdomain_mapping and free_perdomain_mappings are idempotent. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- v3: 1. add new lines 2. move free_perdomain_mappings v2: 1. reset fields 2. destroy perdomain mapping Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/domain.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 80775a0362..a904e4ecb6 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -538,6 +538,18 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) return true; } +static void pv_domain_destroy(struct domain *d) +{ + destroy_perdomain_mapping(d, GDT_LDT_VIRT_START, + GDT_LDT_MBYTES << (20 - PAGE_SHIFT)); + + xfree(d->arch.pv_domain.cpuidmasks); + d->arch.pv_domain.cpuidmasks = NULL; + + free_xenheap_page(d->arch.pv_domain.gdt_ldt_l1tab); + d->arch.pv_domain.gdt_ldt_l1tab = NULL; +} + int arch_domain_create(struct domain *d, unsigned int domcr_flags, struct xen_arch_domainconfig *config) { @@ -712,12 +724,10 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, xfree(d->arch.cpuid); if ( paging_initialised ) paging_final_teardown(d); - free_perdomain_mappings(d); if ( is_pv_domain(d) ) - { - xfree(d->arch.pv_domain.cpuidmasks); - free_xenheap_page(d->arch.pv_domain.gdt_ldt_l1tab); - } + pv_domain_destroy(d); + free_perdomain_mappings(d); + return rc; } @@ -735,12 +745,9 @@ void arch_domain_destroy(struct domain *d) paging_final_teardown(d); - free_perdomain_mappings(d); if ( is_pv_domain(d) ) - { - free_xenheap_page(d->arch.pv_domain.gdt_ldt_l1tab); - xfree(d->arch.pv_domain.cpuidmasks); - } + pv_domain_destroy(d); + free_perdomain_mappings(d); free_xenheap_page(d->shared_info); cleanup_domain_irq_mapping(d); -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |