1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-23 18:06:20 +04:00

Fix overflows on available ring.

This commit is contained in:
Stephen Marz 2020-05-24 13:34:26 -04:00
parent e680196095
commit 4535739f00

View File

@ -374,7 +374,7 @@ pub fn init(gdev: usize) {
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).desc[dev.idx as usize] = desc_c2d_resp;
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize] = head;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize % VIRTIO_RING_SIZE] = head;
(*dev.queue).avail.idx =
(*dev.queue).avail.idx.wrapping_add(1);
}
@ -422,7 +422,7 @@ pub fn init(gdev: usize) {
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).desc[dev.idx as usize] = desc_ab_resp;
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize] = head;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize % VIRTIO_RING_SIZE] = head;
(*dev.queue).avail.idx =
(*dev.queue).avail.idx.wrapping_add(1);
}
@ -457,7 +457,7 @@ pub fn init(gdev: usize) {
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).desc[dev.idx as usize] = desc_sso_resp;
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize] = head;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize % VIRTIO_RING_SIZE] = head;
(*dev.queue).avail.idx =
(*dev.queue).avail.idx.wrapping_add(1);
}
@ -493,7 +493,7 @@ pub fn init(gdev: usize) {
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).desc[dev.idx as usize] = desc_t2h_resp;
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize] = head;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize % VIRTIO_RING_SIZE] = head;
(*dev.queue).avail.idx =
(*dev.queue).avail.idx.wrapping_add(1);
}
@ -528,7 +528,7 @@ pub fn init(gdev: usize) {
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).desc[dev.idx as usize] = desc_rf_resp;
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize] = head;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize % VIRTIO_RING_SIZE] = head;
(*dev.queue).avail.idx =
(*dev.queue).avail.idx.wrapping_add(1);
}
@ -575,7 +575,7 @@ pub fn transfer(gdev: usize, x: u32, y: u32, width: u32, height: u32) {
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).desc[dev.idx as usize] = desc_t2h_resp;
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize] = head;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize % VIRTIO_RING_SIZE] = head;
(*dev.queue).avail.idx =
(*dev.queue).avail.idx.wrapping_add(1);
}
@ -610,7 +610,7 @@ pub fn transfer(gdev: usize, x: u32, y: u32, width: u32, height: u32) {
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).desc[dev.idx as usize] = desc_rf_resp;
dev.idx = (dev.idx + 1) % VIRTIO_RING_SIZE as u16;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize] = head;
(*dev.queue).avail.ring[(*dev.queue).avail.idx as usize % VIRTIO_RING_SIZE] = head;
(*dev.queue).avail.idx =
(*dev.queue).avail.idx.wrapping_add(1);
}