Skip to contentSkip to conversation

x86/HVM: Fix teardown ordering in hvm_vcpu_destroy()

PATCH In review Suravee Suthikulpanit 4 participants 6 messages Jan 10, 2017 – Jan 11, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 x86/HVM: Fix teardown ordering in hvm_vcpu_destroy()

The order of destroy function calls in hvm_vcpu_destroy() should be the reverse of init calls in hvm_vcpu_initialise().

---
Note: I separate this out from the previously sent AMD SVM AVIC patch series since this is a standalone fix.

 xen/arch/x86/hvm/hvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/hvm.c +3 -3
index 25dc759..d465596 100644
@@ -1610,13 +1610,13 @@ void hvm_vcpu_destroy(struct vcpu *v)
 
     free_compat_arg_xlat(v);
 
-    tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
-    hvm_vcpu_cacheattr_destroy(v);
+    hvm_funcs.vcpu_destroy(v);
 
     if ( is_hvm_vcpu(v) )
         vlapic_destroy(v);
 
-    hvm_funcs.vcpu_destroy(v);
+    tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
+    hvm_vcpu_cacheattr_destroy(v);
 }
 
 void hvm_vcpu_down(struct vcpu *v)
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v3 1/1
#1 lore raw
Quoted 8 lines · Suravee Suthikulpanit

The order of destroy function calls in hvm_vcpu_destroy() should be the reverse of init calls in hvm_vcpu_initialise().

Quoted 18 lines

---
Note: I separate this out from the previously sent AMD SVM AVIC patch series since this is a standalone fix.

 xen/arch/x86/hvm/hvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/hvm.c +1 -2
index 25dc759..d465596 100644
@@ -1610,13 +1610,13 @@ void hvm_vcpu_destroy(struct vcpu *v)
 
     free_compat_arg_xlat(v);
 
-    tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
-    hvm_vcpu_cacheattr_destroy(v);
+    hvm_funcs.vcpu_destroy(v);

xen/arch/x86/hvm/hvm.c void hvm_vcpu_destroy(struct vcpu *v) · line 1622

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +2 -1
 
     if ( is_hvm_vcpu(v) )
         vlapic_destroy(v);
 
-    hvm_funcs.vcpu_destroy(v);
+    tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
+    hvm_vcpu_cacheattr_destroy(v);
 }
 
 void hvm_vcpu_down(struct vcpu *v)

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

#2 lore raw
Quoted 10 lines · Andrew Cooper
Quoted 8 lines · Suravee Suthikulpanit

The order of destroy function calls in hvm_vcpu_destroy() should be the reverse of init calls in hvm_vcpu_initialise().

Wait no.

The order in vcpu_initialise is

hvm_vcpu_cacheattr_init()
vlapic_init()
hvm_funcs.vcpu_initialise()
softirq_tasklet_init()
setup_compat_arg_xlat()

Therefore, moving the tasklet_kill() is wrong.

The overall delta should be:

andrewcoop@andrewcoop:/local/xen.git/xen$ git diff HEAD^
xen/arch/x86/hvm/hvm.c +2 -2
index 4c0f561..9f74334 100644
@@ -1626,12 +1626,12 @@ void hvm_vcpu_destroy(struct vcpu *v)
     free_compat_arg_xlat(v);
 
     tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
-    hvm_vcpu_cacheattr_destroy(v);
+    hvm_funcs.vcpu_destroy(v);
 
     if ( is_hvm_vcpu(v) )
         vlapic_destroy(v);
 
-    hvm_funcs.vcpu_destroy(v);
+    hvm_vcpu_cacheattr_destroy(v);
 }
 

IIRC.

If you agree, I will fold this correction in while committing.

~Andrew

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

Reviewed-by
#3 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 10.01.17 at 15:26, <[email protected]> wrote:
Quoted 4 lines · Andrew Cooper
Quoted 3 lines · Suravee Suthikulpanit

The order of destroy function calls in hvm_vcpu_destroy() should be the reverse of init calls in hvm_vcpu_initialise().

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

Wait no.

Which clearly suggests that the earlier R-b-s should have been dropped too.

