aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hvm/svm
diff options
context:
space:
mode:
authorChristoph Egger <Christoph.Egger@amd.com>2012-10-23 09:13:27 +0200
committerChristoph Egger <Christoph.Egger@amd.com>2012-10-23 09:13:27 +0200
commit54c0bb27e5ce61acabe9af578469d87adab9c2af (patch)
tree910a9d14a533984e265389a8bd47684c8c4b79c5 /xen/arch/x86/hvm/svm
parent4244c50c16746b14c6353999ff543e0ec1b64ee5 (diff)
downloadxen-54c0bb27e5ce61acabe9af578469d87adab9c2af.tar.gz
xen-54c0bb27e5ce61acabe9af578469d87adab9c2af.tar.bz2
xen-54c0bb27e5ce61acabe9af578469d87adab9c2af.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> Committed-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/hvm/svm')
-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 9f69bcc70f..e48db005e6 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));