From: Attilio Rao <attilio.rao@citrix.com>
To: xen-devel@lists.xensource.com
Cc: gbtju85@gmail.com
Subject: [PATCH 1 of 2] Add the support for Xen to include OVMF UEFI support and directly use it
Date: Wed, 22 Feb 2012 19:17:13 +0000 [thread overview]
Message-ID: <032fea10f8d121fe7db0.1329938233@dhcp-3-145.uk.xensource.com> (raw)
In-Reply-To: <patchbomb.1329938232@dhcp-3-145.uk.xensource.com>
when specified in the guest configuration file.
This work is somewhat based on Bei Guan effort during the SoC 2011 and
relies on upstream edk2/ovmf Tianocore ROM to be built separately and
manually copied as:
Build/OvmfX64/DEBUG_GCC44/FV/OVMF.fd -> tools/firmware/ovmf/ovmf-x64.bin
Build/OvmfIa32/DEBUG_GCC44/FV/OVMF.fd -> toolf/firmware/ovmf/ovmf-ia32.bin
A way to integrate OVMF build directly into XEN has still be discussed
on the mailing list appropriately.
Signed-off-by: Attilio Rao <attilio.rao@citrix.com>
diff -r a88ba599add1 -r 032fea10f8d1 Config.mk
--- a/Config.mk Tue Feb 21 17:45:59 2012 +0000
+++ b/Config.mk Wed Feb 22 18:54:03 2012 +0000
@@ -224,6 +224,7 @@ SEABIOS_UPSTREAM_TAG ?= rel-1.6.3.1
ETHERBOOT_NICS ?= rtl8139 8086100e
+CONFIG_OVMF ?= y
CONFIG_ROMBIOS ?= y
CONFIG_SEABIOS ?= y
diff -r a88ba599add1 -r 032fea10f8d1 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Feb 21 17:45:59 2012 +0000
+++ b/tools/firmware/hvmloader/Makefile Wed Feb 22 18:54:03 2012 +0000
@@ -37,6 +37,7 @@ endif
CIRRUSVGA_DEBUG ?= n
+OVMF_DIR := ../ovmf
ROMBIOS_DIR := ../rombios
SEABIOS_DIR := ../seabios-dir
@@ -52,6 +53,14 @@ endif
ROMS :=
+ifeq ($(CONFIG_OVMF),y)
+OBJS += ovmf.o
+CFLAGS += -DENABLE_OVMF32 -DENABLE_OVMF64
+OVMF32_ROM := $(OVMF_DIR)/ovmf-ia32.bin
+OVMF64_ROM := $(OVMF_DIR)/ovmf-x64.bin
+ROMS += $(OVMF32_ROM) $(OVMF64_ROM)
+endif
+
ifeq ($(CONFIG_ROMBIOS),y)
OBJS += optionroms.o 32bitbios_support.o rombios.o
CFLAGS += -DENABLE_ROMBIOS
@@ -70,7 +79,7 @@ endif
all: subdirs-all
$(MAKE) hvmloader
-rombios.o seabios.o hvmloader.o: roms.inc
+ovmf.o rombios.o seabios.o hvmloader.o: roms.inc
smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(shell date +%m/%d/%Y)\""
hvmloader: $(OBJS) acpi/acpi.a
@@ -93,6 +102,18 @@ ifneq ($(SEABIOS_ROM),)
echo "#endif" >> $@.new
endif
+ifneq ($(OVMF32_ROM),)
+ echo "#ifdef ROM_INCLUDE_OVMF32" >> $@.new
+ sh ./mkhex ovmf32 $(OVMF32_ROM) >> $@.new
+ echo "#endif" >> $@.new
+endif
+
+ifneq ($(OVMF64_ROM),)
+ echo "#ifdef ROM_INCLUDE_OVMF64" >> $@.new
+ sh ./mkhex ovmf64 $(OVMF64_ROM) >> $@.new
+ echo "#endif" >> $@.new
+endif
+
ifneq ($(STDVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new
sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> $@.new
diff -r a88ba599add1 -r 032fea10f8d1 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Tue Feb 21 17:45:59 2012 +0000
+++ b/tools/firmware/hvmloader/config.h Wed Feb 22 18:54:03 2012 +0000
@@ -35,6 +35,8 @@ struct bios_config {
extern struct bios_config rombios_config;
extern struct bios_config seabios_config;
+extern struct bios_config ovmf32_config;
+extern struct bios_config ovmf64_config;
#define PAGE_SHIFT 12
#define PAGE_SIZE (1ul << PAGE_SHIFT)
diff -r a88ba599add1 -r 032fea10f8d1 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c Tue Feb 21 17:45:59 2012 +0000
+++ b/tools/firmware/hvmloader/hvmloader.c Wed Feb 22 18:54:03 2012 +0000
@@ -212,6 +212,12 @@ struct bios_info {
#ifdef ENABLE_SEABIOS
{ "seabios", &seabios_config, },
#endif
+#ifdef ENABLE_OVMF32
+ { "ovmf-ia32", &ovmf32_config, },
+#endif
+#ifdef ENABLE_OVMF64
+ { "ovmf-x64", &ovmf64_config, },
+#endif
{ NULL, NULL }
};
diff -r a88ba599add1 -r 032fea10f8d1 tools/firmware/hvmloader/ovmf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/ovmf.c Wed Feb 22 18:54:03 2012 +0000
@@ -0,0 +1,147 @@
+/*
+ * HVM OVMF UEFI support.
+ *
+ * Bei Guan, gbtju85@gmail.com
+ * Andrei Warkentin, andreiw@motorola.com
+ * Leendert van Doorn, leendert@watson.ibm.com
+ * Copyright (c) 2005, International Business Machines Corporation.
+ * Copyright (c) 2006, Keir Fraser, XenSource Inc.
+ * Copyright (c) 2011, Citrix Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "config.h"
+#include "smbios_types.h"
+#include "acpi/acpi2_0.h"
+#include "apic_regs.h"
+#include "../rombios/config.h"
+#include "util.h"
+#include "pci_regs.h"
+#include "hypercall.h"
+
+#include <xen/hvm/params.h>
+#include <xen/hvm/ioreq.h>
+#include <xen/memory.h>
+
+#define ROM_INCLUDE_OVMF32
+#define ROM_INCLUDE_OVMF64
+#include "roms.inc"
+
+#define OVMF_BEGIN 0xFFF00000ULL
+#define OVMF_SIZE 0x00100000ULL
+#define OVMF_MAXOFFSET 0x000FFFFFULL
+#define OVMF_END (OVMF_BEGIN + OVMF_SIZE)
+#define LOWCHUNK_BEGIN 0x000F0000
+#define LOWCHUNK_SIZE 0x00010000
+#define LOWCHUNK_MAXOFFSET 0x0000FFFF
+#define LOWCHUNK_END (OVMF_BEGIN + OVMF_SIZE)
+
+extern unsigned char dsdt_anycpu[], dsdt_15cpu[];
+extern int dsdt_anycpu_len, dsdt_15cpu_len;
+
+static void ovmf_load(const struct bios_config *config)
+{
+ xen_pfn_t mfn;
+ uint64_t addr = OVMF_BEGIN;
+
+ /* Copy low-reset vector portion. */
+ memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image
+ + OVMF_SIZE
+ - LOWCHUNK_SIZE,
+ LOWCHUNK_SIZE);
+
+ /* Ensure we have backing page prior to moving FD. */
+ while ((addr >> PAGE_SHIFT) != (OVMF_END >> PAGE_SHIFT)) {
+ mfn = (uint32_t) (addr >> PAGE_SHIFT);
+ addr += PAGE_SIZE;
+ mem_hole_populate_ram(mfn, 1);
+ }
+
+ /* Copy FD. */
+ memcpy((void *) OVMF_BEGIN, config->image, OVMF_SIZE);
+}
+
+static void ovmf_acpi_build_tables(void)
+{
+ struct acpi_config config = {
+ .dsdt_anycpu = dsdt_anycpu,
+ .dsdt_anycpu_len = dsdt_anycpu_len,
+ .dsdt_15cpu = dsdt_15cpu,
+ .dsdt_15cpu_len = dsdt_15cpu_len,
+ };
+
+ acpi_build_tables(&config, ACPI_PHYSICAL_ADDRESS);
+}
+
+static void ovmf_create_smbios_tables(void)
+{
+ hvm_write_smbios_tables(SMBIOS_PHYSICAL_ADDRESS,
+ SMBIOS_PHYSICAL_ADDRESS + sizeof(struct smbios_entry_point),
+ SMBIOS_PHYSICAL_END);
+}
+
+struct bios_config ovmf32_config = {
+ .name = "OVMF-IA32",
+
+ .image = ovmf32,
+ .image_size = sizeof(ovmf32),
+
+ .bios_address = 0,
+ .bios_load = ovmf_load,
+
+ .load_roms = 0,
+
+ .bios_info_setup = NULL,
+ .bios_info_finish = NULL,
+
+ .e820_setup = NULL,
+
+ .acpi_build_tables = ovmf_acpi_build_tables,
+ .create_mp_tables = NULL,
+ .create_smbios_tables = ovmf_create_smbios_tables,
+ .create_pir_tables = NULL,
+};
+
+struct bios_config ovmf64_config = {
+ .name = "OVMF-X64",
+
+ .image = ovmf64,
+ .image_size = sizeof(ovmf64),
+
+ .bios_address = 0,
+ .bios_load = ovmf_load,
+
+ .load_roms = 0,
+
+ .bios_info_setup = NULL,
+ .bios_info_finish = NULL,
+
+ .e820_setup = NULL,
+
+ .acpi_build_tables = ovmf_acpi_build_tables,
+ .create_mp_tables = NULL,
+ .create_smbios_tables = ovmf_create_smbios_tables,
+ .create_pir_tables = NULL,
+};
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
next prev parent reply other threads:[~2012-02-22 19:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-22 19:17 [PATCH 0 of 2] Add the OVMF UEFI support to hvmloader Attilio Rao
2012-02-22 19:17 ` Attilio Rao [this message]
2012-02-23 10:07 ` [PATCH 1 of 2] Add the support for Xen to include OVMF UEFI support and directly use it Ian Campbell
2012-02-23 10:18 ` Attilio Rao
2012-02-23 10:44 ` Ian Campbell
2012-02-23 14:48 ` Jan Beulich
2012-02-23 15:37 ` Ian Campbell
2012-02-23 17:33 ` Jordan Justen
2012-02-24 8:45 ` Ian Campbell
2012-02-24 8:35 ` Jan Beulich
2012-02-24 8:43 ` Ian Campbell
2012-02-24 8:50 ` Jan Beulich
2012-02-23 16:21 ` Jordan Justen
2012-02-23 16:36 ` Ian Campbell
2012-02-23 10:13 ` Keir Fraser
2012-02-22 19:17 ` [PATCH 2 of 2] Add the ability to specify the option "bios_override" in the guest Attilio Rao
2012-02-23 10:13 ` Ian Campbell
2012-02-23 10:31 ` Attilio Rao
2012-02-23 10:46 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=032fea10f8d121fe7db0.1329938233@dhcp-3-145.uk.xensource.com \
--to=attilio.rao@citrix.com \
--cc=gbtju85@gmail.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).