Quoted 30 lines

The order in vcpu_initialise is

hvm_vcpu_cacheattr_init()
vlapic_init()
hvm_funcs.vcpu_initialise()
softirq_tasklet_init()
setup_compat_arg_xlat()

Therefore, moving the tasklet_kill() is wrong.

The overall delta should be:

xen/arch/x86/hvm/hvm.c +2 -2
@@ -1626,12 +1626,12 @@ void hvm_vcpu_destroy(struct vcpu *v)
     free_compat_arg_xlat(v);
 
     tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
-    hvm_vcpu_cacheattr_destroy(v);
+    hvm_funcs.vcpu_destroy(v);
 
     if ( is_hvm_vcpu(v) )
         vlapic_destroy(v);
 
-    hvm_funcs.vcpu_destroy(v);
+    hvm_vcpu_cacheattr_destroy(v);
 }
 

IIRC.

Quoted 1 line

If you agree, I will fold this correction in while committing.

This variant is

Jan

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

#4 lore raw
Quoted 49 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, January 10, 2017 10:42 PM

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 10.01.17 at 15:26, <[email protected]> wrote:
Quoted 4 lines · Andrew Cooper
Quoted 3 lines · Suravee Suthikulpanit

The order of destroy function calls in hvm_vcpu_destroy() should be the reverse of init calls in hvm_vcpu_initialise().

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

Wait no.

Which clearly suggests that the earlier R-b-s should have been dropped too.

Quoted 28 lines

The order in vcpu_initialise is

hvm_vcpu_cacheattr_init()
vlapic_init()
hvm_funcs.vcpu_initialise()
softirq_tasklet_init()
setup_compat_arg_xlat()

Therefore, moving the tasklet_kill() is wrong.

The overall delta should be:

xen/arch/x86/hvm/hvm.c +2 -2
@@ -1626,12 +1626,12 @@ void hvm_vcpu_destroy(struct vcpu *v)
     free_compat_arg_xlat(v);
 
     tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
-    hvm_vcpu_cacheattr_destroy(v);
+    hvm_funcs.vcpu_destroy(v);
 
     if ( is_hvm_vcpu(v) )
         vlapic_destroy(v);
 
-    hvm_funcs.vcpu_destroy(v);
+    hvm_vcpu_cacheattr_destroy(v);
 }
 
Quoted 8 lines
Quoted 3 lines

IIRC.

If you agree, I will fold this correction in while committing.

This variant is

Jan

here is my updated Reviewed-by: Kevin Tian <[email protected]> with Andrew's change.

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

#5 lore raw
In reply to Andrew Cooper
Quoted 47 lines · Andrew Cooper
Quoted 10 lines · Andrew Cooper
Quoted 8 lines · Suravee Suthikulpanit

The order of destroy function calls in hvm_vcpu_destroy() should be the reverse of init calls in hvm_vcpu_initialise().

Wait no.

The order in vcpu_initialise is

hvm_vcpu_cacheattr_init()
vlapic_init()
hvm_funcs.vcpu_initialise()
softirq_tasklet_init()
setup_compat_arg_xlat()

Therefore, moving the tasklet_kill() is wrong.

The overall delta should be:

andrewcoop@andrewcoop:/local/xen.git/xen$ git diff HEAD^
xen/arch/x86/hvm/hvm.c +2 -2
index 4c0f561..9f74334 100644
@@ -1626,12 +1626,12 @@ void hvm_vcpu_destroy(struct vcpu *v)
     free_compat_arg_xlat(v);
 
     tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
-    hvm_vcpu_cacheattr_destroy(v);
+    hvm_funcs.vcpu_destroy(v);
 
     if ( is_hvm_vcpu(v) )
         vlapic_destroy(v);
 
-    hvm_funcs.vcpu_destroy(v);
+    hvm_vcpu_cacheattr_destroy(v);
 }
 

IIRC.

Quoted 4 lines

If you agree, I will fold this correction in while committing.

~Andrew

Ah, right... sorry I missed the tasklet stuff.

Thanks,
Suravee

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