On Di, 2013-09-03 at 21:28 -0400, Kevin O'Connor wrote:
On Tue, Sep 03, 2013 at 02:37:41PM +0200, Gerd
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
In general, it looks sane to me. It does mix the "preinit" phase (on
coreboot/qemu) with the "init" phase (on csm).
There is no preinit 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.
I'd like to do this as early as possible, because one of the things this
enables is logging via qemu debug port (CONFIG_DEBUG_IO).
Also note that preinit has a runningOnKvm() call, and we'll better do
the checks for qemu and kvm beforehand.
@@ -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;
@@ -52,9 +51,43 @@ static void kvm_preinit(void)
+ if (!CONFIG_QEMU_HARDWARE)
+ // check northbridge @ 00:00.0
+ u16 v = pci_config_readw(0, PCI_VENDOR_ID);
+ if (v == 0x0000 || v == 0xffff)
+ 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 */
+ 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.)
Added by qemu commit d350d97d196a632b6c7493acf07a061017fc6f7d (Dec
2008), qemu version 0.10.0 + newer have this.