Skip to contentSkip to conversation

x86/nestedhvm: properly clean up after failure to set up all vCPU-s

PATCH Superseded Jan Beulich 2 participants 5 messages Jan 23, 2013

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/nestedhvm: properly clean up after failure to set up all vCPU-s

This implies that the individual destroy functions will have to remain capable of being called for a vCPU that the corresponding init function was never run on.

Once at it, also clean up some inefficiencies in the corresponding parameter validation code.

xen/arch/x86/hvm/hvm.c +8 -3
@@ -3900,20 +3900,25 @@ long do_hvm_op(unsigned long op, XEN_GUE
                     rc = -EPERM;
                     break;
                 }
+                if ( !a.value )
+                    break;
                 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 )
+                if ( cpu_has_svm && !paging_mode_hap(d) )
                     rc = -EINVAL;
                 /* Set up NHVM state for any vcpus that are already up */
                 if ( !d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM] )
+                {
                     for_each_vcpu(d, v)
                         if ( rc == 0 )
                             rc = nestedhvm_vcpu_initialise(v);
+                    if ( rc )
+                        for_each_vcpu(d, v)
+                            nestedhvm_vcpu_destroy(v);
+                }
                 break;
             case HVM_PARAM_BUFIOREQ_EVTCHN:
                 rc = -EINVAL;
xen/arch/x86/hvm/nestedhvm.c +1 -1
@@ -87,7 +87,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);
 }
 

x86/nestedhvm: properly clean up after failure to set up all vCPU-s

This implies that the individual destroy functions will have to remain capable of being called for a vCPU that the corresponding init function was never run on.

Once at it, also clean up some inefficiencies in the corresponding parameter validation code.

xen/arch/x86/hvm/hvm.c +8 -3
@@ -3900,20 +3900,25 @@ long do_hvm_op(unsigned long op, XEN_GUE
                     rc = -EPERM;
                     break;
                 }
+                if ( !a.value )
+                    break;
                 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 )
+                if ( cpu_has_svm && !paging_mode_hap(d) )
                     rc = -EINVAL;
                 /* Set up NHVM state for any vcpus that are already up */
                 if ( !d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM] )
+                {
                     for_each_vcpu(d, v)
                         if ( rc == 0 )
                             rc = nestedhvm_vcpu_initialise(v);
+                    if ( rc )
+                        for_each_vcpu(d, v)
+                            nestedhvm_vcpu_destroy(v);
+                }
                 break;
             case HVM_PARAM_BUFIOREQ_EVTCHN:
                 rc = -EINVAL;
xen/arch/x86/hvm/nestedhvm.c +1 -1
@@ -87,7 +87,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);
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jan Beulich

This implies that the individual destroy functions will have to remain capable of being called for a vCPU that the corresponding init function was never run on.

Once at it, also clean up some inefficiencies in the corresponding parameter validation code.

But doubtless should have a nestedhvm maintainer ack too.

#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 4 lines · Jan Beulich

This implies that the individual destroy functions will have to remain capable of being called for a vCPU that the corresponding init function was never run on.

Quoted 8 lines
Quoted 4 lines

Once at it, also clean up some inefficiencies in the corresponding parameter validation code.

But doubtless should have a nestedhvm maintainer ack too.

Whoever that is. This was actually the first patch for XSA-35, so would have gone in without people seeing this who didn't already (and who one way or another approved of it).

Jan

#3 lore raw
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 8 lines · Jan Beulich

This implies that the individual destroy functions will have to remain capable of being called for a vCPU that the corresponding init function was never run on.

Once at it, also clean up some inefficiencies in the corresponding parameter validation code.

Quoted 7 lines
Quoted 3 lines

But doubtless should have a nestedhvm maintainer ack too.

Whoever that is. This was actually the first patch for XSA-35, so would have gone in without people seeing this who didn't already (and who one way or another approved of it).

Maybe an Ack from a nvmx maintainer at least?

-- Keir

Quoted 2 lines

Jan

#4 lore raw
Quoted 17 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 8 lines · Jan Beulich

This implies that the individual destroy functions will have to remain capable of being called for a vCPU that the corresponding init function was never run on.

Once at it, also clean up some inefficiencies in the corresponding parameter validation code.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

But doubtless should have a nestedhvm maintainer ack too.

Whoever that is. This was actually the first patch for XSA-35, so would have gone in without people seeing this who didn't already (and who one way or another approved of it).

Maybe an Ack from a nvmx maintainer at least?

Jun, Eddie?

Thanks, Jan