Skip to contentSkip to conversation

x86/vmx: Improvements to vmentry failure handling

PATCH In review Andrew Cooper 3 participants 3 messages Oct 23, 2015 – Oct 29, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/vmx: Improvements to vmentry failure handling

Combine the almost identical vm_launch_fail() and vm_resume_fail() into a single vmx_vmentry_failure().

Re-save all GPRs so that domain_crash() prints the real register values, rather than the active stack of the vmx_vmentry_failure() callpath.

---
CC: Jan Beulich <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

---
 xen/arch/x86/hvm/vmx/entry.S |  9 +++++----
 xen/arch/x86/hvm/vmx/vmcs.c  | 15 ++++-----------
 2 files changed, 9 insertions(+), 15 deletions(-)
xen/arch/x86/hvm/vmx/entry.S +5 -4
index 2a4ed57..a5438a4 100644
@@ -101,14 +101,15 @@ UNLIKELY_END(realmode)
 
 /*.Lvmx_resume:*/
         VMRESUME
-        sti
-        call vm_resume_fail
-        ud2
+        jmp  .Lvmx_vmentry_fail
 
 .Lvmx_launch:
         VMLAUNCH
+
+.Lvmx_vmentry_fail:
         sti
-        call vm_launch_fail
+        SAVE_ALL
+        call vmx_vmentry_failure
         ud2
 
 ENTRY(vmx_asm_do_vmentry)
xen/arch/x86/hvm/vmx/vmcs.c +4 -11
index 62e405f..7beac12 100644
@@ -1588,21 +1588,14 @@ void vmx_destroy_vmcs(struct vcpu *v)
     free_xenheap_page(v->arch.hvm_vmx.msr_bitmap);
 }
 
-void vm_launch_fail(void)
-{
-    unsigned long error;
-
-    __vmread(VM_INSTRUCTION_ERROR, &error);
-    printk("<vm_launch_fail> error code %lx\n", error);
-    domain_crash_synchronous();
-}
-
-void vm_resume_fail(void)
+void vmx_vmentry_failure(void)
 {
+    struct vcpu *curr = current;
     unsigned long error;
 
     __vmread(VM_INSTRUCTION_ERROR, &error);
-    printk("<vm_resume_fail> error code %lx\n", error);
+    printk(XENLOG_ERR "VM%s error: %#lx\n",
+           curr->arch.hvm_vmx.launched ? "RESUME" : "LAUNCH", error);
     domain_crash_synchronous();
 }
 
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Saturday, October 24, 2015 1:53 AM

Combine the almost identical vm_launch_fail() and vm_resume_fail() into a single vmx_vmentry_failure().

Re-save all GPRs so that domain_crash() prints the real register values, rather than the active stack of the vmx_vmentry_failure() callpath.

#2 lore raw
In reply to Andrew Cooper
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 23.10.15 at 19:52, <[email protected]> wrote:
xen/arch/x86/hvm/vmx/vmcs.c +1 -10
@@ -1588,21 +1588,14 @@ void vmx_destroy_vmcs(struct vcpu *v)
     free_xenheap_page(v->arch.hvm_vmx.msr_bitmap);
 }
 
-void vm_launch_fail(void)
-{
-    unsigned long error;
-
-    __vmread(VM_INSTRUCTION_ERROR, &error);
-    printk("<vm_launch_fail> error code %lx\n", error);
-    domain_crash_synchronous();
-}
-
-void vm_resume_fail(void)
+void vmx_vmentry_failure(void)

xen/arch/x86/hvm/vmx/vmcs.c void vmx_destroy_vmcs(struct vcpu *v) · line 1600

Quoted 10 lines
xen/arch/x86/hvm/vmx/vmcs.c +3 -1
 {
+    struct vcpu *curr = current;
     unsigned long error;
 
     __vmread(VM_INSTRUCTION_ERROR, &error);
-    printk("<vm_resume_fail> error code %lx\n", error);
+    printk(XENLOG_ERR "VM%s error: %#lx\n",
+           curr->arch.hvm_vmx.launched ? "RESUME" : "LAUNCH", error);
     domain_crash_synchronous();
 }

Imo this should be gprintk() both for log level purposes (subject to a follow-up discussion on XSA-152 which I'll kick off in a subsequent mail) and inclusion of the offending vCPU's ID in what gets printed.

Jan