All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/3] Usb 20210528 patches
@ 2021-05-28 14:21 Gerd Hoffmann
  2021-05-28 14:22 ` [PULL 1/3] hw/input/hid: Add support for keys of jp106 keyboard Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2021-05-28 14:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

The following changes since commit c8616fc7670b884de5f74d2767aade224c1c5c3a:

  Merge remote-tracking branch 'remotes/philmd/tags/gitlab-ci-20210527' into staging (2021-05-27 16:32:57 +0100)

are available in the Git repository at:

  git://git.kraxel.org/qemu tags/usb-20210528-pull-request

for you to fetch changes up to fc967aad408eb4777b099d17ada1f39be5f6fd2e:

  hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X (2021-05-28 09:10:20 +0200)

----------------------------------------------------------------
usb: bugfixes for hid and xhci.

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

Katsuhiro Ueno (1):
  hw/input/hid: Add support for keys of jp106 keyboard.

Ruimei Yan (2):
  hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to
  hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X

 hw/usb/hcd-xhci.h        |  2 +-
 hw/input/hid.c           |  4 ++--
 hw/usb/hcd-xhci-pci.c    | 13 ++++++++-----
 hw/usb/hcd-xhci-sysbus.c |  4 +++-
 hw/usb/hcd-xhci.c        |  8 ++++++--
 5 files changed, 20 insertions(+), 11 deletions(-)

-- 
2.31.1




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

* [PULL 1/3] hw/input/hid: Add support for keys of jp106 keyboard.
  2021-05-28 14:21 [PULL 0/3] Usb 20210528 patches Gerd Hoffmann
@ 2021-05-28 14:22 ` Gerd Hoffmann
  2021-05-28 14:22 ` [PULL 2/3] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2021-05-28 14:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Katsuhiro Ueno

From: Katsuhiro Ueno <uenobk@gmail.com>

Add support for the following keys: KATAKANAHIRAGANA, HENKAN, MUHENKAN,
RO, and YEN.  Before this commit, these keys did not work as expected
when a jp106 keyboard was connected to the guest as a usb-kbd device.

Signed-off-by: Katsuhiro Ueno <uenobk@gmail.com>
Message-Id: <CA+pCdY3iG+pKKQqEVknnWF-W0wK36S4U1jxPvxmGAPp6FFvz1Q@mail.gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/hid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/input/hid.c b/hw/input/hid.c
index e1d2e4608374..8aab0521f405 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -51,8 +51,8 @@ static const uint8_t hid_usage_keys[0x100] = {
     0x45, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
     0xe8, 0xe9, 0x71, 0x72, 0x73, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0xe3, 0xe7, 0x65,
+    0x88, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x8a, 0x00, 0x8b, 0x00, 0x89, 0xe7, 0x65,
 
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-- 
2.31.1



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

* [PULL 2/3] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to
  2021-05-28 14:21 [PULL 0/3] Usb 20210528 patches Gerd Hoffmann
  2021-05-28 14:22 ` [PULL 1/3] hw/input/hid: Add support for keys of jp106 keyboard Gerd Hoffmann
@ 2021-05-28 14:22 ` Gerd Hoffmann
  2021-05-31 15:32   ` Alexander Bulekov
  2021-05-28 14:22 ` [PULL 3/3] hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X Gerd Hoffmann
  2021-05-30 21:46 ` [PULL 0/3] Usb 20210528 patches Peter Maydell
  3 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2021-05-28 14:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Bin Meng, Ruimei Yan, Gerd Hoffmann

From: Ruimei Yan <ruimei.yan@windriver.com>

At present MSI / MSI-X interrupts are triggered regardless of the
irq level. We should have checked the level to determine whether
the interrupt needs to be delivered.

The level check logic was present in early versions of the xhci
model, but got dropped later by a rework of interrupt handling
under commit 4c4abe7cc903 ("xhci: rework interrupt handling").

Fixes: 4c4abe7cc903 ("xhci: rework interrupt handling")
Signed-off-by: Ruimei Yan <ruimei.yan@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Message-Id: <20210521024224.2277634-1-bmeng.cn@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-xhci-pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index 9421734d0fe2..b6acd1790c1a 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -67,12 +67,13 @@ static void xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
          msi_enabled(pci_dev))) {
         pci_set_irq(pci_dev, level);
     }
