evtchn_do_upcall() barrier between upcall_pending and pending_sel
Hello,
In evtchn_do_upcall() there is a barrier between setting upcall_pending and pending_sel, which makes sense to avoid losing events, however I don't understand why it is a rmb(). memory-barriers.txt says that rmb() only provides ordering of reads, not stores. Shouldn't that be a wmb() instead then?
Samuel
Makes sense, yes.
-- Keir
Quoted 14 lines · Samuel Thibault
Hello,
In
evtchn_do_upcall()there is a barrier between settingupcall_pendingandpending_sel, which makes sense to avoid losing events, however I don't understand why it is armb(). memory-barriers.txt says thatrmb()only provides ordering of reads, not stores. Shouldn't that be awmb()instead then?Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 1 line · Keir Fraser, le Thu 08 May 2008 11:25:59 +0100, a écrit :
Makes sense, yes.
Here are fixes then.
evtchn: Use wmb instead of rmb to enforce ordering between evtchn_upcall_pending and evtchn_pending_sel stores.
drivers/xen/core/evtchn.c +1 -1
@@ -246,7 +246,7 @@ asmlinkage void evtchn_do_upcall(struct#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ /* Clear master flag /before/ clearing selector flag. */ -rmb (); +wmb ();#endif l1 =xchg (&vcpu_info->evtchn_pending_sel,0 );
minios: in non-x86 case, use wmb to enforce ordering between evtchn_upcall_pending and evtchn_pending_sel stores.
extras/mini-os/hypervisor.c +5 -1
@@ -46,7 +46,11 @@ void do_hypervisor_callback(struct pt_re in_callback =1 ; vcpu_info->evtchn_upcall_pending =0 ; -/* NB. No need for a barrier here -- XCHG is a barrier on x86. */ +/* NB x86. No need for a barrier here -- XCHG is a barrier on x86. */ +#if !defined(__i386__) && !defined(__x86_64__) +/* clear master flag /before/ clearing selector flag. */ +wmb (); +#endif l1 =xchg (&vcpu_info->evtchn_pending_sel,0 );while ( l1 !=0 ) {