mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
xen/evtchn: fix ring resize when binding new events
commit27e0e63853upstream. The copying of ring data was wrong for two cases: For a full ring nothing got copied at all (as in that case the canonicalized producer and consumer indexes are identical). And in case one or both of the canonicalized (after the resize) indexes would point into the second half of the buffer, the copied data ended up in the wrong (free) part of the new buffer. In both cases uninitialized data would get passed back to the caller. Fix this by simply copying the old ring contents twice: Once to the low half of the new buffer, and a second time to the high half. This addresses the inability to boot a HVM guest with 64 or more vCPUs. This regression was caused by8620015499(xen/evtchn: dynamically grow pending event channel ring). Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
58d378b24b
commit
11dc8042c6
@@ -316,7 +316,6 @@ static int evtchn_resize_ring(struct per_user_data *u)
|
|||||||
{
|
{
|
||||||
unsigned int new_size;
|
unsigned int new_size;
|
||||||
evtchn_port_t *new_ring, *old_ring;
|
evtchn_port_t *new_ring, *old_ring;
|
||||||
unsigned int p, c;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure the ring is large enough to capture all possible
|
* Ensure the ring is large enough to capture all possible
|
||||||
@@ -346,20 +345,17 @@ static int evtchn_resize_ring(struct per_user_data *u)
|
|||||||
/*
|
/*
|
||||||
* Copy the old ring contents to the new ring.
|
* Copy the old ring contents to the new ring.
|
||||||
*
|
*
|
||||||
* If the ring contents crosses the end of the current ring,
|
* To take care of wrapping, a full ring, and the new index
|
||||||
* it needs to be copied in two chunks.
|
* pointing into the second half, simply copy the old contents
|
||||||
|
* twice.
|
||||||
*
|
*
|
||||||
* +---------+ +------------------+
|
* +---------+ +------------------+
|
||||||
* |34567 12| -> | 1234567 |
|
* |34567 12| -> |34567 1234567 12|
|
||||||
* +-----p-c-+ +------------------+
|
* +-----p-c-+ +-------c------p---+
|
||||||
*/
|
*/
|
||||||
p = evtchn_ring_offset(u, u->ring_prod);
|
memcpy(new_ring, old_ring, u->ring_size * sizeof(*u->ring));
|
||||||
c = evtchn_ring_offset(u, u->ring_cons);
|
memcpy(new_ring + u->ring_size, old_ring,
|
||||||
if (p < c) {
|
u->ring_size * sizeof(*u->ring));
|
||||||
memcpy(new_ring + c, u->ring + c, (u->ring_size - c) * sizeof(*u->ring));
|
|
||||||
memcpy(new_ring + u->ring_size, u->ring, p * sizeof(*u->ring));
|
|
||||||
} else
|
|
||||||
memcpy(new_ring + c, u->ring + c, (p - c) * sizeof(*u->ring));
|
|
||||||
|
|
||||||
u->ring = new_ring;
|
u->ring = new_ring;
|
||||||
u->ring_size = new_size;
|
u->ring_size = new_size;
|
||||||
|
|||||||
Reference in New Issue
Block a user