All of lore.kernel.org
 help / color / mirror / Atom feed
* wbinvd optimization for pass through domain
@ 2007-11-15  3:05 Dong, Eddie
  2007-11-15  7:04 ` question about io path in the front/backend tgh
  2007-11-16 16:29 ` wbinvd optimization for pass through domain Keir Fraser
  0 siblings, 2 replies; 11+ messages in thread
From: Dong, Eddie @ 2007-11-15  3:05 UTC (permalink / raw)
  To: xen-devel

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


This patch optimize wbinvd exit emulation for pass-through domain
to avoid "alway wbinvd" when a VCPU is migrated. In stead, do
host wbinvd on all host CPUs when wbinvd exit.


Signed-off-by Yaozu (Eddie) Dong <eddie.dong@intel.com>

[-- Attachment #2: wbinvd-opt.patch --]
[-- Type: application/octet-stream, Size: 3362 bytes --]

diff -r dfca1120813f xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c	Sun Nov 11 18:28:57 2007 +0000
+++ b/xen/arch/x86/hvm/vmx/vmcs.c	Wed Nov 14 17:19:44 2007 +0800
@@ -766,7 +766,7 @@ void vm_resume_fail(unsigned long eflags
     domain_crash_synchronous();
 }
 
-static void flush_cache(void *info)
+void flush_cache(void *info)
 {
     wbinvd();
 }
@@ -784,10 +784,14 @@ void vmx_do_resume(struct vcpu *v)
     {
         /* For pass-through domain, guest PCI-E device driver may leverage the
          * "Non-Snoop" I/O, and explicitly "WBINVD" or "CFLUSH" to a RAM space.
-         * In that case, if migration occurs before "WBINVD" or "CFLUSH", need
-         * to maintain data consistency.
+         * Since migration may occurs before "WBINVD" or "CFLUSH", we need to
+         * maintain data consistency either:
+         * 1: flush cache (wbinvd) when the guest is scheduled out if there is
+         * no wbinvd exit, or
+         * 2: execute wbinvd on all dirty pCPUs when guest wbinvd exits.
          */
-        if ( !list_empty(&(domain_hvm_iommu(v->domain)->pdev_list)) )
+        if ( !list_empty(&(domain_hvm_iommu(v->domain)->pdev_list)) &&
+                !cpu_has_wbinvd_exiting )
         {
             int cpu = v->arch.hvm_vmx.active_cpu;
             if ( cpu != -1 )
diff -r dfca1120813f xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c	Sun Nov 11 18:28:57 2007 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c	Wed Nov 14 17:51:04 2007 +0800
@@ -2915,14 +2915,21 @@ asmlinkage void vmx_vmexit_handler(struc
         __update_guest_eip(inst_len);
         if ( !list_empty(&(domain_hvm_iommu(v->domain)->pdev_list)) )
         {
-            wbinvd();
-            /* Disable further WBINVD intercepts. */
-            if ( (exit_reason == EXIT_REASON_WBINVD) &&
-                 (vmx_cpu_based_exec_control &
-                  CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) )
-                __vmwrite(SECONDARY_VM_EXEC_CONTROL,
-                          vmx_secondary_exec_control &
-                          ~SECONDARY_EXEC_WBINVD_EXITING);
+            if ( cpu_has_wbinvd_exiting ) {
+                extern void flush_cache(void *info);
+
+                on_selected_cpus(cpu_online_map, flush_cache, NULL, 1, 1);
+            }
+            else {
+                wbinvd();
+                /* Disable further WBINVD intercepts. */
+                if ( (exit_reason == EXIT_REASON_WBINVD) &&
+                     (vmx_cpu_based_exec_control &
+                      CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) )
+                    __vmwrite(SECONDARY_VM_EXEC_CONTROL,
+                              vmx_secondary_exec_control &
+                              ~SECONDARY_EXEC_WBINVD_EXITING);
+            }
         }
         break;
     }
diff -r dfca1120813f xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h	Sun Nov 11 18:28:57 2007 +0000
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h	Wed Nov 14 17:07:54 2007 +0800
@@ -136,6 +136,8 @@ extern u32 vmx_secondary_exec_control;
 
 extern bool_t cpu_has_vmx_ins_outs_instr_info;
 
+#define cpu_has_wbinvd_exiting \
+    (vmx_secondary_exec_control & SECONDARY_EXEC_WBINVD_EXITING)
 #define cpu_has_vmx_virtualize_apic_accesses \
     (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)
 #define cpu_has_vmx_tpr_shadow \

[-- 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] 11+ messages in thread

end of thread, other threads:[~2007-12-09 19:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-15  3:05 wbinvd optimization for pass through domain Dong, Eddie
2007-11-15  7:04 ` question about io path in the front/backend tgh
2007-12-04  2:58   ` Mark Williamson
2007-12-05  7:19     ` tgh
2007-12-07  9:25     ` tgh
2007-12-09  2:10       ` Mark Williamson
2007-12-09  5:14         ` Pradeep Singh
2007-12-09 19:47           ` Mark Williamson
2007-11-16 16:29 ` wbinvd optimization for pass through domain Keir Fraser
2007-11-19  5:08   ` Dong, Eddie
2007-11-19 11:48     ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.