* [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load
@ 2018-05-11 8:16 Pavel Dovgalyuk
2018-05-11 9:13 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Pavel Dovgalyuk @ 2018-05-11 8:16 UTC (permalink / raw)
To: qemu-devel
Cc: arei.gonglei, mst, ciro.santilli, maria.klimushenkova, dovgaluk,
kraxel, pavel.dovgaluk, pbonzini
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 <Pavel.Dovgaluk@ispras.ru>
---
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 06f5d2a..8b1931b 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -837,7 +837,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++) {
@@ -852,7 +857,6 @@ static void ps2_common_post_load(PS2State *s)
q->rptr = 0;
q->wptr = size;
q->count = size;
- s->update_irq(s->update_arg, q->count != 0);
}
static void ps2_kbd_reset(void *opaque)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load
2018-05-11 8:16 [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load Pavel Dovgalyuk
@ 2018-05-11 9:13 ` Paolo Bonzini
2018-09-11 10:18 ` Pavel Dovgalyuk
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2018-05-11 9:13 UTC (permalink / raw)
To: Pavel Dovgalyuk, qemu-devel
Cc: arei.gonglei, mst, ciro.santilli, maria.klimushenkova, dovgaluk,
kraxel
On 11/05/2018 10:16, Pavel Dovgalyuk wrote:
> 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 <Pavel.Dovgaluk@ispras.ru>
> ---
> 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 06f5d2a..8b1931b 100644
> --- a/hw/input/ps2.c
> +++ b/hw/input/ps2.c
> @@ -837,7 +837,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++) {
> @@ -852,7 +857,6 @@ static void ps2_common_post_load(PS2State *s)
> q->rptr = 0;
> q->wptr = size;
> q->count = size;
> - s->update_irq(s->update_arg, q->count != 0);
> }
>
> static void ps2_kbd_reset(void *opaque)
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load
2018-05-11 9:13 ` Paolo Bonzini
@ 2018-09-11 10:18 ` Pavel Dovgalyuk
2018-09-11 11:10 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Pavel Dovgalyuk @ 2018-09-11 10:18 UTC (permalink / raw)
To: 'Paolo Bonzini', 'Pavel Dovgalyuk', qemu-devel
Cc: arei.gonglei, mst, ciro.santilli, maria.klimushenkova, kraxel
Paolo, have you forgot about this?
Pavel Dovgalyuk
> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Friday, May 11, 2018 12:14 PM
> To: Pavel Dovgalyuk; qemu-devel@nongnu.org
> Cc: arei.gonglei@huawei.com; mst@redhat.com; ciro.santilli@gmail.com;
> maria.klimushenkova@ispras.ru; dovgaluk@ispras.ru; kraxel@redhat.com
> Subject: Re: [PATCH] ps2: prevent changing irq state on save and load
>
> On 11/05/2018 10:16, Pavel Dovgalyuk wrote:
> > 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 <Pavel.Dovgaluk@ispras.ru>
> > ---
> > 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 06f5d2a..8b1931b 100644
> > --- a/hw/input/ps2.c
> > +++ b/hw/input/ps2.c
> > @@ -837,7 +837,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++) {
> > @@ -852,7 +857,6 @@ static void ps2_common_post_load(PS2State *s)
> > q->rptr = 0;
> > q->wptr = size;
> > q->count = size;
> > - s->update_irq(s->update_arg, q->count != 0);
> > }
> >
> > static void ps2_kbd_reset(void *opaque)
> >
>
> Queued, thanks.
>
> Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load
2018-09-11 10:18 ` Pavel Dovgalyuk
@ 2018-09-11 11:10 ` Paolo Bonzini
2018-09-11 11:25 ` Gerd Hoffmann
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2018-09-11 11:10 UTC (permalink / raw)
To: Pavel Dovgalyuk, 'Pavel Dovgalyuk', qemu-devel
Cc: arei.gonglei, mst, ciro.santilli, maria.klimushenkova, kraxel
On 11/09/2018 12:18, Pavel Dovgalyuk wrote:
> Paolo, have you forgot about this?
>
> Pavel Dovgalyuk
Yes, though Gerd might be a better match for the patch.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load
2018-09-11 11:10 ` Paolo Bonzini
@ 2018-09-11 11:25 ` Gerd Hoffmann
2018-09-11 11:26 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2018-09-11 11:25 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Pavel Dovgalyuk, 'Pavel Dovgalyuk', qemu-devel,
arei.gonglei, mst, ciro.santilli, maria.klimushenkova
On Tue, Sep 11, 2018 at 01:10:56PM +0200, Paolo Bonzini wrote:
> On 11/09/2018 12:18, Pavel Dovgalyuk wrote:
> > Paolo, have you forgot about this?
> >
> > Pavel Dovgalyuk
>
> Yes, though Gerd might be a better match for the patch.
Dropped it from my patch mailbox after seeing your 'queued' message.
Pavel, can you resend?
thanks,
Gerd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load
2018-09-11 11:25 ` Gerd Hoffmann
@ 2018-09-11 11:26 ` Paolo Bonzini
2018-09-11 11:27 ` Pavel Dovgalyuk
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2018-09-11 11:26 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Pavel Dovgalyuk, 'Pavel Dovgalyuk', qemu-devel,
arei.gonglei, mst, ciro.santilli, maria.klimushenkova
On 11/09/2018 13:25, Gerd Hoffmann wrote:
> On Tue, Sep 11, 2018 at 01:10:56PM +0200, Paolo Bonzini wrote:
>> On 11/09/2018 12:18, Pavel Dovgalyuk wrote:
>>> Paolo, have you forgot about this?
>>>
>>> Pavel Dovgalyuk
>>
>> Yes, though Gerd might be a better match for the patch.
>
> Dropped it from my patch mailbox after seeing your 'queued' message.
>
> Pavel, can you resend?
No need, I'll queue it for real now. :)
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load
2018-09-11 11:26 ` Paolo Bonzini
@ 2018-09-11 11:27 ` Pavel Dovgalyuk
0 siblings, 0 replies; 7+ messages in thread
From: Pavel Dovgalyuk @ 2018-09-11 11:27 UTC (permalink / raw)
To: 'Paolo Bonzini', 'Gerd Hoffmann'
Cc: 'Pavel Dovgalyuk', qemu-devel, arei.gonglei, mst,
ciro.santilli, maria.klimushenkova
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> On 11/09/2018 13:25, Gerd Hoffmann wrote:
> > On Tue, Sep 11, 2018 at 01:10:56PM +0200, Paolo Bonzini wrote:
> >> On 11/09/2018 12:18, Pavel Dovgalyuk wrote:
> >>> Paolo, have you forgot about this?
> >>>
> >>> Pavel Dovgalyuk
> >>
> >> Yes, though Gerd might be a better match for the patch.
> >
> > Dropped it from my patch mailbox after seeing your 'queued' message.
> >
> > Pavel, can you resend?
>
> No need, I'll queue it for real now. :)
Thank you.
Pavel Dovgalyuk
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-09-11 11:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-11 8:16 [Qemu-devel] [PATCH] ps2: prevent changing irq state on save and load Pavel Dovgalyuk
2018-05-11 9:13 ` Paolo Bonzini
2018-09-11 10:18 ` Pavel Dovgalyuk
2018-09-11 11:10 ` Paolo Bonzini
2018-09-11 11:25 ` Gerd Hoffmann
2018-09-11 11:26 ` Paolo Bonzini
2018-09-11 11:27 ` Pavel Dovgalyuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).