-    if (msix_enabled(pci_dev)) {
+
+    if (msix_enabled(pci_dev) && level) {
         msix_notify(pci_dev, n);
         return;
     }
 
-    if (msi_enabled(pci_dev)) {
+    if (msi_enabled(pci_dev) && level) {
         msi_notify(pci_dev, n);
         return;
     }
-- 
2.31.1



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

* [PULL 3/3] hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X
  2021-05-28 14:21 [PULL 0/3] Usb 20210528 patches Gerd Hoffmann
  2021-05-28 14:22 ` [PULL 1/3] hw/input/hid: Add support for keys of jp106 keyboard Gerd Hoffmann
  2021-05-28 14:22 ` [PULL 2/3] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to Gerd Hoffmann
@ 2021-05-28 14:22 ` Gerd Hoffmann
  2021-05-30 21:46 ` [PULL 0/3] Usb 20210528 patches Peter Maydell
  3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2021-05-28 14:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Bin Meng, Ruimei Yan, Gerd Hoffmann

From: Ruimei Yan <ruimei.yan@windriver.com>

Per xHCI spec v1.2 chapter 4.17.5 page 296:

  If MSI or MSI-X interrupts are enabled, Interrupt Pending (IP)
  shall be cleared automatically when the PCI dword write generated
  by the interrupt assertion is complete.

Currently QEMU does not clear the IP flag in the MSI / MSI-X mode.
This causes subsequent spurious interrupt to be delivered to guests.
To solve this, we change the xhci intr_raise() hook routine to have
a bool return value that is passed to its caller (the xhci core),
with true indicating that IP should be self-cleared.

Fixes: 62c6ae04cf43 ("xhci: Initial xHCI implementation")
Fixes: 4c47f800631a ("xhci: add msix support")
Signed-off-by: Ruimei Yan <ruimei.yan@windriver.com>
[bmeng: move IP clear codes from xhci pci to xhci core]
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Message-Id: <20210521024224.2277634-2-bmeng.cn@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-xhci.h        | 2 +-
 hw/usb/hcd-xhci-pci.c    | 8 +++++---
 hw/usb/hcd-xhci-sysbus.c | 4 +++-
 hw/usb/hcd-xhci.c        | 8 ++++++--
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index 7bba361f3bbd..98f598382adc 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -194,7 +194,7 @@ typedef struct XHCIState {
     uint32_t flags;
     uint32_t max_pstreams_mask;
     void (*intr_update)(XHCIState *s, int n, bool enable);
-    void (*intr_raise)(XHCIState *s, int n, bool level);
+    bool (*intr_raise)(XHCIState *s, int n, bool level);
     DeviceState *hostOpaque;
 
     /* Operational Registers */
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index b6acd1790c1a..e934b1a5b1fb 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -57,7 +57,7 @@ static void xhci_pci_intr_update(XHCIState *xhci, int n, bool enable)
     }
 }
 
-static void xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
+static bool xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
 {
     XHCIPciState *s = container_of(xhci, XHCIPciState, xhci);
     PCIDevice *pci_dev = PCI_DEVICE(s);
@@ -70,13 +70,15 @@ static void xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
 
     if (msix_enabled(pci_dev) && level) {
         msix_notify(pci_dev, n);
-        return;
+        return true;
     }
 
     if (msi_enabled(pci_dev) && level) {
         msi_notify(pci_dev, n);
-        return;
+        return true;
     }
+
+    return false;
 }
 
 static void xhci_pci_reset(DeviceState *dev)
diff --git a/hw/usb/hcd-xhci-sysbus.c b/hw/usb/hcd-xhci-sysbus.c
index 42e2574c8298..a14e4381960e 100644
--- a/hw/usb/hcd-xhci-sysbus.c
+++ b/hw/usb/hcd-xhci-sysbus.c
@@ -16,11 +16,13 @@
 #include "hw/acpi/aml-build.h"
 #include "hw/irq.h"
 
-static void xhci_sysbus_intr_raise(XHCIState *xhci, int n, bool level)
+static bool xhci_sysbus_intr_raise(XHCIState *xhci, int n, bool level)
 {
     XHCISysbusState *s = container_of(xhci, XHCISysbusState, xhci);
 
     qemu_set_irq(s->irq[n], level);
+
+    return false;
 }
 
 void xhci_sysbus_reset(DeviceState *dev)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 46212b1e695a..e01700039b13 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -551,7 +551,9 @@ static void xhci_intr_update(XHCIState *xhci, int v)
             level = 1;
         }
         if (xhci->intr_raise) {
-            xhci->intr_raise(xhci, 0, level);
+            if (xhci->intr_raise(xhci, 0, level)) {
+                xhci->intr[0].iman &= ~IMAN_IP;
+            }
         }
     }
     if (xhci->intr_update) {
@@ -579,7 +581,9 @@ static void xhci_intr_raise(XHCIState *xhci, int v)
         return;
     }
     if (xhci->intr_raise) {
-        xhci->intr_raise(xhci, v, true);
+        if (xhci->intr_raise(xhci, v, true)) {
+            xhci->intr[v].iman &= ~IMAN_IP;
+        }
     }
 }
 
