On Tue, Sep 03, 2013 at 02:37:41PM +0200, Gerd Hoffmann wrote:
This patch adds support for detecting whenever SeaBIOS runs on qemu or not. This is done by looking at the northbridge (pci device 00:00.0) and check the subsystem id. Most pci devices emulated by qemu -- the two northbridges i440fx and q35 included -- have a subsystem id of "1af4:1100".
In general, it looks sane to me. It does mix the "preinit" phase (on coreboot/qemu) with the "init" phase (on csm). Can the detect just be done in qemu_cfg_init (perhaps renaming it to qemu_init) and that way this detection doesn't need to be done in the preinit phase.
--- a/src/paravirt.c +++ b/src/paravirt.c @@ -19,6 +19,7 @@ #include "acpi.h" // acpi_setup #include "mptable.h" // mptable_setup #include "pci.h" // create_pirtable +#include "pci_regs.h" // create_pirtable #include "xen.h" // xen_biostable_setup
// Amount of continuous ram under 4Gig @@ -33,10 +34,8 @@ int PlatformRunningOn VARFSEG; */ #define KVM_CPUID_SIGNATURE 0x40000000
-static void kvm_preinit(void) +static void kvm_detect(void) {
- if (!CONFIG_QEMU)
unsigned int eax, ebx, ecx, edx; char signature[13];return;
@@ -52,9 +51,43 @@ static void kvm_preinit(void) } }
+void qemu_detect(void) +{
- if (!CONFIG_QEMU_HARDWARE)
return;
- // check northbridge @ 00:00.0
- u16 v = pci_config_readw(0, PCI_VENDOR_ID);
- if (v == 0x0000 || v == 0xffff)
return;
- u16 d = pci_config_readw(0, PCI_DEVICE_ID);
- u16 sv = pci_config_readw(0, PCI_SUBSYSTEM_VENDOR_ID);
- u16 sd = pci_config_readw(0, PCI_SUBSYSTEM_ID);
- if (sv != 0x1af4 || /* Red Hat, Inc */
sd != 0x1100) /* Qemu virtual machine */
return;
- PlatformRunningOn |= PF_QEMU;
Do old versions of QEMU set this also? (If not, there is a corner case where we could have CONFIG_QEMU but PlatformRunningOn != PF_QEMU - I don't think that matters, but it is weird.)
-Kevin