aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-09-03 11:41:01 +0200
committerGerd Hoffmann <kraxel@redhat.com>2013-09-19 11:48:59 +0200
commitebfece8e85d18190846c622d540e8aa96303ca31 (patch)
treedb576e8a30b9618acdbf996c9597fae6627f0396
parentb367e0ab76f3ee77bb30371ab6b84553e6113aed (diff)
downloadseabios-ebfece8e85d18190846c622d540e8aa96303ca31.tar.gz
Add generic qemu detection
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 case the subsystem ID matches set PF_QEMU, log a message (including the northbridge found while being at it) and also check for kvm. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--src/fw/paravirt.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c
index 2524b7b..357de56 100644
--- a/src/fw/paravirt.c
+++ b/src/fw/paravirt.c
@@ -12,6 +12,7 @@
#include "config.h" // CONFIG_QEMU
#include "hw/cmos.h" // CMOS_*
#include "hw/pci.h" // create_pirtable
+#include "hw/pci_regs.h" // PCI_DEVICE_ID
#include "ioport.h" // outw
#include "malloc.h" // malloc_tmp
#include "memmap.h" // add_e820
@@ -35,10 +36,8 @@ int PlatformRunningOn VARFSEG;
*/
#define KVM_CPUID_SIGNATURE 0x40000000
-static void kvm_preinit(void)
+static void kvm_detect(void)
{
- if (!CONFIG_QEMU)
- return;
unsigned int eax, ebx, ecx, edx;
char signature[13];
@@ -54,9 +53,43 @@ static void kvm_preinit(void)
}
}
+static 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;
+ switch (d) {
+ case 0x1237:
+ dprintf(1, "Running on QEMU (i440fx)\n");
+ break;
+ case 0x29c0:
+ dprintf(1, "Running on QEMU (q35)\n");
+ break;
+ default:
+ dprintf(1, "Running on QEMU (unknown nb: %04x:%04x)\n", v, d);
+ break;
+ }
+ kvm_detect();
+}
+
void
qemu_preinit(void)
{
+ qemu_detect();
+
if (!CONFIG_QEMU)
return;
@@ -65,8 +98,11 @@ qemu_preinit(void)
return;
}
- PlatformRunningOn = PF_QEMU;
- kvm_preinit();
+ if (!runningOnQEMU()) {
+ dprintf(1, "Warning: No QEMU Northbridge found (isapc?)\n");
+ PlatformRunningOn |= PF_QEMU;
+ kvm_detect();
+ }
// On emulators, get memory size from nvram.
u32 rs = ((inb_cmos(CMOS_MEM_EXTMEM2_LOW) << 16)