[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/79] ps2: prevent changing irq state on save and lo
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 04/79] ps2: prevent changing irq state on save and load |
Date: |
Sun, 30 Sep 2018 10:12:02 +0200 |
From: Pavel Dovgalyuk <address@hidden>
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>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <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)
--
1.8.3.1
- [Qemu-devel] [PULL 00/79] Misc QEMU patches for 2018-09-30, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 03/79] es1370: fix ADC_FRAMEADR and ADC_FRAMECNT, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 02/79] qsp: hide indirect function calls from Coverity, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 04/79] ps2: prevent changing irq state on save and load,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/79] cpus: initialize timers_state.vm_clock_lock, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 08/79] util: add atomic64, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 07/79] cacheinfo: add i/d cache_linesize_log, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 05/79] atomic: fix comment s/x64_64/x86_64/, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 01/79] virtio: Return true from virtio_queue_empty if broken, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 09/79] tests: add atomic64-bench, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 16/79] hostmem-memfd: add checks before adding hostmem-memfd & properties, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 13/79] cpus: access .qemu_icount with atomic64, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 12/79] cpus: take seqlock across qemu_icount updates, Paolo Bonzini, 2018/09/30
- [Qemu-devel] [PULL 14/79] cpus: access .qemu_icount_bias with atomic64, Paolo Bonzini, 2018/09/30