Skip to contentSkip to conversation

Input 20180515 patches

GIT PULL Applied Gerd Hoffmann 2 participants 4 messages May 15, 2018

lore
Share & tools
lore
#0 lore raw

The following changes since commit fbd3a489df9953e2a5d017c922f3c103b2426952:

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180514' into staging (2018-05-14 18:53:42 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/input-20180515-pull-request

for you to fetch changes up to 7abe7eb29494b4e4a11ec99ae5623083409a2f1e:

ps2: Fix mouse stream corruption due to lost data (2018-05-15 11:31:33 +0200)

----------------------------------------------------------------
input: ps2 fixes.

----------------------------------------------------------------

Geoffrey McRae (2):
ps2: Clear the PS/2 queue and obey disable
ps2: Fix mouse stream corruption due to lost data

 include/hw/input/ps2.h |   5 ++
 hw/input/ps2.c         | 135 ++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 111 insertions(+), 29 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

[Qemu-devel] [PULL 1/2] ps2: Clear the PS/2 queue and obey disable

From: Geoffrey McRae <[email protected]>

This allows guest's to correctly reinitialize and identify the mouse should the guest decide to re-scan or reset during mouse input events.

When the guest sends the "Identify" command, due to the PC's hardware architecutre it is impossible to reliably determine the response from the command amongst other streaming data, such as mouse or keyboard events. Standard practice is for the guest to disable the device and then issue the identify command, so this must be obeyed.

Message-Id: <[email protected]>

---
 hw/input/ps2.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
hw/input/ps2.c +11 -0
index 06f5d2ac4a..4abc8cecdd 100644
@@ -232,6 +232,11 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
     uint16_t keycode = 0;
     int mod;
 
+    /* do not process events while disabled to prevent stream corruption */
+    if (!s->scan_enabled) {
+        return;
+    }
+
     qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
     assert(evt->type == INPUT_EVENT_KIND_KEY);
     qcode = qemu_input_key_value_to_qcode(key->key);
@@ -673,6 +678,11 @@ static void ps2_mouse_sync(DeviceState *dev)
 {
     PS2MouseState *s = (PS2MouseState *)dev;
 
+    /* do not sync while disabled to prevent stream corruption */
+    if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) {
+        return;
+    }
+
     if (s->mouse_buttons) {
         qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
     }
@@ -776,6 +786,7 @@ void ps2_write_mouse(void *opaque, int val)
             s->mouse_resolution = 2;
             s->mouse_status = 0;
             s->mouse_type = 0;
+            ps2_reset_queue(&s->common);
             ps2_queue(&s->common, AUX_ACK);
             ps2_queue(&s->common, 0xaa);
             ps2_queue(&s->common, s->mouse_type);
Signature · 1 line
2.9.3
#2 lore raw

[Qemu-devel] [PULL 2/2] ps2: Fix mouse stream corruption due to lost data

In reply to Gerd Hoffmann

From: Geoffrey McRae <[email protected]>

This fixes an issue by adding bounds checking to multi-byte packets where the PS/2 mouse data stream may become corrupted due to data being discarded when the PS/2 ringbuffer is full.

Interrupts for Multi-byte responses are postponed until the final byte has been queued.

These changes fix a bug where windows guests drop the mouse device entirely requring the guest to be restarted.

Message-Id: <[email protected]>

[ kraxel: codestyle fixes ]

---
 include/hw/input/ps2.h |   5 ++
 hw/input/ps2.c         | 124 +++++++++++++++++++++++++++++++++++++------------
 2 files changed, 100 insertions(+), 29 deletions(-)
include/hw/input/ps2.h +5 -0
index 94709b8502..213aa16aa3 100644
@@ -37,7 +37,12 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
 void ps2_write_mouse(void *, int val);
 void ps2_write_keyboard(void *, int val);
 uint32_t ps2_read_data(PS2State *s);
+void ps2_queue_noirq(PS2State *s, int b);
+void ps2_raise_irq(PS2State *s);
 void ps2_queue(PS2State *s, int b);
+void ps2_queue_2(PS2State *s, int b1, int b2);
+void ps2_queue_3(PS2State *s, int b1, int b2, int b3);
+void ps2_queue_4(PS2State *s, int b1, int b2, int b3, int b4);
 void ps2_keyboard_set_translation(void *opaque, int mode);
 void ps2_mouse_fake_event(void *opaque);
 
hw/input/ps2.c +95 -29

219 lines not on this page · raw message

Signature · 1 line
2.9.3
#3 lore raw
In reply to Gerd Hoffmann
Quoted 17 lines · Gerd Hoffmann

The following changes since commit fbd3a489df9953e2a5d017c922f3c103b2426952:

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180514' into staging (2018-05-14 18:53:42 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/input-20180515-pull-request

for you to fetch changes up to 7abe7eb29494b4e4a11ec99ae5623083409a2f1e:

ps2: Fix mouse stream corruption due to lost data (2018-05-15 11:31:33 +0200)

----------------------------------------------------------------
input: ps2 fixes.

----------------------------------------------------------------

Quoted 8 lines

Geoffrey McRae (2):
ps2: Clear the PS/2 queue and obey disable
ps2: Fix mouse stream corruption due to lost data

 include/hw/input/ps2.h |   5 ++
 hw/input/ps2.c         | 135 ++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 111 insertions(+), 29 deletions(-)

Applied, thanks.

-- PMM