From 830cd54fca126f5dab9b34b48a61304f2401e982 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 15 Aug 2014 13:32:36 +0200 Subject: [PATCH] usb: Fix bootindex for portnr > 9 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 Reviewed-by: Laszlo Ersek Note: xhci can be configured with up to 15 ports (default is 4 ports). Signed-off-by: Gerd Hoffmann --- 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; } -- 2.7.4