Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06fc732c authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by H. Peter Anvin
Browse files

xen: disable interrupts before saving in percpu



Impact: Fix race condition

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: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent b1792e36
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -19,8 +19,10 @@ DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
   paired with xen_mc_issue() */
   paired with xen_mc_issue() */
static inline void xen_mc_batch(void)
static inline void xen_mc_batch(void)
{
{
	unsigned long flags;
	/* need to disable interrupts until this entry is complete */
	/* 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)
static inline struct multicall_space xen_mc_entry(size_t args)