xen/events: add a proper barrier to 2-level uevent unmasking
authorJuergen Gross <jgross@suse.com>
Mon, 7 Sep 2020 13:47:27 +0000 (15:47 +0200)
committerJuergen Gross <jgross@suse.com>
Tue, 20 Oct 2020 08:21:56 +0000 (10:21 +0200)
A follow-up patch will require certain write to happen before an event
channel is unmasked.

While the memory barrier is not strictly necessary for all the callers,
the main one will need it. In order to avoid an extra memory barrier
when using fifo event channels, mandate evtchn_unmask() to provide
write ordering.

The 2-level event handling unmask operation is missing an appropriate
barrier, so add it. Fifo event channels are fine in this regard due to
using sync_cmpxchg().

This is part of XSA-332.

Cc: stable@vger.kernel.org
Suggested-by: Julien Grall <julien@xen.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Wei Liu <wl@xen.org>
drivers/xen/events/events_2l.c

index 64df919a2111b1ba51ede63e75bd42b9db789e7d..e1af5e093ff4550c199290f0e496b6593192c155 100644 (file)
@@ -91,6 +91,8 @@ static void evtchn_2l_unmask(evtchn_port_t port)
 
        BUG_ON(!irqs_disabled());
 
+       smp_wmb();      /* All writes before unmask must be visible. */
+
        if (unlikely((cpu != cpu_from_evtchn(port))))
                do_hypercall = 1;
        else {