qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4
@ 2015-07-17  6:52 Gerd Hoffmann
  2015-07-17  6:52 ` [Qemu-devel] [PULL 1/3] virtio-input: fix segfault in virtio_input_hid_properties Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2015-07-17  6:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Dropped the patch to enable virtio-input for non-linux systems.
Otherwise unmodified.

please pull,
  Gerd

The following changes since commit 2d5ee9e7a7dd495d233cf9613a865f63f88e3375:

  Merge remote-tracking branch 'remotes/lalrae/tags/mips-20150716' into staging (2015-07-16 10:40:23 +0100)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-input-20150717-1

for you to fetch changes up to 562f93754b95fd6dc65ad9a2aa15a90b2da7e8a4:

  hid: clarify hid_keyboard_process_keycode (2015-07-17 08:44:41 +0200)

----------------------------------------------------------------
input: fixes for 2.4

----------------------------------------------------------------
Gerd Hoffmann (1):
      virtio-input: move sys/ioctl.h include

Lin Ma (1):
      virtio-input: fix segfault in virtio_input_hid_properties

Paolo Bonzini (1):
      hid: clarify hid_keyboard_process_keycode

 hw/input/hid.c                         | 32 ++++++++++++++++++++++++++++----
 hw/input/virtio-input-hid.c            |  1 +
 hw/input/virtio-input-host.c           |  1 +
 include/standard-headers/linux/input.h |  1 -
 scripts/update-linux-headers.sh        |  1 +
 5 files changed, 31 insertions(+), 5 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PULL 1/3] virtio-input: fix segfault in virtio_input_hid_properties
  2015-07-17  6:52 [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Gerd Hoffmann
@ 2015-07-17  6:52 ` Gerd Hoffmann
  2015-07-17  6:52 ` [Qemu-devel] [PULL 2/3] virtio-input: move sys/ioctl.h include Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2015-07-17  6:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, Lin Ma

From: Lin Ma <lma@suse.com>

commit 5cce173 introduced virtio-input segfault, This patch fixes it.

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/virtio-input-hid.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
index 616a815..4d85dad 100644
--- a/hw/input/virtio-input-hid.c
+++ b/hw/input/virtio-input-hid.c
@@ -308,6 +308,7 @@ static void virtio_input_hid_handle_status(VirtIOInput *vinput,
 static Property virtio_input_hid_properties[] = {
     DEFINE_PROP_STRING("display", VirtIOInputHID, display),
     DEFINE_PROP_UINT32("head", VirtIOInputHID, head, 0),
+    DEFINE_PROP_END_OF_LIST(),
 };
 
 static void virtio_input_hid_class_init(ObjectClass *klass, void *data)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PULL 2/3] virtio-input: move sys/ioctl.h include
  2015-07-17  6:52 [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Gerd Hoffmann
  2015-07-17  6:52 ` [Qemu-devel] [PULL 1/3] virtio-input: fix segfault in virtio_input_hid_properties Gerd Hoffmann