-- 
2.31.1



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

* Re: [PULL 0/3] Usb 20210528 patches
  2021-05-28 14:21 [PULL 0/3] Usb 20210528 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2021-05-28 14:22 ` [PULL 3/3] hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X Gerd Hoffmann
@ 2021-05-30 21:46 ` Peter Maydell
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2021-05-30 21:46 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On Fri, 28 May 2021 at 15:24, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> The following changes since commit c8616fc7670b884de5f74d2767aade224c1c5c3a:
>
>   Merge remote-tracking branch 'remotes/philmd/tags/gitlab-ci-20210527' into staging (2021-05-27 16:32:57 +0100)
>
> are available in the Git repository at:
>
>   git://git.kraxel.org/qemu tags/usb-20210528-pull-request
>
> for you to fetch changes up to fc967aad408eb4777b099d17ada1f39be5f6fd2e:
>
>   hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X (2021-05-28 09:10:20 +0200)
>
> ----------------------------------------------------------------
> usb: bugfixes for hid and xhci.
>
> ----------------------------------------------------------------


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.

-- PMM


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

* Re: [PULL 2/3] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to
  2021-05-28 14:22 ` [PULL 2/3] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to Gerd Hoffmann
@ 2021-05-31 15:32   ` Alexander Bulekov
  2021-06-01  6:44     ` Bin Meng
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Bulekov @ 2021-05-31 15:32 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Ruimei Yan, Bin Meng, Philippe Mathieu-Daudé, qemu-devel

On 210528 1622, Gerd Hoffmann wrote:
> From: Ruimei Yan <ruimei.yan@windriver.com>
> 
> At present MSI / MSI-X interrupts are triggered regardless of the
> irq level. We should have checked the level to determine whether
> the interrupt needs to be delivered.
> 
> The level check logic was present in early versions of the xhci
> model, but got dropped later by a rework of interrupt handling
> under commit 4c4abe7cc903 ("xhci: rework interrupt handling").
> 
> Fixes: 4c4abe7cc903 ("xhci: rework interrupt handling")
> Signed-off-by: Ruimei Yan <ruimei.yan@windriver.com>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Message-Id: <20210521024224.2277634-1-bmeng.cn@gmail.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Hi,
FYI, OSS-Fuzz detected that this fixed this stack-overflow:
https://bugs.launchpad.net/bugs/1905444
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27796#c5
-Alex


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

* Re: [PULL 2/3] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to
  2021-05-31 15:32   ` Alexander Bulekov
@ 2021-06-01  6:44     ` Bin Meng
  0 siblings, 0 replies; 7+ messages in thread
From: Bin Meng @ 2021-06-01  6:44 UTC (permalink / raw)
  To: Alexander Bulekov
  Cc: Philippe Mathieu-Daudé,
	Bin Meng, Ruimei Yan, Gerd Hoffmann,
	qemu-devel@nongnu.org Developers

On Mon, May 31, 2021 at 11:33 PM Alexander Bulekov <alxndr@bu.edu> wrote:
>
> On 210528 1622, Gerd Hoffmann wrote:
> > From: Ruimei Yan <ruimei.yan@windriver.com>
> >
> > At present MSI / MSI-X interrupts are triggered regardless of the
> > irq level. We should have checked the level to determine whether
> > the interrupt needs to be delivered.
> >
> > The level check logic was present in early versions of the xhci
> > model, but got dropped later by a rework of interrupt handling
> > under commit 4c4abe7cc903 ("xhci: rework interrupt handling").
> >
> > Fixes: 4c4abe7cc903 ("xhci: rework interrupt handling")
> > Signed-off-by: Ruimei Yan <ruimei.yan@windriver.com>
> > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > Message-Id: <20210521024224.2277634-1-bmeng.cn@gmail.com>
> > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>
> Hi,
> FYI, OSS-Fuzz detected that this fixed this stack-overflow:
> https://bugs.launchpad.net/bugs/1905444
> https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27796#c5

Good to know :)

Regards,
Bin


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

end of thread, other threads:[~2021-06-01  6:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 14:21 [PULL 0/3] Usb 20210528 patches Gerd Hoffmann
2021-05-28 14:22 ` [PULL 1/3] hw/input/hid: Add support for keys of jp106 keyboard Gerd Hoffmann
2021-05-28 14:22 ` [PULL 2/3] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to Gerd Hoffmann
2021-05-31 15:32   ` Alexander Bulekov
2021-06-01  6:44     ` Bin Meng
2021-05-28 14:22 ` [PULL 3/3] hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X Gerd Hoffmann
2021-05-30 21:46 ` [PULL 0/3] Usb 20210528 patches Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.