xen: Add RING_COPY_REQUEST()
authorDavid Vrabel <david.vrabel@citrix.com>
Fri, 30 Oct 2015 14:58:08 +0000 (14:58 +0000)
committerZefan Li <lizefan@huawei.com>
Wed, 26 Oct 2016 15:15:39 +0000 (23:15 +0800)
commitffac74669117c65a25fa0a9c5194ef70fb95ee70
tree5b90f61c4141795aab375b4d9d5aebe45b780732
parent334e907923e9cab057020a9c7ec7d9f32ead6573
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: Zefan Li <lizefan@huawei.com>
include/xen/interface/io/ring.h