xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xen.org
Cc: Anthony PERARD <anthony.perard@citrix.com>
Subject: [RFC PATCH 3/5] hvmloader: Load BIOS from where libxc left it.
Date: Wed, 16 Sep 2015 18:19:45 +0100	[thread overview]
Message-ID: <1442423987-14956-4-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1442423987-14956-1-git-send-email-anthony.perard@citrix.com>

---
 tools/firmware/hvmloader/config.h    |  9 +--------
 tools/firmware/hvmloader/hvmloader.c | 25 +++++++++++++------------
 tools/firmware/hvmloader/seabios.c   | 24 ++++++++++++++----------
 3 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h
index b838cf9..0ddd897 100644
--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -12,17 +12,10 @@ extern unsigned long igd_opregion_pgbase;
 struct bios_config {
     const char *name;
 
-    /* BIOS ROM image bits */
-    void *image;
-    unsigned int image_size;
-
-    /* Physical address to load at */
-    unsigned int bios_address;
-
     /* 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);
diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
index 716d03c..04b5076 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -253,6 +253,9 @@ int main(void)
 {
     const struct bios_config *bios;
     int acpi_enabled;
+    uint8_t *bios_addr;
+    uint32_t bios_lenght;
+    const char *s;
 
     /* Initialise hypercall stubs with RET, rendering them no-ops. */
     memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
@@ -286,16 +289,14 @@ int main(void)
         bios->create_smbios_tables();
     }
 
+    // XXX check that the values exist and are correct
+    s = xenstore_read("hvmloader/bios/address", NULL);
+    bios_addr = (uint8_t*)(uint32_t)strtoll(s, NULL, 0);
+    s = xenstore_read("hvmloader/bios/length", NULL);
+    bios_lenght = (uint32_t)strtoll(s, NULL, 0);
+
     printf("Loading %s ...\n", bios->name);
-    if ( bios->bios_load )
-        bios->bios_load(bios);
-    else
-    {
-        BUG_ON(bios->bios_address + bios->image_size >
-               HVMLOADER_PHYSICAL_ADDRESS);
-        memcpy((void *)bios->bios_address, bios->image,
-               bios->image_size);
-    }
+    bios->bios_load(bios, bios_addr, bios_lenght);
 
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     {
@@ -333,9 +334,9 @@ int main(void)
     if ( SCRATCH_PHYSICAL_ADDRESS != scratch_start )
         printf(" %05x-%05lx: Scratch space\n",
                SCRATCH_PHYSICAL_ADDRESS, scratch_start);
-    printf(" %05x-%05x: Main BIOS\n",
-           bios->bios_address,
-           bios->bios_address + bios->image_size - 1);
+    /* printf(" %05x-%05x: Main BIOS\n", */
+           /* bios->bios_address, */
+           /* bios->bios_address + bios->image_size - 1); */
 
     if ( bios->e820_setup )
         bios->e820_setup();
diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c
index c6b3d9f..28793ca 100644
--- a/tools/firmware/hvmloader/seabios.c
+++ b/tools/firmware/hvmloader/seabios.c
@@ -27,9 +27,6 @@
 #include "smbios_types.h"
 #include "acpi/acpi2_0.h"
 
-#define ROM_INCLUDE_SEABIOS
-#include "roms.inc"
-
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
 
@@ -121,6 +118,7 @@ static void seabios_create_pir_tables(void)
     add_table(create_pir_tables());
 }
 
+unsigned int seabios_bios_address = 0;
 static void seabios_setup_e820(void)
 {
     struct seabios_info *info = (void *)BIOS_INFO_PHYSICAL_ADDRESS;
@@ -128,21 +126,27 @@ static void seabios_setup_e820(void)
     info->e820 = (uint32_t)e820;
 
     /* SeaBIOS reserves memory in e820 as necessary so no low reservation. */
-    info->e820_nr = build_e820_table(e820, 0, 0x100000-sizeof(seabios));
+    BUG_ON(seabios_bios_address == 0);
+    info->e820_nr = build_e820_table(e820, 0, seabios_bios_address);
     dump_e820_table(e820, info->e820_nr);
 }
 
-struct bios_config seabios_config = {
-    .name = "SeaBIOS",
+static void seabios_load(const struct bios_config *bios,
+                         void *bios_addr, uint32_t bios_lenght)
+{
+    unsigned int bios_dest = 0x100000 - bios_lenght;
+    seabios_bios_address = 0x100000 - bios_lenght;
 
-    .image = seabios,
-    .image_size = sizeof(seabios),
+    BUG_ON(bios_dest + bios_lenght > HVMLOADER_PHYSICAL_ADDRESS);
+    memcpy((void *)bios_dest, bios_addr, bios_lenght);
+}
 
-    .bios_address = 0x100000 - sizeof(seabios),
+struct bios_config seabios_config = {
+    .name = "SeaBIOS",
 
     .load_roms = NULL,
 
-    .bios_load = NULL,
+    .bios_load = seabios_load,
 
     .bios_info_setup = seabios_setup_bios_info,
     .bios_info_finish = seabios_finish_bios_info,
-- 
Anthony PERARD

  parent reply	other threads:[~2015-09-16 17:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 17:19 [RFC PATCH 0/5] Load BIOS via toolstack instead of been embedded in hvmloader Anthony PERARD
2015-09-16 17:19 ` [RFC PATCH 1/5] libxc: Load BIOS and ACPI table into guest memory Anthony PERARD
2015-09-16 17:19 ` [RFC PATCH 2/5] libxl: Load guest BIOS and ACPI table from file Anthony PERARD
2015-09-16 17:19 ` Anthony PERARD [this message]
2015-09-16 17:19 ` [RFC PATCH 4/5] hvmloader: Load ACPI table from here libxc left it Anthony PERARD
2015-09-16 17:19 ` [RFC PATCH 5/5] hvmloader: Keep BIOS and ACPI blob in separated files Anthony PERARD
2015-09-16 18:56 ` [RFC PATCH 0/5] Load BIOS via toolstack instead of been embedded in hvmloader Andrew Cooper
2015-09-17  9:49   ` Anthony PERARD
2015-09-25 15:37     ` Ian Campbell
2015-09-25 15:45       ` Anthony PERARD
2015-09-25 16:28         ` 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=1442423987-14956-4-git-send-email-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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).