Skip to contentSkip to conversation

x86/hvm.c: fix regression in guest destruction

PATCH In review Ravi Sahita 5 participants 9 messages Jul 29, 2015 – Jul 30, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hvm.c: fix regression in guest destruction

As reported by Wei Lu on July 27 2015

---
 xen/arch/x86/hvm/hvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +3 -1
index ec1d797..6a56216 100644
@@ -2463,7 +2463,9 @@ void hvm_vcpu_destroy(struct vcpu *v)
 {
     hvm_all_ioreq_servers_remove_vcpu(v->domain, v);
 
-    altp2m_vcpu_destroy(v);
+    if ( hvm_altp2m_supported() )
+        altp2m_vcpu_destroy(v);
+
     nestedhvm_vcpu_destroy(v);
 
     free_compat_arg_xlat(v);
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Ravi Sahita

As reported by Wei Lu on July 27 2015

Quoted 1 line
Quoted 19 lines
---
 xen/arch/x86/hvm/hvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +3 -1
index ec1d797..6a56216 100644
@@ -2463,7 +2463,9 @@ void hvm_vcpu_destroy(struct vcpu *v)
 {
     hvm_all_ioreq_servers_remove_vcpu(v->domain, v);
 
-    altp2m_vcpu_destroy(v);
+    if ( hvm_altp2m_supported() )
+        altp2m_vcpu_destroy(v);
+
     nestedhvm_vcpu_destroy(v);
 
     free_compat_arg_xlat(v);
Tested-by
#2 lore raw
Quoted 9 lines · Andrew Cooper
Quoted 1 line · Ravi Sahita

As reported by Wei Lu on July 27 2015

Quoted 1 line
Quoted 19 lines
Quoted 19 lines
---
 xen/arch/x86/hvm/hvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +3 -1
index ec1d797..6a56216 100644
@@ -2463,7 +2463,9 @@ void hvm_vcpu_destroy(struct vcpu *v)
 {
     hvm_all_ioreq_servers_remove_vcpu(v->domain, v);
 
-    altp2m_vcpu_destroy(v);
+    if ( hvm_altp2m_supported() )
+        altp2m_vcpu_destroy(v);
+
     nestedhvm_vcpu_destroy(v);
 
     free_compat_arg_xlat(v);
Reviewed-by Andrew Cooper Tested-by Wei Liu
#3 lore raw
In reply to Andrew Cooper
Quoted 4 lines · Andrew Cooper
Quoted 1 line · Ravi Sahita

As reported by Wei Lu on July 27 2015

Which leaves an effectively empty commit message:

x86/hvm.c: fix regression in guest destruction

If I were maintainer of this code I'd be very grumpy about the lack of a commit log (What regression? What is the fix? Why is it correct?) for this patch. I asked on IRC and Andy suggested instead:

x86/hvm.c: Don't tear down altp2m state if it was never set up

which I have applied with. I still don't think the commit message is very satisfactory, but I'm not maintainer of any of this code so meh.

Ian.

#4 lore raw
Quoted 2 lines · Ian Campbell

which I have applied with. I still don't think the commit message is very satisfactory, but I'm not maintainer of any of this code so meh.

For the benefit of the archives perhaps someone could explain why gating a per-vcpu teardown on a host level feature setting is correct?

In particular what ensures that altp2m_vcpu_initialise has been called, given that this is only called from HVMOP_altp2m_set_domain_state. What happens if that HVMOP is never touched?

Do things work both for altp2m disabled on the Xen command line and disabled/enabled in the guest config? If so how?

Also how come HVMOP_altp2m_set_domain_state does not have a hvm_altp2m_supported check?

Ian.

#5 lore raw
Quoted 12 lines · Ian Campbell
Quoted 2 lines · Ian Campbell

which I have applied with. I still don't think the commit message is very satisfactory, but I'm not maintainer of any of this code so meh.

For the benefit of the archives perhaps someone could explain why gating a per-vcpu teardown on a host level feature setting is correct?

In particular what ensures that altp2m_vcpu_initialise has been called, given that this is only called from HVMOP_altp2m_set_domain_state. What happens if that HVMOP is never touched?

Quoted 5 lines

Do things work both for altp2m disabled on the Xen command line and disabled/enabled in the guest config? If so how?

Also how come HVMOP_altp2m_set_domain_state does not have a hvm_altp2m_supported check?

So this was all acked & stuff before I had much of a chance to comment on it, but on my to-do list for 4.7 is to rework a lot of the initialization / teardown stuff. In particular:

- Always and only check for whether something has been initialized (e.g., non-NULL, non-INVALID_MFN) before tearing it down

- Do *all* of the initialization for both altp2m and nestedhvm when they're actually enabled for the domain, rather than doing a bunch of the initialization unconditionally up front.

This is all part of the "technical debt" we were talking about when we considered giving it a freeze exception.

-George

#6 lore raw
Quoted 28 lines · George Dunlap
Quoted 14 lines · Ian Campbell
Quoted 3 lines · Ian Campbell

which I have applied with. I still don't think the commit message is very
satisfactory, but I'm not maintainer of any of this code so meh.

For the benefit of the archives perhaps someone could explain why gating a
per-vcpu teardown on a host level feature setting is correct?

In particular what ensures that altp2m_vcpu_initialise has been called, given that this is only called from HVMOP_altp2m_set_domain_state. What happens if that HVMOP is never touched?

Quoted 5 lines

Do things work both for altp2m disabled on the Xen command line and disabled/enabled in the guest config? If so how?

Also how come HVMOP_altp2m_set_domain_state does not have a hvm_altp2m_supported check?

So this was all acked & stuff before I had much of a chance to comment on it, but on my to-do list for 4.7 is to rework a lot of the initialization / teardown stuff. In particular:

- Always and only check for whether something has been initialized (e.g., non-NULL, non-INVALID_MFN) before tearing it down

Quoted 6 lines

- Do *all* of the initialization for both altp2m and nestedhvm when they're actually enabled for the domain, rather than doing a bunch of the initialization unconditionally up front.

This is all part of the "technical debt" we were talking about when we considered giving it a freeze exception.

Thanks, I'm inferring that everything I asked about in the second from last paragraph is somehow fine, just confusingly achieved in the current code...

I'm done grumping now...

Ian.

#7 lore raw
In reply to Ian Campbell
Quoted 2 lines · Ian Campbell

Also how come HVMOP_altp2m_set_domain_state does not have a hvm_altp2m_supported check?

(For the benefit of not leaving this question unanswered)

There is an early exit at the top of do_altp2m_op(), ahead of even reading the hypercall body from the guest.

~Andrew

#8 lore raw
Quoted 8 lines · Andrew Cooper
Quoted 2 lines · Ian Campbell

Also how come HVMOP_altp2m_set_domain_state does not have a hvm_altp2m_supported check?

(For the benefit of not leaving this question unanswered)

There is an early exit at the top of do_altp2m_op(), ahead of even reading the hypercall body from the guest.

Thanks.

Ian.