qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, lersek@redhat.com, kraxel@redhat.com,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] usb: Fix bootindex for portnr > 9
Date: Fri, 15 Aug 2014 13:32:36 +0200	[thread overview]
Message-ID: <1408102357-914-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1408102357-914-1-git-send-email-armbru@redhat.com>

We identify devices by their Open Firmware device paths.  The encoding
of the host controller and hub port numbers is incorrect:
usb_get_fw_dev_path() formats them in decimal, while SeaBIOS uses
hexadecimal.  When some port number > 9, SeaBIOS will miss the
bootindex (lucky case), or apply it to another device (unlucky case).

The relevant spec[*] agrees with SeaBIOS (and OVMF, for that matter).
Change %d to %x.

Bug can bite only with host controllers or hubs sporting more than ten
ports.  I'm not aware of any.

[*] Open Firmware Recommended Practice: Universal Serial Bus,
Version 1, Section 3.2.1 Device Node Address Representation
http://www.openfirmware.org/1275/bindings/usb/usb-1_0.ps

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/usb/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 927a47b..516fb52 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -589,11 +589,11 @@ static char *usb_get_fw_dev_path(DeviceState *qdev)
         nr = strtol(in, &in, 10);
         if (in[0] == '.') {
             /* some hub between root port and device */
-            pos += snprintf(fw_path + pos, fw_len - pos, "hub@%ld/", nr);
+            pos += snprintf(fw_path + pos, fw_len - pos, "hub@%lx/", nr);
             in++;
         } else {
             /* the device itself */
-            pos += snprintf(fw_path + pos, fw_len - pos, "%s@%ld",
+            pos += snprintf(fw_path + pos, fw_len - pos, "%s@%lx",
                             qdev_fw_name(qdev), nr);
             break;
         }
-- 
1.9.3

  reply	other threads:[~2014-08-15 11:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-15 11:32 [Qemu-devel] [PATCH 0/2] Fix latent(?) bootindex bugs Markus Armbruster
2014-08-15 11:32 ` Markus Armbruster [this message]
2014-08-25 12:48   ` [Qemu-devel] [PATCH 1/2] usb: Fix bootindex for portnr > 9 Gerd Hoffmann
2014-08-25 14:33     ` Markus Armbruster
2014-08-15 11:32 ` [Qemu-devel] [PATCH 2/2] ide: Fix bootindex for bus_id " Markus Armbruster
2014-08-26 10:51   ` Stefan Hajnoczi
2014-08-15 11:55 ` [Qemu-devel] [PATCH 0/2] Fix latent(?) bootindex bugs Laszlo Ersek

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=1408102357-914-2-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).