xen/0008-hvmloader-Locate-the-BIOS-blob.patch
Charles Arnold 92ed83b0e8 - Add patches from proposed upstream series to load BIOS's from
the toolstack instead of embedding in hvmloader
  http://lists.xenproject.org/archives/html/xen-devel/2016-03/msg01626.html
  0001-libxc-Rework-extra-module-initialisation.patch,
  0002-libxc-Prepare-a-start-info-structure-for-hvmloader.patch,
  0003-configure-define-SEABIOS_PATH-and-OVMF_PATH.patch,
  0004-firmware-makefile-install-BIOS-blob.patch,
  0005-libxl-Load-guest-BIOS-from-file.patch,
  0006-xen-Move-the-hvm_start_info-C-representation-from-li.patch,
  0007-hvmloader-Grab-the-hvm_start_info-pointer.patch,
  0008-hvmloader-Locate-the-BIOS-blob.patch,
  0009-hvmloader-Check-modules-whereabouts-in-perform_tests.patch,
  0010-hvmloader-Load-SeaBIOS-from-hvm_start_info-modules.patch,
  0011-hvmloader-Load-OVMF-from-modules.patch,
  0012-hvmloader-Specific-bios_load-function-required.patch,
  0013-hvmloader-Always-build-in-SeaBIOS-and-OVMF-loader.patch,
  0014-configure-do-not-depend-on-SEABIOS_PATH-or-OVMF_PATH.patch
- Enable support for UEFI on x86_64 using the ovmf-x86_64-ms.bin
  firmware from qemu-ovmf-x86_64. The firmware is preloaded with
  Microsoft keys to more closely resemble firmware on real hardware
  FATE#320490

OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=416
2016-04-13 19:43:10 +00:00

140 lines
4.8 KiB
Diff

From 463aedc4fd6e09518b4711e931048bf932b6ee39 Mon Sep 17 00:00:00 2001
From: Anthony PERARD <anthony.perard@citrix.com>
Date: Mon, 14 Mar 2016 17:55:43 +0000
Subject: [PATCH 08/15] hvmloader: Locate the BIOS blob
The BIOS can be found an entry called "bios" of the modlist of the
hvm_start_info struct.
The found BIOS blob is not loaded by this patch, but only passed as
argument to bios_load() function. It is going to be used by the next few
patches.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
tools/firmware/hvmloader/config.h | 2 +-
tools/firmware/hvmloader/hvmloader.c | 42 ++++++++++++++++++++++++++++++++++--
tools/firmware/hvmloader/ovmf.c | 3 ++-
tools/firmware/hvmloader/rombios.c | 3 ++-
tools/firmware/hvmloader/util.h | 2 ++
5 files changed, 47 insertions(+), 5 deletions(-)
Index: xen-4.7.0-testing/tools/firmware/hvmloader/config.h
===================================================================
--- xen-4.7.0-testing.orig/tools/firmware/hvmloader/config.h
+++ xen-4.7.0-testing/tools/firmware/hvmloader/config.h
@@ -22,7 +22,7 @@ struct bios_config {
/* ROMS */
void (*load_roms)(void);
- void (*bios_load)(const struct bios_config *config);
+ void (*bios_load)(const struct bios_config *config, void *addr, uint32_t size);
void (*bios_info_setup)(void);
void (*bios_info_finish)(void);
Index: xen-4.7.0-testing/tools/firmware/hvmloader/hvmloader.c
===================================================================
--- xen-4.7.0-testing.orig/tools/firmware/hvmloader/hvmloader.c
+++ xen-4.7.0-testing/tools/firmware/hvmloader/hvmloader.c
@@ -253,10 +253,40 @@ static void acpi_enable_sci(void)
BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN));
}
+const struct hvm_modlist_entry *get_module_entry(
+ const struct hvm_start_info *info,
+ const char *name)
+{
+ const struct hvm_modlist_entry *modlist =
+ (struct hvm_modlist_entry *)info->modlist_paddr;
+ unsigned int i;
+
+ if ( !modlist )
+ return NULL;
+
+ for ( i = 0; i < info->nr_modules; i++ )
+ {
+ uint32_t module_name = modlist[i].cmdline_paddr;
+
+ BUG_ON(!modlist[i].cmdline_paddr ||
+ modlist[i].cmdline_paddr > UINT_MAX);
+
+ if ( !strcmp(name, (char*)module_name) )
+ {
+ BUG_ON(!modlist[i].paddr || modlist[i].paddr > UINT_MAX ||
+ modlist[i].size > UINT_MAX);
+ return &modlist[i];
+ }
+ }
+
+ return NULL;
+}
+
int main(void)
{
const struct bios_config *bios;
int acpi_enabled;
+ const struct hvm_modlist_entry *bios_module;
/* Initialise hypercall stubs with RET, rendering them no-ops. */
memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
@@ -292,8 +322,16 @@ int main(void)
}
printf("Loading %s ...\n", bios->name);
- if ( bios->bios_load )
- bios->bios_load(bios);
+ bios_module = get_module_entry(hvm_start_info, "bios");
+ if ( bios_module && bios->bios_load )
+ {
+ uint32_t paddr = bios_module->paddr;
+ bios->bios_load(bios, (void*)paddr, bios_module->size);
+ }
+ else if ( bios->bios_load )
+ {
+ bios->bios_load(bios, 0, 0);
+ }
else
{
BUG_ON(bios->bios_address + bios->image_size >
Index: xen-4.7.0-testing/tools/firmware/hvmloader/ovmf.c
===================================================================
--- xen-4.7.0-testing.orig/tools/firmware/hvmloader/ovmf.c
+++ xen-4.7.0-testing/tools/firmware/hvmloader/ovmf.c
@@ -93,7 +93,8 @@ static void ovmf_finish_bios_info(void)
info->checksum = -checksum;
}
-static void ovmf_load(const struct bios_config *config)
+static void ovmf_load(const struct bios_config *config,
+ void *bios_addr, uint32_t bios_length)
{
xen_pfn_t mfn;
uint64_t addr = OVMF_BEGIN;
Index: xen-4.7.0-testing/tools/firmware/hvmloader/rombios.c
===================================================================
--- xen-4.7.0-testing.orig/tools/firmware/hvmloader/rombios.c
+++ xen-4.7.0-testing/tools/firmware/hvmloader/rombios.c
@@ -121,7 +121,8 @@ static void rombios_load_roms(void)
option_rom_phys_addr + option_rom_sz - 1);
}
-static void rombios_load(const struct bios_config *config)
+static void rombios_load(const struct bios_config *config,
+ void *unused_addr, uint32_t unused_size)
{
uint32_t bioshigh;
struct rombios_info *info;
Index: xen-4.7.0-testing/tools/firmware/hvmloader/util.h
===================================================================
--- xen-4.7.0-testing.orig/tools/firmware/hvmloader/util.h
+++ xen-4.7.0-testing/tools/firmware/hvmloader/util.h
@@ -34,6 +34,8 @@ enum {
#undef NULL
#define NULL ((void*)0)
+#define UINT_MAX (~0U)
+
void __assert_failed(char *assertion, char *file, int line)
__attribute__((noreturn));
#define ASSERT(p) \