All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] x86: enforce strict memory order for x2apic
@ 2008-09-25  6:55 Tian, Kevin
  2008-09-25  8:24 ` Jan Beulich
  0 siblings, 1 reply; 7+ messages in thread
From: Tian, Kevin @ 2008-09-25  6:55 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

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

enforce strict memory order for x2apic.

x2apic allows using MSR to access APIC registers. For
efficient access, serializing semantics of WRMSR to
APIC regs are relaxed. This breaks some assumptions
made on old MMIO access style. In those places, wmb()
is used which is a nop on x86, as MMIO APIC regs are
mapped in uncacheable style which enforces program
order. However when x2apic is enabled, it's possible
for wrmsr reordered even before earlier global data
writes. We observed occasional crash in
smp_call_function_interrupt, where stale call_data
is referenced.

We kick a fix by simply using 'mb' instead of 'wmb'.
This can effectively enforce program order, as args
for WRMSR are loaded from memory. Those memory loads
are ordered by mb and so does WRMSR. Alternative is
to add a 'fence' parameter to send_IPI_mask and then
only use 'mb' in x2apic version. We think it's not
necessary to go with that complexity.

Signed-off-by Kevin Tian <kevin.tian@intel.com>
Signed-off-by Yunhong Jiang <yunhong.jiang@intel.com>

diff -r cfa7cabb56cb xen/arch/x86/smp.c
--- a/xen/arch/x86/smp.c        Thu Sep 25 05:33:35 2008 +0800
+++ b/xen/arch/x86/smp.c        Thu Sep 25 05:52:03 2008 +0800
@@ -186,6 +186,7 @@ void flush_area_mask(cpumask_t mask, con
         flush_cpumask = mask;
         flush_va      = va;
         flush_flags   = flags;
+        mb();
         send_IPI_mask(mask, INVALIDATE_TLB_VECTOR);
         while ( !cpus_empty(flush_cpumask) )
             cpu_relax();
@@ -280,7 +281,7 @@ int on_selected_cpus(
     spin_lock(&call_lock);

     call_data = &data;
-    wmb();
+    mb();

     send_IPI_mask(selected, CALL_FUNCTION_VECTOR);

[-- Attachment #2: x2apic-ipi.patch --]
[-- Type: application/octet-stream, Size: 1650 bytes --]

enforce strict memory order for x2apic.

x2apic allows using MSR to access APIC registers. For
efficient access, serializing semantics of WRMSR to
APIC regs are relaxed. This breaks some assumptions
made on old MMIO access style. In those places, wmb() 
is used which is a nop on x86, as MMIO APIC regs are
mapped in uncacheable style which enforces program
order. However when x2apic is enabled, it's possible
for wrmsr reordered even before earlier global data
writes. We observed occasional crash in 
smp_call_function_interrupt, where stale call_data
is referenced.

We kick a fix by simply using 'mb' instead of 'wmb'.
This can effectively enforce program order, as args
for WRMSR are loaded from memory. Those memory loads
are ordered by mb and so does WRMSR. Alternative is 
to add a 'fence' parameter to send_IPI_mask and then 
only use 'mb' in x2apic version. We think it's not 
necessary to go with that complexity.

Signed-off-by Kevin Tian <kevin.tian@intel.com>
Signed-off-by Yunhong Jiang <yunhong.jiang@intel.com>

diff -r cfa7cabb56cb xen/arch/x86/smp.c
--- a/xen/arch/x86/smp.c	Thu Sep 25 05:33:35 2008 +0800
+++ b/xen/arch/x86/smp.c	Thu Sep 25 05:52:03 2008 +0800
@@ -186,6 +186,7 @@ void flush_area_mask(cpumask_t mask, con
         flush_cpumask = mask;
         flush_va      = va;
         flush_flags   = flags;
+        mb();
         send_IPI_mask(mask, INVALIDATE_TLB_VECTOR);
         while ( !cpus_empty(flush_cpumask) )
             cpu_relax();
@@ -280,7 +281,7 @@ int on_selected_cpus(
     spin_lock(&call_lock);
 
     call_data = &data;
-    wmb();
+    mb();
 
     send_IPI_mask(selected, CALL_FUNCTION_VECTOR);
 

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

end of thread, other threads:[~2008-09-25  9:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-25  6:55 [Patch] x86: enforce strict memory order for x2apic Tian, Kevin
2008-09-25  8:24 ` Jan Beulich
2008-09-25  8:29   ` Tian, Kevin
2008-09-25  8:36     ` Keir Fraser
2008-09-25  8:38       ` Tian, Kevin
2008-09-25  8:40         ` Tian, Kevin
2008-09-25  9:04           ` 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.