The make_bios_readonly() call is invoked from resume. The PCIDevices list is only valid during POST. Cache the necessary PCI BDF ids so that PCIDevices isn't needed.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/shadow.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/src/shadow.c b/src/shadow.c index e971fe9..967eb8e 100644 --- a/src/shadow.c +++ b/src/shadow.c @@ -97,23 +97,7 @@ make_bios_readonly_intel(u16 bdf, u32 pam0) pci_config_writeb(bdf, pam0, 0x10); }
-static void i440fx_bios_make_readonly(struct pci_device *pci, void *arg) -{ - make_bios_readonly_intel(pci->bdf, I440FX_PAM0); -} - -void mch_bios_make_readonly(struct pci_device *pci, void *arg) -{ - make_bios_readonly_intel(pci->bdf, Q35_HOST_BRIDGE_PAM0); -} - -static const struct pci_device_id dram_controller_make_readonly_tbl[] = { - PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, - i440fx_bios_make_readonly), - PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_Q35_MCH, - mch_bios_make_readonly), - PCI_DEVICE_END -}; +static int ShadowBDF = -1;
// Make the 0xc0000-0x100000 area read/writable. void @@ -133,11 +117,13 @@ make_bios_writable(void) if (vendor == PCI_VENDOR_ID_INTEL && device == PCI_DEVICE_ID_INTEL_82441) { make_bios_writable_intel(bdf, I440FX_PAM0); + ShadowBDF = bdf; return; } if (vendor == PCI_VENDOR_ID_INTEL && device == PCI_DEVICE_ID_INTEL_Q35_MCH) { make_bios_writable_intel(bdf, Q35_HOST_BRIDGE_PAM0); + ShadowBDF = bdf; return; } } @@ -150,12 +136,18 @@ make_bios_readonly(void) { if (!CONFIG_QEMU || runningOnXen()) return; - dprintf(3, "locking shadow ram\n"); - struct pci_device *pci = pci_find_init_device( - dram_controller_make_readonly_tbl, NULL); - if (!pci) + + if (ShadowBDF < 0) { dprintf(1, "Unable to lock ram - bridge not found\n"); + return; + } + + u16 device = pci_config_readw(ShadowBDF, PCI_DEVICE_ID); + if (device == PCI_DEVICE_ID_INTEL_82441) + make_bios_readonly_intel(ShadowBDF, I440FX_PAM0); + else + make_bios_readonly_intel(ShadowBDF, Q35_HOST_BRIDGE_PAM0); }
void