Skip to contentSkip to conversation

Fix latent(?) bootindex bugs

PATCH Applied Markus Armbruster 4 participants 7 messages Aug 15, 2014 – Aug 26, 2014

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 usb: Fix bootindex for portnr > 9

In reply to Markus Armbruster

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

---
 hw/usb/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/bus.c +2 -2
index 927a47b..516fb52 100644
@@ -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;
         }
Signature · 1 line
1.9.3
#0 lore raw

cover Fix latent(?) bootindex bugs

I put (?) behind latent, because I didn't actually prove the reason it can't bite USB I put forward in PATCH 1.

PATCH 1 should be picked up by the USB maintainer (Kraxel), and PATCH 2 by a block maintainer (Kevin or Stefan). I'm posting this as a series regardless, because I want them reviewed together.

Related: [SeaBIOS] [PATCH v3] boot: Fix boot order for SCSI target, lun > 9
http://www.seabios.org/pipermail/seabios/2014-August/008205.html
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1096560

Markus Armbruster (2):
usb: Fix bootindex for portnr > 9
ide: Fix bootindex for bus_id > 9

 hw/ide/qdev.c | 2 +-
 hw/usb/bus.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.3
#4 lore raw

PATCH 2/2 ide: Fix bootindex for bus_id > 9

We identify devices by their Open Firmware device paths. The encoding of bus numbers is incorrect: idebus_get_fw_dev_path() formats them in decimal, while SeaBIOS uses hexadecimal. With bus number > 9, SeaBIOS will miss the bootindex (lucky case), or apply it to another device (unlucky case).

Bug can't bite right now: ich9-ahci has six ports, and the sysbus-ahci created by Calxeda Highbank has just one.

Fix it anyway, by changing %d to %x.

I couldn't find an Open Firmware spec covering this. For what it's worth, OVMF agrees with SeaBIOS.

---
 hw/ide/qdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/qdev.c +1 -1
index 6e475e6..9c4d221 100644
@@ -59,7 +59,7 @@ static char *idebus_get_fw_dev_path(DeviceState *dev)
 {
     char path[30];
 
-    snprintf(path, sizeof(path), "%s@%d", qdev_fw_name(dev),
+    snprintf(path, sizeof(path), "%s@%x", qdev_fw_name(dev),
              ((IDEBus*)dev->parent_bus)->bus_id);
 
     return g_strdup(path);
Signature · 1 line
1.9.3
Reviewed-by on the v1 series
#6 lore raw
In reply to Markus Armbruster
Quoted 12 lines · Markus Armbruster

I put (?) behind latent, because I didn't actually prove the reason it can't bite USB I put forward in PATCH 1.

PATCH 1 should be picked up by the USB maintainer (Kraxel), and PATCH 2 by a block maintainer (Kevin or Stefan). I'm posting this as a series regardless, because I want them reviewed together.

Related: [SeaBIOS] [PATCH v3] boot: Fix boot order for SCSI target, lun > 9
http://www.seabios.org/pipermail/seabios/2014-August/008205.html
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1096560

Quoted 8 lines

Markus Armbruster (2):
usb: Fix bootindex for portnr > 9
ide: Fix bootindex for bus_id > 9

 hw/ide/qdev.c | 2 +-
 hw/usb/bus.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

series

#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] usb: Fix bootindex for portnr > 9

In reply to Markus Armbruster
Quoted 11 lines · Markus Armbruster

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.

fyi: xhci can be configured with up to 15 ports (default is 4 ports though).

Applied to usb patch queue.

thanks,
Gerd

#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] usb: Fix bootindex for portnr > 9

Quoted 7 lines · Gerd Hoffmann
Quoted 6 lines · Markus Armbruster

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).

Quoted 8 lines
Quoted 5 lines

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.

fyi: xhci can be configured with up to 15 ports (default is 4 ports though).

Would be nice to put that into the commit message, between my S-o-B and yours.

Quoted 1 line

Applied to usb patch queue.

Thanks!

#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] ide: Fix bootindex for bus_id > 9

In reply to Markus Armbruster
Quoted 11 lines · Markus Armbruster

We identify devices by their Open Firmware device paths. The encoding of bus numbers is incorrect: idebus_get_fw_dev_path() formats them in decimal, while SeaBIOS uses hexadecimal. With bus number > 9, SeaBIOS will miss the bootindex (lucky case), or apply it to another device (unlucky case).

Bug can't bite right now: ich9-ahci has six ports, and the sysbus-ahci created by Calxeda Highbank has just one.

Fix it anyway, by changing %d to %x.

Quoted 7 lines

I couldn't find an Open Firmware spec covering this. For what it's worth, OVMF agrees with SeaBIOS.

---
 hw/ide/qdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan