* [PATCH] nestedsvm: fix memory leak on shutdown/crash
@ 2012-10-17 8:36 Christoph Egger
2012-10-22 15:24 ` Tim Deegan
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Egger @ 2012-10-17 8:36 UTC (permalink / raw)
To: xen-devel@lists.xen.org
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
Fix memory leak of l1 vmcb page when destroying a vcpu while
l2 guest is running.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
--
---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
[-- Attachment #2: xen_nh_shutdown.diff --]
[-- Type: text/plain, Size: 842 bytes --]
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));
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nestedsvm: fix memory leak on shutdown/crash
2012-10-17 8:36 [PATCH] nestedsvm: fix memory leak on shutdown/crash Christoph Egger
@ 2012-10-22 15:24 ` Tim Deegan
0 siblings, 0 replies; 2+ messages in thread
From: Tim Deegan @ 2012-10-22 15:24 UTC (permalink / raw)
To: Christoph Egger; +Cc: xen-devel@lists.xen.org
At 10:36 +0200 on 17 Oct (1350470161), Christoph Egger wrote:
>
> Fix memory leak of l1 vmcb page when destroying a vcpu while
> l2 guest is running.
>
> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <tim@xen.org>
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));
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-22 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 8:36 [PATCH] nestedsvm: fix memory leak on shutdown/crash Christoph Egger
2012-10-22 15:24 ` Tim Deegan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).