From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: [PATCH] nestedsvm: fix memory leak on shutdown/crash Date: Wed, 17 Oct 2012 10:36:01 +0200 Message-ID: <507E6DF1.7080506@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000306010809040908010205" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --------------000306010809040908010205 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit Fix memory leak of l1 vmcb page when destroying a vcpu while l2 guest is running. Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --------------000306010809040908010205 Content-Type: text/plain; charset="us-ascii"; name="xen_nh_shutdown.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_nh_shutdown.diff" Content-Description: xen_nh_shutdown.diff diff -r 6b73078a4403 xen/arch/x86/hvm/svm/nestedsvm.c --- a/xen/arch/x86/hvm/svm/nestedsvm.c Fri Oct 12 14:38:20 2012 +0200 +++ b/xen/arch/x86/hvm/svm/nestedsvm.c Wed Oct 17 09:08:20 2012 +0200 @@ -122,6 +122,15 @@ void nsvm_vcpu_destroy(struct vcpu *v) struct nestedvcpu *nv = &vcpu_nestedhvm(v); struct nestedsvm *svm = &vcpu_nestedsvm(v); + /* + * When destroying the vcpu, it may be running on behalf of l2 guest. + * Therefore we need to switch the VMCB pointer back to the l1 vmcb, + * in order to avoid double free of l2 vmcb and the possible memory leak + * of l1 vmcb page. + */ + if (nv->nv_n1vmcx) + v->arch.hvm_svm.vmcb = nv->nv_n1vmcx; + if (svm->ns_cached_msrpm) { free_xenheap_pages(svm->ns_cached_msrpm, get_order_from_bytes(MSRPM_SIZE)); --------------000306010809040908010205 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------000306010809040908010205--