Jeremy Fitzhardinge
2009-Feb-04 00:01 UTC
[Xen-devel] [PATCH] xen: disable interrupts before saving in percpu
xen_mc_batch has a small preempt race where it takes the address of a percpu variable immediately before disabling interrupts, thereby leaving a small window in which we may migrate to another cpu and save the flags in the wrong percpu variable. Disable interrupts before saving the old flags in a percpu. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/xen/multicalls.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ==================================================================--- a/arch/x86/xen/multicalls.h +++ b/arch/x86/xen/multicalls.h @@ -19,8 +19,10 @@ paired with xen_mc_issue() */ static inline void xen_mc_batch(void) { + unsigned long flags; /* need to disable interrupts until this entry is complete */ - local_irq_save(__get_cpu_var(xen_mc_irq_flags)); + local_irq_save(flags); + __get_cpu_var(xen_mc_irq_flags) = flags; } static inline struct multicall_space xen_mc_entry(size_t args) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-Feb-04 02:15 UTC
[Xen-devel] Re: [PATCH] xen: disable interrupts before saving in percpu
H. Peter Anvin wrote:> Jeremy Fitzhardinge wrote: > >> xen_mc_batch has a small preempt race where it takes the address of a >> percpu variable immediately before disabling interrupts, thereby >> leaving a small window in which we may migrate to another cpu and save >> the flags in the wrong percpu variable. Disable interrupts before >> saving the old flags in a percpu. >> > > Applied to tip:core/xen, thanks!Can you push this Linusward too? Thanks, J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel