aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2013-03-07 17:57:02 +0100
committerJan Beulich <jbeulich@suse.com>2013-03-07 17:57:02 +0100
commit4b0ac057e3bcae70a109da0610e1dd2e270aec8a (patch)
tree335fea019a40e3fe75f1a8a0166dc39029ff1419
parent3c4cd2c6a0e1795c837dd0cfb15db08a5d6694eb (diff)
downloadxen-4b0ac057e3bcae70a109da0610e1dd2e270aec8a.tar.gz
xen-4b0ac057e3bcae70a109da0610e1dd2e270aec8a.tar.bz2
xen-4b0ac057e3bcae70a109da0610e1dd2e270aec8a.zip
x86/nhvm: properly clean up after failure to set up all vCPU-s
Otherwise we may leak memory when setting up nHVM fails half way. This implies that the individual destroy functions will have to remain capable (in the VMX case they first need to be made so, following 26486:7648ef657fe7 and 26489:83a3fa9c8434) of being called for a vCPU that the corresponding init function was never run on. Once at it, also remove a redundant check from the corresponding parameter validation code. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Tim Deegan <tim@xen.org> Tested-by: Olaf Hering <olaf@aepfle.de> master changeset: 17281aea1a9a10f1ee165c6e6a2921a67b7b1df2 master date: 2013-02-22 11:21:38 +0100
-rw-r--r--xen/arch/x86/hvm/hvm.c8
-rw-r--r--xen/arch/x86/hvm/nestedhvm.c2
2 files changed, 6 insertions, 4 deletions
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 2d4acb1ef0..3d471a5935 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3873,18 +3873,20 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
#else
if ( a.value > 1 )
rc = -EINVAL;
- if ( !is_hvm_domain(d) )
- rc = -EINVAL;
/* Remove the check below once we have
* shadow-on-shadow.
*/
if ( cpu_has_svm && !paging_mode_hap(d) && a.value )
rc = -EINVAL;
/* Set up NHVM state for any vcpus that are already up */
- if ( !d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM] )
+ if ( a.value &&
+ !d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM] )
for_each_vcpu(d, v)
if ( rc == 0 )
rc = nestedhvm_vcpu_initialise(v);
+ if ( !a.value || rc )
+ for_each_vcpu(d, v)
+ nestedhvm_vcpu_destroy(v);
#endif
break;
case HVM_PARAM_BUFIOREQ_EVTCHN:
diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c
index ba0bb8b4e1..5153a4aa48 100644
--- a/xen/arch/x86/hvm/nestedhvm.c
+++ b/xen/arch/x86/hvm/nestedhvm.c
@@ -88,7 +88,7 @@ nestedhvm_vcpu_initialise(struct vcpu *v)
void
nestedhvm_vcpu_destroy(struct vcpu *v)
{
- if ( nestedhvm_enabled(v->domain) && hvm_funcs.nhvm_vcpu_destroy )
+ if ( hvm_funcs.nhvm_vcpu_destroy )
hvm_funcs.nhvm_vcpu_destroy(v);
}