All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] usb: uhci: Look up queue by address, not token
Date: Thu, 15 Nov 2012 09:20:39 +0100	[thread overview]
Message-ID: <50A4A5D7.8030508@siemens.com> (raw)

The queue token is insufficient to identify if a TD belongs to it. What
we need is the QH address.

This fixes the case where the guest issues multiple asynchronous
requests for the same EP.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

I'm not 100% this still fulfills the aim of "Verify queue has not been
changed by guest". On the other hand, the current code looks quite
wrong to me after studying the spec for a while.

 hw/usb/hcd-uhci.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index f4b555a..1434a3a 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -227,13 +227,12 @@ static void uhci_queue_free(UHCIQueue *queue, const char *reason)
     g_free(queue);
 }
 
-static UHCIQueue *uhci_queue_find(UHCIState *s, UHCI_TD *td)
+static UHCIQueue *uhci_queue_find(UHCIState *s, uint32_t qh_addr)
 {
-    uint32_t token = uhci_queue_token(td);
     UHCIQueue *queue;
 
     QTAILQ_FOREACH(queue, &s->queues, next) {
-        if (queue->token == token) {
+        if (queue->qh_addr == qh_addr) {
             return queue;
         }
     }
@@ -841,7 +840,7 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr,
     }
 
     if (q == NULL) {
-        q = uhci_queue_find(s, td);
+        q = uhci_queue_find(s, qh_addr);
         if (q && !uhci_queue_verify(q, qh_addr, td, td_addr, queuing)) {
             uhci_queue_free(q, "guest re-used qh");
             q = NULL;
-- 
1.7.3.4

             reply	other threads:[~2012-11-15  8:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15  8:20 Jan Kiszka [this message]
2012-11-15  8:30 ` [Qemu-devel] [PATCH] usb: uhci: Look up queue by address, not token Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50A4A5D7.8030508@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=hdegoede@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.