From e9811a0708c6a91b4cbade05207ebb426506a046 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sun, 30 Apr 2023 19:09:49 +0900 Subject: [PATCH] virtio: handle queue overflow --- kernel/arch/aarch64/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/arch/aarch64/virtio.c b/kernel/arch/aarch64/virtio.c index c551b1b8..5d3f9b14 100644 --- a/kernel/arch/aarch64/virtio.c +++ b/kernel/arch/aarch64/virtio.c @@ -228,7 +228,7 @@ static void virtio_tablet_thread(void * data) { uint16_t them = queue->used.index; - for (; index < them; index++) { + for (; index != them; index++) { asm volatile ("dc ivac, %0\ndsb sy" :: "r"(&buffers[index%queue_size]) : "memory"); struct virtio_input_event evt = buffers[index%queue_size]; while (evt.type == 0xFF) { @@ -376,7 +376,7 @@ static void virtio_keyboard_thread(void * data) { uint16_t them = queue->used.index; - for (; index < them; index++) { + for (; index != them; index++) { asm volatile ("dc ivac, %0\ndsb sy" :: "r"(&buffers[index%queue_size]) : "memory"); struct virtio_input_event evt = buffers[index%queue_size]; while (evt.type == 0xFF) {