@ 2015-07-17  6:52 ` Gerd Hoffmann
  2015-07-17  6:52 ` [Qemu-devel] [PULL 3/3] hid: clarify hid_keyboard_process_keycode Gerd Hoffmann
  2015-07-17 11:24 ` [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2015-07-17  6:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Michael S. Tsirkin

Drop from include/standard-headers/linux/input.h
Add to hw/input/virtio-input-host.c instead.

That allows to build virtio-input (except pass-through) on windows.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/virtio-input-host.c           | 1 +
 include/standard-headers/linux/input.h | 1 -
 scripts/update-linux-headers.sh        | 1 +
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/input/virtio-input-host.c b/hw/input/virtio-input-host.c
index f7e3d84..8978f16 100644
--- a/hw/input/virtio-input-host.c
+++ b/hw/input/virtio-input-host.c
@@ -11,6 +11,7 @@
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-input.h"
 
+#include <sys/ioctl.h>
 #include "standard-headers/linux/input.h"
 
 /* ----------------------------------------------------------------- */
diff --git a/include/standard-headers/linux/input.h b/include/standard-headers/linux/input.h
index a459dd2..b003c67 100644
--- a/include/standard-headers/linux/input.h
+++ b/include/standard-headers/linux/input.h
@@ -10,7 +10,6 @@
 
 
 #include <sys/time.h>
-#include <sys/ioctl.h>
 #include <sys/types.h>
 #include "standard-headers/linux/types.h"
 
diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
index 47378d9..f0e830c 100755
--- a/scripts/update-linux-headers.sh
+++ b/scripts/update-linux-headers.sh
@@ -56,6 +56,7 @@ cp_virtio() {
                 -e 's/__bitwise__//' \
                 -e 's/__attribute__((packed))/QEMU_PACKED/' \
                 -e 's/__inline__/inline/' \
+                -e '/sys\/ioctl.h/d' \
                 "$f" > "$to/$header";
         done
     fi
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PULL 3/3] hid: clarify hid_keyboard_process_keycode
  2015-07-17  6:52 [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Gerd Hoffmann
  2015-07-17  6:52 ` [Qemu-devel] [PULL 1/3] virtio-input: fix segfault in virtio_input_hid_properties Gerd Hoffmann
  2015-07-17  6:52 ` [Qemu-devel] [PULL 2/3] virtio-input: move sys/ioctl.h include Gerd Hoffmann
@ 2015-07-17  6:52 ` Gerd Hoffmann
  2015-07-17 11:24 ` [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2015-07-17  6:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Gerd Hoffmann

From: Paolo Bonzini <pbonzini@redhat.com>

Coverity thinks the fallthroughs are smelly.  They are correct, but
everything else in this function is like "wut?".

Refer explicitly to bits 8 and 9 of hs->kbd.modifiers instead of
shifting right first and using (1 << 7).  Document what the scancode
is when hid_code is 0xe0.  And add plenty of comments.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/hid.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/hw/input/hid.c b/hw/input/hid.c
index 6841cb8..21ebd9e 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -239,7 +239,7 @@ static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,
 
 static void hid_keyboard_process_keycode(HIDState *hs)
 {
-    uint8_t hid_code, key;
+    uint8_t hid_code, index, key;
     int i, keycode, slot;
 
     if (hs->n == 0) {
@@ -249,7 +249,8 @@ static void hid_keyboard_process_keycode(HIDState *hs)
     keycode = hs->kbd.keycodes[slot];
 
     key = keycode & 0x7f;
-    hid_code = hid_usage_keys[key | ((hs->kbd.modifiers >> 1) & (1 << 7))];
+    index = key | ((hs->kbd.modifiers & (1 << 8)) >> 1);
+    hid_code = hid_usage_keys[index];
     hs->kbd.modifiers &= ~(1 << 8);
 
     switch (hid_code) {
@@ -257,18 +258,41 @@ static void hid_keyboard_process_keycode(HIDState *hs)
         return;
 
     case 0xe0:
+        assert(key == 0x1d);
         if (hs->kbd.modifiers & (1 << 9)) {
-            hs->kbd.modifiers ^= 3 << 8;
+            /* The hid_codes for the 0xe1/0x1d scancode sequence are 0xe9/0xe0.
+             * Here we're processing the second hid_code.  By dropping bit 9
+             * and setting bit 8, the scancode after 0x1d will access the
+             * second half of the table.
+             */
+            hs->kbd.modifiers ^= (1 << 8) | (1 << 9);
             return;
         }
+        /* fall through to process Ctrl_L */
     case 0xe1 ... 0xe7:
+        /* Ctrl_L/Ctrl_R, Shift_L/Shift_R, Alt_L/Alt_R, Win_L/Win_R.
+         * Handle releases here, or fall through to process presses.
+         */
         if (keycode & (1 << 7)) {
             hs->kbd.modifiers &= ~(1 << (hid_code & 0x0f));
             return;
         }
-    case 0xe8 ... 0xef:
+        /* fall through */
+    case 0xe8 ... 0xe9:
+        /* USB modifiers are just 1 byte long.  Bits 8 and 9 of
+         * hs->kbd.modifiers implement a state machine that detects the
+         * 0xe0 and 0xe1/0x1d sequences.  These bits do not follow the
+         * usual rules where bit 7 marks released keys; they are cleared
+         * elsewhere in the function as the state machine dictates.
+         */
         hs->kbd.modifiers |= 1 << (hid_code & 0x0f);
         return;
+
+    case 0xea ... 0xef:
+        abort();
+
+    default:
+        break;
     }
 
     if (keycode & (1 << 7)) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4
  2015-07-17  6:52 [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2015-07-17  6:52 ` [Qemu-devel] [PULL 3/3] hid: clarify hid_keyboard_process_keycode Gerd Hoffmann
@ 2015-07-17 11:24 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2015-07-17 11:24 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 17 July 2015 at 07:52, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Dropped the patch to enable virtio-input for non-linux systems.
> Otherwise unmodified.
>
> please pull,
>   Gerd
>
> The following changes since commit 2d5ee9e7a7dd495d233cf9613a865f63f88e3375:
>
>   Merge remote-tracking branch 'remotes/lalrae/tags/mips-20150716' into staging (2015-07-16 10:40:23 +0100)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-input-20150717-1
>
> for you to fetch changes up to 562f93754b95fd6dc65ad9a2aa15a90b2da7e8a4:
>
>   hid: clarify hid_keyboard_process_keycode (2015-07-17 08:44:41 +0200)
>
> ----------------------------------------------------------------
> input: fixes for 2.4

Applied, thanks (you missed rc1, I'm afraid, so these will be in rc2).

-- PMM

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-07-17 11:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-17  6:52 [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Gerd Hoffmann
2015-07-17  6:52 ` [Qemu-devel] [PULL 1/3] virtio-input: fix segfault in virtio_input_hid_properties Gerd Hoffmann
2015-07-17  6:52 ` [Qemu-devel] [PULL 2/3] virtio-input: move sys/ioctl.h include Gerd Hoffmann
2015-07-17  6:52 ` [Qemu-devel] [PULL 3/3] hid: clarify hid_keyboard_process_keycode Gerd Hoffmann
2015-07-17 11:24 ` [Qemu-devel] [PULL v2 for-2.4 0/3] input: fixes for 2.4 Peter Maydell

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).