xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH] Don't enable irq for machine check vmexit
@ 2010-02-01  9:18 Jiang, Yunhong
  2010-02-01 11:14 ` Keir Fraser
  2010-02-04  9:26 ` Jiang, Yunhong
  0 siblings, 2 replies; 14+ messages in thread
From: Jiang, Yunhong @ 2010-02-01  9:18 UTC (permalink / raw)
  To: Jiang, Yunhong, Keir Fraser, Tim.Deegan@citrix.com
  Cc: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 2658 bytes --]

Sorry forgot the patch.

--jyh

diff -r 857d7b2dd8c7 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Jan 29 08:59:46 2010 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c	Sun Jan 31 18:40:34 2010 +0800
@@ -2153,6 +2153,7 @@ static void vmx_failed_vmentry(unsigned 
         printk("caused by machine check.\n");
         HVMTRACE_0D(MCE);
         do_machine_check(regs);
+        local_irq_enable();
         break;
     default:
         printk("reason not known yet!");
@@ -2243,6 +2244,23 @@ err:
 err:
     vmx_inject_hw_exception(TRAP_gp_fault, 0);
     return -1;
+}
+
+int vmx_mce_exit(int exit_reason)
+{
+    if ( unlikely(exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY &&
+        (uint16_t)exit_reason == EXIT_REASON_MCE_DURING_VMENTRY) )
+            return 1;
+    else if (unlikely(exit_reason == EXIT_REASON_EXCEPTION_NMI))
+    {
+        uint32_t vector;
+
+        vector = __vmread(VM_EXIT_INTR_INFO) & INTR_INFO_VECTOR_MASK;
+        if (vector == TRAP_machine_check)
+            return 1;
+    }
+
+    return 0;
 }
 
 asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
@@ -2273,7 +2291,8 @@ asmlinkage void vmx_vmexit_handler(struc
         vmx_do_extint(regs);
 
     /* Now enable interrupts so it's safe to take locks. */
-    local_irq_enable();
+    if ( !(vmx_mce_exit(exit_reason)) )
+        local_irq_enable();
 
     if ( unlikely(exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) )
         return vmx_failed_vmentry(exit_reason, regs);
@@ -2433,6 +2452,7 @@ asmlinkage void vmx_vmexit_handler(struc
         case TRAP_machine_check:
             HVMTRACE_0D(MCE);
             do_machine_check(regs);
+            local_irq_enable();
             break;
         case TRAP_invalid_op:
             vmx_vmexit_ud_intercept(regs);



>-----Original Message-----
>From: Jiang, Yunhong
>Sent: Monday, February 01, 2010 4:48 PM
>To: Keir Fraser; Tim.Deegan@citrix.com
>Cc: xen-devel@lists.xensource.com
>Subject: [PATCH] Don't enable irq for machine check vmexit
>
>We should not enable irq for machine check VMExit
>
>In changeset 18658:824892134573, IRQ is enabled during VMExit except external
>interrupt. The exception should apply for machine check also, because :
>a) The mce_logout_lock should be held in irq_disabled context.
>b) The machine check event should be handled as quickly as possible, enable irq will
>increase the period greatly.
>
>Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
>
>This is in hotspot code path, I try to use unlikely, hope to reduce the performance
>impact
>
>Thanks
>Yunhong Jiang


[-- Attachment #2: hvm_vmexit.patch --]
[-- Type: application/octet-stream, Size: 2183 bytes --]

We should not enable irq for machine check VMExit

In changeset 18658:824892134573, IRQ is enabled during VMExit except external interrupt. The exception should apply for machine check also, because :
a) The mce_logout_lock should be hold in irq_disabled context.
b) The machine check event should be handled as quickly as possible, enable irq will increase the period greatly.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>

diff -r 857d7b2dd8c7 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Jan 29 08:59:46 2010 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c	Sun Jan 31 18:40:34 2010 +0800
@@ -2153,6 +2153,7 @@ static void vmx_failed_vmentry(unsigned 
         printk("caused by machine check.\n");
         HVMTRACE_0D(MCE);
         do_machine_check(regs);
+        local_irq_enable();
         break;
     default:
         printk("reason not known yet!");
@@ -2243,6 +2244,23 @@ err:
 err:
     vmx_inject_hw_exception(TRAP_gp_fault, 0);
     return -1;
+}
+
+int vmx_mce_exit(int exit_reason)
+{
+    if ( unlikely(exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY &&
+        (uint16_t)exit_reason == EXIT_REASON_MCE_DURING_VMENTRY) )
+            return 1;
+    else if (unlikely(exit_reason == EXIT_REASON_EXCEPTION_NMI))
+    {
+        uint32_t vector;
+
+        vector = __vmread(VM_EXIT_INTR_INFO) & INTR_INFO_VECTOR_MASK;
+        if (vector == TRAP_machine_check)
+            return 1;
+    }
+
+    return 0;
 }
 
 asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
@@ -2273,7 +2291,8 @@ asmlinkage void vmx_vmexit_handler(struc
         vmx_do_extint(regs);
 
     /* Now enable interrupts so it's safe to take locks. */
-    local_irq_enable();
+    if ( !(vmx_mce_exit(exit_reason)) )
+        local_irq_enable();
 
     if ( unlikely(exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) )
         return vmx_failed_vmentry(exit_reason, regs);
@@ -2433,6 +2452,7 @@ asmlinkage void vmx_vmexit_handler(struc
         case TRAP_machine_check:
             HVMTRACE_0D(MCE);
             do_machine_check(regs);
+            local_irq_enable();
             break;
         case TRAP_invalid_op:
             vmx_vmexit_ud_intercept(regs);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-02-07  4:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01  9:18 [PATCH] Don't enable irq for machine check vmexit Jiang, Yunhong
2010-02-01 11:14 ` Keir Fraser
2010-02-04  9:26 ` Jiang, Yunhong
2010-02-04 10:03   ` Keir Fraser
2010-02-04 12:25     ` Jiang, Yunhong
2010-02-04 14:21       ` Tim Deegan
2010-02-04 14:35         ` Jiang, Yunhong
2010-02-05 10:22         ` Jiang, Yunhong
2010-02-05 10:42           ` Tim Deegan
2010-02-05 14:37             ` Jiang, Yunhong
2010-02-05 12:53           ` Keir Fraser
2010-02-05 14:36             ` Jiang, Yunhong
2010-02-05 14:59               ` Keir Fraser
2010-02-07  4:25                 ` Jiang, Yunhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).