I think we've fairly much decided not to do this, so I'll drop it from
my tree for now. But for archival purposes here it is...
Signed-off-by: David Woodhouse <David.Woodhouse(a)intel.com>
---
src/Kconfig | 16 +++++++---------
src/boot.c | 2 +-
src/paravirt.c | 12 ------------
src/paravirt.h | 6 +-----
src/post.c | 3 ++-
src/shadow.c | 7 +++----
src/xen.c | 29 +++++++++++++++++++++--------
src/xen.h | 4 +++-
8 files changed, 38 insertions(+), 41 deletions(-)
diff --git a/src/Kconfig b/src/Kconfig
index 98a6642..2bef08b 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -14,10 +14,10 @@ choice
Configure as a coreboot payload.
config QEMU
- bool "Build for QEMU/Xen/KVM/Bochs"
+ bool "Build for QEMU/KVM/Bochs"
select QEMU_HARDWARE
help
- Configure for an emulated machine (QEMU, Xen, KVM, or Bochs).
+ Configure for an emulated machine (QEMU, KVM, or Bochs).
config CSM
bool "Build as Compatibilty Support Module for EFI BIOS"
@@ -25,6 +25,11 @@ choice
Configure to be used by EFI firmware as Compatibility Support
module (CSM) to provide legacy BIOS services.
+ config XEN
+ bool "Build for Xen HVM"
+ help
+ Configure to be used by xen hvmloader, for a HVM guest.
+
endchoice
config QEMU_HARDWARE
@@ -34,13 +39,6 @@ endchoice
Support virtual hardware when the code detects it is
running on an emulator.
- config XEN
- depends on QEMU
- bool "Support Xen HVM"
- default y
- help
- Configure to be used by xen hvmloader, for a HVM guest.
-
config THREADS
bool "Parallelize hardware init"
default y
diff --git a/src/boot.c b/src/boot.c
index ec411b7..60c985c 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -250,7 +250,7 @@ boot_init(void)
if (! CONFIG_BOOT)
return;
- if (CONFIG_QEMU) {
+ if (CONFIG_QEMU || CONFIG_XEN) {
// On emulators, get boot order from nvram.
if (inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1)
CheckFloppySig = 0;
diff --git a/src/paravirt.c b/src/paravirt.c
index f061039..5d2ce84 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -58,11 +58,6 @@ qemu_preinit(void)
if (!CONFIG_QEMU)
return;
- if (runningOnXen()) {
- xen_ramsize_preinit();
- return;
- }
-
PlatformRunningOn = PF_QEMU;
kvm_preinit();
@@ -97,13 +92,6 @@ qemu_platform_setup(void)
if (!CONFIG_QEMU)
return;
- if (runningOnXen()) {
- pci_probe_devices();
- xen_hypercall_setup();
- xen_biostable_setup();
- return;
- }
-
// Initialize pci
pci_setup();
smm_setup();
diff --git a/src/paravirt.h b/src/paravirt.h
index fce5af9..8a33af4 100644
--- a/src/paravirt.h
+++ b/src/paravirt.h
@@ -6,8 +6,7 @@
// Types of paravirtualized platforms.
#define PF_QEMU (1<<0)
-#define PF_XEN (1<<1)
-#define PF_KVM (1<<2)
+#define PF_KVM (1<<1)
extern u32 RamSize;
extern u64 RamSizeOver4G;
@@ -17,9 +16,6 @@ static inline int runningOnQEMU(void) {
return CONFIG_QEMU || (
CONFIG_QEMU_HARDWARE && GET_GLOBAL(PlatformRunningOn) & PF_QEMU);
}
-static inline int runningOnXen(void) {
- return CONFIG_XEN && GET_GLOBAL(PlatformRunningOn) & PF_XEN;
-}
static inline int runningOnKVM(void) {
return CONFIG_QEMU && GET_GLOBAL(PlatformRunningOn) & PF_KVM;
}
diff --git a/src/post.c b/src/post.c
index 44bb0b0..977e09d 100644
--- a/src/post.c
+++ b/src/post.c
@@ -294,6 +294,7 @@ dopost(void)
{
// Detect ram and setup internal malloc.
qemu_preinit();
+ xen_preinit();
coreboot_preinit();
malloc_preinit();
@@ -314,7 +315,7 @@ handle_post(void)
dprintf(1, "Start bios (version %s)\n", VERSION);
// Check if we are running under Xen.
- xen_preinit();
+ xen_early_preinit();
// Allow writes to modify bios area (0xf0000)
make_bios_writable();
diff --git a/src/shadow.c b/src/shadow.c
index 0aac60b..467d777 100644
--- a/src/shadow.c
+++ b/src/shadow.c
@@ -10,7 +10,6 @@
#include "config.h" // CONFIG_*
#include "pci_ids.h" // PCI_VENDOR_ID_INTEL
#include "pci_regs.h" // PCI_VENDOR_ID
-#include "paravirt.h" // runningOnXen
#include "dev-q35.h" // PCI_VENDOR_ID_INTEL
// On the emulators, the bios at 0xf0000 is also at 0xffff0000
@@ -119,7 +118,7 @@ static const struct pci_device_id dram_controller_make_readonly_tbl[] = {
void
make_bios_writable(void)
{
- if (!CONFIG_QEMU || runningOnXen())
+ if (!CONFIG_QEMU)
return;
dprintf(3, "enabling shadow ram\n");
@@ -148,7 +147,7 @@ make_bios_writable(void)
void
make_bios_readonly(void)
{
- if (!CONFIG_QEMU || runningOnXen())
+ if (!CONFIG_QEMU)
return;
dprintf(3, "locking shadow ram\n");
@@ -161,7 +160,7 @@ make_bios_readonly(void)
void
qemu_prep_reset(void)
{
- if (!CONFIG_QEMU || runningOnXen())
+ if (!CONFIG_QEMU)
return;
// QEMU doesn't map 0xc0000-0xfffff back to the original rom on a
// reset, so do that manually before invoking a hard reset.
diff --git a/src/xen.c b/src/xen.c
index f5de3d6..78ddfa8 100644
--- a/src/xen.c
+++ b/src/xen.c
@@ -11,6 +11,7 @@
#include "types.h" // ASM32FLAT
#include "util.h" // copy_acpi_rsdp
#include "acpi.h" // find_pmtimer
+#include "pci.h" // pci_probe_devices
#define INFO_PHYSICAL_ADDRESS 0x00001000
@@ -48,7 +49,7 @@ static void validate_info(struct xen_seabios_info *t)
panic("Bad Xen info checksum\n");
}
-void xen_preinit(void)
+void xen_early_preinit(void)
{
u32 base, eax, ebx, ecx, edx;
char signature[13];
@@ -77,11 +78,10 @@ void xen_preinit(void)
break;
}
}
- if (!xen_cpuid_base) {
- dprintf(1, "No Xen hypervisor found.\n");
- return;
- }
- PlatformRunningOn = PF_QEMU|PF_XEN;
+ if (!xen_cpuid_base)
+ panic("No Xen hypervisor found.\n");
+
+ PlatformRunningOn = PF_QEMU;
}
static int hypercall_xen_version( int cmd, void *arg)
@@ -96,7 +96,7 @@ void xen_hypercall_setup(void)
xen_extraversion_t extraversion;
unsigned long i;
- if (!runningOnXen())
+ if (!CONFIG_XEN)
return;
cpuid(xen_cpuid_base + 2, &eax, &ebx, &ecx, &edx);
@@ -129,8 +129,11 @@ void xen_biostable_setup(void)
find_reset_reg();
}
-void xen_ramsize_preinit(void)
+void xen_preinit(void)
{
+ if (!CONFIG_XEN)
+ return;
+
int i;
struct xen_seabios_info *info = (void *)INFO_PHYSICAL_ADDRESS;
struct e820entry *e820 = (struct e820entry *)info->e820;
@@ -143,3 +146,13 @@ void xen_ramsize_preinit(void)
add_e820(e->start, e->size, e->type);
}
}
+
+void xen_platform_setup(void)
+{
+ if (!CONFIG_XEN)
+ return;
+
+ pci_probe_devices();
+ xen_hypercall_setup();
+ xen_biostable_setup();
+}
diff --git a/src/xen.h b/src/xen.h
index f00f840..6a2bdd6 100644
--- a/src/xen.h
+++ b/src/xen.h
@@ -1,10 +1,12 @@
#ifndef __XEN_H
#define __XEN_H
-void xen_preinit(void);
+void xen_early_preinit(void);
void xen_ramsize_preinit(void);
void xen_hypercall_setup(void);
void xen_biostable_setup(void);
+void xen_preinit(void);
+void xen_platform_setup(void);
extern unsigned long xen_hypercall_page;
--
1.8.1.2
--
dwmw2