qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Bauer <mail@sebastianbauer.info>
To: qemu-devel@nongnu.org
Cc: Sebastian Bauer <mail@sebastianbauer.info>
Subject: [Qemu-devel] [PATCH v2] xhci: check speed field of the input context of a set address command.
Date: Fri, 26 Oct 2012 17:41:39 +0200	[thread overview]
Message-ID: <1351266099-5301-1-git-send-email-mail@sebastianbauer.info> (raw)

If the supplied speed data doesn't match the device speed,
return CC_PARAMETER_ERROR. See 6.2.2.1 of the xhci spec.

Signed-off-by: Sebastian Bauer <mail@sebastianbauer.info>
---
Changes v1->v2: Added description to the patch

 hw/usb/hcd-xhci.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 37b3dbb..32a3681 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -1822,6 +1822,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
     uint32_t ictl_ctx[2];
     uint32_t slot_ctx[4];
     uint32_t ep0_ctx[5];
+    uint32_t speed;
     int i;
     TRBCCode res;
 
@@ -1865,6 +1866,15 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
         return CC_USB_TRANSACTION_ERROR;
     }
 
+    /* Check for validness of the input contexts, see 6.2.2.1 */
+    speed = (slot_ctx[0] >> 20) & 0xf;
+    if (speed != uport->dev->speed + 1)
+    {
+        fprintf(stderr,"xhci: invalid device speed in slot context for slot %u (expected %d, got %d).\n",
+                slotid, uport->dev->speed+1, speed);
+        return CC_PARAMETER_ERROR;
+    }
+
     for (i = 0; i < MAXSLOTS; i++) {
         if (xhci->slots[i].uport == uport) {
             fprintf(stderr, "xhci: port %s already assigned to slot %d\n",
-- 
1.7.10.4

                 reply	other threads:[~2012-10-26 15:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1351266099-5301-1-git-send-email-mail@sebastianbauer.info \
    --to=mail@sebastianbauer.info \
    --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 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).