aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Egger <Christoph.Egger@amd.com>2012-10-25 15:32:06 +0200
committerChristoph Egger <Christoph.Egger@amd.com>2012-10-25 15:32:06 +0200
commit2614ed22f2b83711a2dda6e2d68a720c5ff7e19b (patch)
tree552de18a3cccf1353f68af58a618de3e4465a220
parentb00d54d3d54adfb9fab309301e0019e703feb0a2 (diff)
downloadxen-2614ed22f2b83711a2dda6e2d68a720c5ff7e19b.tar.gz
xen-2614ed22f2b83711a2dda6e2d68a720c5ff7e19b.tar.bz2
xen-2614ed22f2b83711a2dda6e2d68a720c5ff7e19b.zip
nestedsvm: fix memory leak on shutdown/crash
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> xen-unstable changeset: 26095:a7503ce27d46 xen-unstable date: Tue Oct 23 07:13:27 UTC 2012 Committed-by: Jan Beulich <jbeulich@suse.com>
-rw-r--r--xen/arch/x86/hvm/svm/nestedsvm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index a9b03c44fd..16f73e13cc 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -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));