I've installed a SI-PEX40064 SATA controller card
<http://www.sybausa.com/index.php?route=product/product&product_id=156>
in my system that I am trying to use with PCI passthrough via Xen, in
order to give a guest VM its own real SATA controller so as to not
have to deal with virtual disks. Moreover, I want to boot off of a
disk attached to the card.

The card implements (or pretends to implement) AHCI, so SeaBIOS starts
up and can see the attached disk. But SeaBIOS gets a timeout
communicating with the disk:

|eff9d000| WARNING - Timeout at ahci_port_setup:469!
|eff9d000| AHCI/2: device not ready (tf 0x58)

The card has a PCI Option ROM, and I think the Option ROM needs to be
loaded for the card to work and/or be bootable. But SeaBIOS refuses to
load the Option ROM. (My real physical system with Asus EFI firmware
and CSM enabled does load the Option ROM for the card when it is
installed.) I dug into the code, and it looks like it's the same issue
as is mentioned here:

https://mail.coreboot.org/pipermail/seabios/2017-June/011425.html

Basically, a device is not checked for an option ROM (or an
fw_fcg/CBFS-based Option ROM file), and its option ROM is not loaded,
if pci->have_driver is set for the device. That field gets set for
anything that apparently implements AHCI, so the Option ROMs for AHCI
controllers are skipped, even if they are useful. Removing that check
causes the option ROM for my card to be loaded, and allows the
bootloader stored on the disk attached to the card to start up.

I've attached a patch that implements this change, and adds a few more
debug messages to explain what is going on. I haven't observed any
problems with my patched SeaBIOS under Xen, but I'm not sure why the
check was there in the first place (as it wasn't commented), so I
can't speak to the repercussions of disabling it on everyone else's
machines.
From 0e5303f632b03dd8bd93f35b2b6dec32bce29d4f Mon Sep 17 00:00:00 2001
From: Adam Novak <[email protected]>
Date: Sun, 26 Nov 2017 17:44:19 -0800
Subject: [PATCH] Load PCI Option ROMs from devices even if we have a driver
 for them.

---
 src/optionroms.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/optionroms.c b/src/optionroms.c
index 092393a..0137921 100644
--- a/src/optionroms.c
+++ b/src/optionroms.c
@@ -350,8 +350,14 @@ optionrom_setup(void)
     // Find and deploy PCI roms.
     struct pci_device *pci;
     foreachpci(pci) {
-        if (pci->class == PCI_CLASS_DISPLAY_VGA || pci->have_driver)
+        dprintf(5, "Consider PCI bdf %pP (vd %04x:%04x)\n", pci, pci->vendor, pci->device);
+        if (pci->class == PCI_CLASS_DISPLAY_VGA) {
+            dprintf(5, "\tIs a VGA device (VGA ROMs already loaded). Skip.\n");
             continue;
+        }
+        if (pci->have_driver) {
+            dprintf(5, "\tAlready have a driver, but check for ROM anyway\n");
+        }
         init_pcirom(pci, 0, sources);
     }
 
-- 
2.14.1

_______________________________________________
SeaBIOS mailing list
[email protected]
https://mail.coreboot.org/mailman/listinfo/seabios

Reply via email to