xen: Add RING_COPY_REQUEST()
authorDavid Vrabel <david.vrabel@citrix.com>
Fri, 30 Oct 2015 14:58:08 +0000 (14:58 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 22 Jan 2016 21:40:06 +0000 (21:40 +0000)
commita489a13bfc648d5d3764d2fe064135f83ff34ee8
tree1cc85a0eeaaf87a1ad50abbfe99510ca7a842862
parent45f32e359d36dd045e4af0d1bea8bbbafd81eeb7
xen: Add RING_COPY_REQUEST()

commit 454d5d882c7e412b840e3c99010fe81a9862f6fb upstream.

Using RING_GET_REQUEST() on a shared ring is easy to use incorrectly
(i.e., by not considering that the other end may alter the data in the
shared ring while it is being inspected).  Safe usage of a request
generally requires taking a local copy.

Provide a RING_COPY_REQUEST() macro to use instead of
RING_GET_REQUEST() and an open-coded memcpy().  This takes care of
ensuring that the copy is done correctly regardless of any possible
compiler optimizations.

Use a volatile source to prevent the compiler from reordering or
omitting the copy.

This is part of XSA155.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/xen/interface/io/ring.h