[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 20/24] ps2: prevent changing irq state on save an
From: |
Pavel Dovgalyuk |
Subject: |
[Qemu-devel] [PATCH v5 20/24] ps2: prevent changing irq state on save and load |
Date: |
Wed, 25 Jul 2018 15:16:43 +0300 |
User-agent: |
StGit/0.17.1-dirty |
Commit 2858ab09e6f708e381fc1a1cc87e747a690c4884 changed
PS/2 keyboard/mouse buffers to the standard size. However, its state
may change when migrating from the old buffer size and therefore irq needs
updating. But this change made wrong, because it throws the whole queue
if there are too much data instead of cropping it.
That commit also updates irq (because the queue state may change).
But updating the irq may change the VM state (and determinism of
the execution). E.g., when replaying the execution, one may save
the VM state and the state of the interrupt controller will be updated
at the moment of saving, instead of using the recorded update events.
This patch makes the queue update deterministic: it removes the update_irq
call and crops the queue to prevent losing the characters and changing
the required irq status.
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
hw/input/ps2.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index fdfcadf..6c43fc2 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -914,7 +914,12 @@ static void ps2_common_post_load(PS2State *s)
uint8_t tmp_data[PS2_QUEUE_SIZE];
/* set the useful data buffer queue size, < PS2_QUEUE_SIZE */
- size = (q->count < 0 || q->count > PS2_QUEUE_SIZE) ? 0 : q->count;
+ size = q->count;
+ if (q->count < 0) {
+ size = 0;
+ } else if (q->count > PS2_QUEUE_SIZE) {
+ size = PS2_QUEUE_SIZE;
+ }
/* move the queue elements to the start of data array */
for (i = 0; i < size; i++) {
@@ -929,7 +934,6 @@ static void ps2_common_post_load(PS2State *s)
q->rptr = 0;
q->wptr = (size == PS2_QUEUE_SIZE) ? 0 : size;
q->count = size;
- s->update_irq(s->update_arg, q->count != 0);
}
static void ps2_kbd_reset(void *opaque)
- [Qemu-devel] [PATCH v5 10/24] replay: implement replay-seek command to proceed to the desired step, (continued)
- [Qemu-devel] [PATCH v5 10/24] replay: implement replay-seek command to proceed to the desired step, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 11/24] replay: flush events when exiting, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 12/24] timer: remove replay clock probe in deadline calculation, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 13/24] replay: refine replay-time module, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 14/24] translator: fix breakpoint processing, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 15/24] replay: flush rr queue before loading the vmstate, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 16/24] gdbstub: add reverse step support in replay mode, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 17/24] gdbstub: add reverse continue support in replay mode, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 18/24] replay: describe reverse debugging in docs/replay.txt, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 19/24] replay: allow loading any snapshots before recording, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 20/24] ps2: prevent changing irq state on save and load,
Pavel Dovgalyuk <=
- [Qemu-devel] [PATCH v5 21/24] replay: wake up vCPU when replaying, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 22/24] replay: replay BH for IDE trim operation, Pavel Dovgalyuk, 2018/07/25
- [Qemu-devel] [PATCH v5 23/24] replay: add BH oneshot event for block layer, Pavel Dovgalyuk, 2018/07/25
- Re: [Qemu-devel] [PATCH v5 23/24] replay: add BH oneshot event for block layer, Alex Bennée, 2018/07/26