From patchwork Fri Apr 29 14:49:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8983581 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5C44D9F372 for ; Fri, 29 Apr 2016 14:51:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B3F120114 for ; Fri, 29 Apr 2016 14:51:47 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB502201CD for ; Fri, 29 Apr 2016 14:51:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aw9jt-0000Kr-PS; Fri, 29 Apr 2016 14:49:53 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aw9jr-0000Kd-Sv for xen-devel@lists.xenproject.org; Fri, 29 Apr 2016 14:49:51 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id EC/98-18833-F8473275; Fri, 29 Apr 2016 14:49:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOIsWRWlGSWpSXmKPExsXS6fjDS7evRDn cYNcbKYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePOzAlMBUtVK970LWRvYPwt28XIySEkkCfR 92sGG4jNK2An8ff9djBbQsBQYt/8VWA2i4CqxJ9Dt9hBbDYBdYm2Z9tZuxg5OEQEDCTOHU3qY uTiYBZoZJS40/KJGaRGWEBH4v6TN+wgNUJAM5e/SAEJcwrYS8y+3M4MEuYVEJT4u0MYJMwMVH H51yzGCYw8sxAys5BkIGwtiYe/brFA2NoSyxa+ZgYpZxaQllj+jwPCNJPo/iSMqgLEdpQ4eWM vywJGjlWM6sWpRWWpRbrGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgYHKAAQ7 GDv+OR1ilORgUhLlvaqrHC7El5SfUpmRWJwRX1Sak1p8iFGDg0Ng267VFxilWPLy81KVJHjji 4HqBItS01Mr0jJzgLEEUyrBwaMkwjsPJM1bXJCYW5yZDpE6xagoJc7bA5IQAElklObBtcHi9x KjrJQwLyPQUUI8BalFuZklqPKvGMU5GJWEefeBTOHJzCuBm/4KaDET0GKBTYogi0sSEVJSDYy zfv1Zqhmf1LTr+7qVly8I7G/8JvY7PJSZ0zv2qfBNld+cDzPDm5j3R8rxrtPaM+9+dnOXXKJu nmMh2/IrskkZK/ynFp9Kv5yoaunInTJf6sLnALkTG9z4FY582myzcJF9wCXmfXZv7mg2fJzBc mfLzk1auZIX9ggnTv9gJ5s709cx/Hy/fqcSS3FGoqEWc1FxIgCqXCqS2gIAAA== X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1461941388!12071216!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47540 invoked from network); 29 Apr 2016 14:49:50 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Apr 2016 14:49:50 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 29 Apr 2016 08:49:45 -0600 Message-Id: <572390AF02000078000E7450@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Fri, 29 Apr 2016 08:49:51 -0600 From: "Jan Beulich" To: "xen-devel" References: <57238EAA02000078000E741D@prv-mh.provo.novell.com> In-Reply-To: <57238EAA02000078000E741D@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu Subject: [Xen-devel] [PATCH 2/2] x86: fix domain cleanup X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Free d->arch.cpuids on both the creation error path and during destruction. Don't bypass iommu_domain_destroy(). Move psr_domain_init() up so that hvm_domain_initialise() again is the last thing which can fail, and hence doesn't require undoing later on. Move psr_domain_free() up on the creation error path, so that cleanup once again gets done in reverse order of setup. Signed-off-by: Jan Beulich x86: fix domain cleanup Free d->arch.cpuids on both the creation error path and during destruction. Don't bypass iommu_domain_destroy(). Move psr_domain_init() up so that hvm_domain_initialise() again is the last thing which can fail, and hence doesn't require undoing later on. Move psr_domain_free() up on the creation error path, so that cleanup once again gets done in reverse order of setup. Signed-off-by: Jan Beulich --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -642,21 +642,18 @@ int arch_domain_create(struct domain *d, } spin_lock_init(&d->arch.e820_lock); + if ( (rc = psr_domain_init(d)) != 0 ) + goto fail; + if ( has_hvm_container_domain(d) ) { if ( (rc = hvm_domain_initialise(d)) != 0 ) - { - iommu_domain_destroy(d); goto fail; - } } else /* 64-bit PV guest by default. */ d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0; - if ( (rc = psr_domain_init(d)) != 0 ) - goto fail; - /* initialize default tsc behavior in case tools don't */ tsc_set_info(d, TSC_MODE_DEFAULT, 0UL, 0, 0); spin_lock_init(&d->arch.vtsc_lock); @@ -674,8 +671,11 @@ int arch_domain_create(struct domain *d, fail: d->is_dying = DOMDYING_dead; + psr_domain_free(d); + iommu_domain_destroy(d); cleanup_domain_irq_mapping(d); free_xenheap_page(d->shared_info); + xfree(d->arch.cpuids); if ( paging_initialised ) paging_final_teardown(d); free_perdomain_mappings(d); @@ -684,7 +684,6 @@ int arch_domain_create(struct domain *d, xfree(d->arch.pv_domain.cpuidmasks); free_xenheap_page(d->arch.pv_domain.gdt_ldt_l1tab); } - psr_domain_free(d); return rc; } @@ -694,6 +693,7 @@ void arch_domain_destroy(struct domain * hvm_domain_destroy(d); xfree(d->arch.e820); + xfree(d->arch.cpuids); free_domain_pirqs(d); if ( !is_idle_domain(d) ) Reviewed-by: Andrew Cooper --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -642,21 +642,18 @@ int arch_domain_create(struct domain *d, } spin_lock_init(&d->arch.e820_lock); + if ( (rc = psr_domain_init(d)) != 0 ) + goto fail; + if ( has_hvm_container_domain(d) ) { if ( (rc = hvm_domain_initialise(d)) != 0 ) - { - iommu_domain_destroy(d); goto fail; - } } else /* 64-bit PV guest by default. */ d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0; - if ( (rc = psr_domain_init(d)) != 0 ) - goto fail; - /* initialize default tsc behavior in case tools don't */ tsc_set_info(d, TSC_MODE_DEFAULT, 0UL, 0, 0); spin_lock_init(&d->arch.vtsc_lock); @@ -674,8 +671,11 @@ int arch_domain_create(struct domain *d, fail: d->is_dying = DOMDYING_dead; + psr_domain_free(d); + iommu_domain_destroy(d); cleanup_domain_irq_mapping(d); free_xenheap_page(d->shared_info); + xfree(d->arch.cpuids); if ( paging_initialised ) paging_final_teardown(d); free_perdomain_mappings(d); @@ -684,7 +684,6 @@ int arch_domain_create(struct domain *d, xfree(d->arch.pv_domain.cpuidmasks); free_xenheap_page(d->arch.pv_domain.gdt_ldt_l1tab); } - psr_domain_free(d); return rc; } @@ -694,6 +693,7 @@ void arch_domain_destroy(struct domain * hvm_domain_destroy(d); xfree(d->arch.e820); + xfree(d->arch.cpuids); free_domain_pirqs(d); if ( !is_idle_domain(d) )