[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.5] libvchan: Read prod/cons only once.
commit 1fac32bd60db4fbd2a14d95c1601db55666f4fb1 Author: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> AuthorDate: Wed Mar 9 16:57:36 2016 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Mar 9 16:57:36 2016 +0100 libvchan: Read prod/cons only once. We must ensure that the prod/cons are only read once and that the compiler won't try to optimize the reads. That is split the read of these in multiple instructions influencing later branch code. As such insert barriers when fetching the cons and prod index. This is part of XSA155. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> master commit: 7d66a4ba695ab8d13b214fb816dd59e443ae1ec9 master date: 2015-12-18 09:50:02 -0500 --- tools/libvchan/io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/libvchan/io.c b/tools/libvchan/io.c index e66bc4e..3d23daa 100644 --- a/tools/libvchan/io.c +++ b/tools/libvchan/io.c @@ -118,6 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit) static inline int raw_get_data_ready(struct libxenvchan *ctrl) { uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl); + xen_mb(); /* Ensure 'ready' is read only once. */ if (ready > rd_ring_size(ctrl)) /* We have no way to return errors. Locking up the ring is * better than the alternatives. */ @@ -159,6 +160,7 @@ int libxenvchan_data_ready(struct libxenvchan *ctrl) static inline int raw_get_buffer_space(struct libxenvchan *ctrl) { uint32_t ready = wr_ring_size(ctrl) - (wr_prod(ctrl) - wr_cons(ctrl)); + xen_mb(); /* Ensure 'ready' is read only once. */ if (ready > wr_ring_size(ctrl)) /* We have no way to return errors. Locking up the ring is * better than the alternatives. */ -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.5 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |