From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xen.org
Cc: Anthony PERARD <anthony.perard@citrix.com>
Subject: [RFC PATCH 1/5] libxc: Load BIOS and ACPI table into guest memory.
Date: Wed, 16 Sep 2015 18:19:43 +0100 [thread overview]
Message-ID: <1442423987-14956-2-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1442423987-14956-1-git-send-email-anthony.perard@citrix.com>
---
tools/libxc/include/xenguest.h | 4 ++++
tools/libxc/xc_hvm_build_x86.c | 46 +++++++++++++++++++++++++++++++++---------
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h
index 1a1a185..42acbfd 100644
--- a/tools/libxc/include/xenguest.h
+++ b/tools/libxc/include/xenguest.h
@@ -229,6 +229,10 @@ struct xc_hvm_build_args {
uint64_t lowmem_end;
uint64_t highmem_end;
uint64_t mmio_start;
+
+ /* BIOS as module */
+ struct xc_hvm_firmware_module bios_module;
+ struct xc_hvm_firmware_module acpi_table_module;
};
/**
diff --git a/tools/libxc/xc_hvm_build_x86.c b/tools/libxc/xc_hvm_build_x86.c
index ea250dd..a444d83 100644
--- a/tools/libxc/xc_hvm_build_x86.c
+++ b/tools/libxc/xc_hvm_build_x86.c
@@ -53,6 +53,15 @@
#define VGA_HOLE_SIZE (0x20)
+static uint64_t module_init(struct xc_hvm_firmware_module *x, uint64_t mstart)
+{
+#define MODULE_ALIGN 1UL << 7
+#define MKALIGN(x, a) (((uint64_t)(x) + (a) - 1) & ~(uint64_t)((a) - 1))
+ if ( x->length != 0 )
+ x->guest_addr_out = mstart;
+ return MKALIGN(x->length, MODULE_ALIGN);
+}
+
static int modules_init(struct xc_hvm_build_args *args,
uint64_t vend, struct elf_binary *elf,
uint64_t *mstart_out, uint64_t *mend_out)
@@ -60,27 +69,29 @@ static int modules_init(struct xc_hvm_build_args *args,
#define MODULE_ALIGN 1UL << 7
#define MB_ALIGN 1UL << 20
#define MKALIGN(x, a) (((uint64_t)(x) + (a) - 1) & ~(uint64_t)((a) - 1))
- uint64_t total_len = 0, offset1 = 0;
+ uint64_t total_len = 0, offset1 = 0, offset0;
- if ( (args->acpi_module.length == 0)&&(args->smbios_module.length == 0) )
- return 0;
+
+ /* Want to place the modules 1Mb+change behind the loader image. */
+ *mstart_out = MKALIGN(elf->pend, MB_ALIGN) + (MB_ALIGN);
/* Find the total length for the firmware modules with a reasonable large
* alignment size to align each the modules.
*/
- total_len = MKALIGN(args->acpi_module.length, MODULE_ALIGN);
+ total_len += module_init(&args->bios_module, *mstart_out + total_len);
+ total_len += module_init(&args->acpi_table_module, *mstart_out + total_len);
+ offset0 = total_len;
+ total_len += MKALIGN(args->acpi_module.length, MODULE_ALIGN);
offset1 = total_len;
total_len += MKALIGN(args->smbios_module.length, MODULE_ALIGN);
- /* Want to place the modules 1Mb+change behind the loader image. */
- *mstart_out = MKALIGN(elf->pend, MB_ALIGN) + (MB_ALIGN);
*mend_out = *mstart_out + total_len;
- if ( *mend_out > vend )
+ if ( *mend_out > vend )
return -1;
if ( args->acpi_module.length != 0 )
- args->acpi_module.guest_addr_out = *mstart_out;
+ args->acpi_module.guest_addr_out = *mstart_out + offset0;
if ( args->smbios_module.length != 0 )
args->smbios_module.guest_addr_out = *mstart_out + offset1;
@@ -158,6 +169,17 @@ static int loadelfimage(xc_interface *xch, struct elf_binary *elf,
return rc;
}
+static void loadmodule(struct xc_hvm_firmware_module *x,
+ uint8_t *dest, uint64_t mstart)
+{
+ if ( x->length != 0 )
+ {
+ memcpy(dest + (x->guest_addr_out - mstart),
+ x->data,
+ x->length);
+ }
+}
+
static int loadmodules(xc_interface *xch,
struct xc_hvm_build_args *args,
uint64_t mstart, uint64_t mend,
@@ -196,9 +218,11 @@ static int loadmodules(xc_interface *xch,
memset(dest, 0, pages << PAGE_SHIFT);
/* Load modules into range */
+ loadmodule(&args->bios_module, dest, mstart);
+ loadmodule(&args->acpi_table_module, dest, mstart);
if ( args->acpi_module.length != 0 )
{
- memcpy(dest,
+ memcpy(dest + (args->acpi_module.guest_addr_out - mstart),
args->acpi_module.data,
args->acpi_module.length);
}
@@ -729,6 +753,10 @@ int xc_hvm_build(xc_interface *xch, uint32_t domid,
args.acpi_module.guest_addr_out;
hvm_args->smbios_module.guest_addr_out =
args.smbios_module.guest_addr_out;
+ hvm_args->bios_module.guest_addr_out =
+ args.bios_module.guest_addr_out;
+ hvm_args->acpi_table_module.guest_addr_out =
+ args.acpi_table_module.guest_addr_out;
}
free(image);
--
Anthony PERARD
next prev 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 ` Anthony PERARD [this message]
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 ` [RFC PATCH 3/5] hvmloader: Load BIOS from where libxc left it Anthony PERARD
2015-09-16 17:19 ` [RFC PATCH 4/5] hvmloader: Load ACPI table from here " 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-2-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).