|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 05/15] x86/PVH: split pvh_load_kernel()
All E820 manipulations want to happen before the initrd is placed. As a
first step, split placing the kernel from actually loading it. Then
placement of other data (ACPI, VMX) can be inserted between kernel
placement and P2M population (followed by the loading of the kernel).
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
If need be, moving the "elf" local variable to dom0_construct_pvh() could
of course further be split off. Just that this by itself doesn't make much
sense.
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -644,26 +644,17 @@ static bool __init check_and_adjust_load
return true;
}
-static int __init pvh_load_kernel(
- const struct boot_domain *bd, paddr_t *entry, paddr_t *start_info_addr)
+static int __init pvh_place_kernel(
+ const struct boot_domain *bd,
+ struct elf_binary *elf,
+ paddr_t *entry)
{
struct domain *d = bd->d;
struct boot_module *image = bd->kernel;
- struct boot_module *initrd = bd->initrd;
void *image_base = bootstrap_map_bm(image);
void *image_start = image_base + image->arch.headroom;
unsigned long image_len = image->size;
- unsigned long initrd_len =
- initrd ? initrd->size - initrd->arch.headroom : 0;
- size_t cmdline_len = bd->cmdline ? strlen(bd->cmdline) + 1 : 0;
- const char *initrd_cmdline = NULL;
- struct elf_binary elf;
struct elf_dom_parms parms;
- size_t extra_space;
- paddr_t last_addr;
- struct hvm_start_info start_info = { 0 };
- struct hvm_modlist_entry mod = { 0 };
- struct vcpu *v = d->vcpu[0];
int rc;
if ( (rc = bzimage_parse(image_base, &image_start, &image_len)) != 0 )
@@ -672,19 +663,19 @@ static int __init pvh_load_kernel(
return rc;
}
- if ( (rc = elf_init(&elf, image_start, image_len)) != 0 )
+ if ( (rc = elf_init(elf, image_start, image_len)) != 0 )
{
printk("Unable to init ELF\n");
return rc;
}
if ( opt_dom0_verbose )
- elf_set_verbose(&elf);
- elf_parse_binary(&elf);
- if ( (rc = elf_xen_parse(&elf, &parms, true)) != 0 )
+ elf_set_verbose(elf);
+ elf_parse_binary(elf);
+ if ( (rc = elf_xen_parse(elf, &parms, true)) != 0 )
{
printk("Unable to parse kernel for ELFNOTES\n");
- if ( elf_check_broken(&elf) )
- printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
+ if ( elf_check_broken(elf) )
+ printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(elf));
return rc;
}
@@ -697,20 +688,43 @@ static int __init pvh_load_kernel(
if ( (rc = initdom_check_parms(d, &parms)) != 0 )
return rc;
- /* Copy the OS image and free temporary buffer. */
- elf.dest_base = (void *)(parms.virt_kstart - parms.virt_base);
- elf.dest_size = parms.virt_kend - parms.virt_kstart;
+ elf->dest_base = (void *)(parms.virt_kstart - parms.virt_base);
+ elf->dest_size = parms.virt_kend - parms.virt_kstart;
- if ( !check_and_adjust_load_address(d, &elf, &parms) )
+ if ( !check_and_adjust_load_address(d, elf, &parms) )
return -ENOSPC;
- elf_set_vcpu(&elf, v);
- rc = elf_load_binary(&elf);
+ *entry = parms.phys_entry;
+
+ return 0;
+}
+
+static int __init pvh_load_kernel(
+ const struct boot_domain *bd,
+ struct elf_binary *elf,
+ paddr_t *start_info_addr)
+{
+ struct domain *d = bd->d;
+ struct boot_module *initrd = bd->initrd;
+ unsigned long initrd_len =
+ initrd ? initrd->size - initrd->arch.headroom : 0;
+ size_t cmdline_len = bd->cmdline ? strlen(bd->cmdline) + 1 : 0;
+ const char *initrd_cmdline = NULL;
+ size_t extra_space;
+ paddr_t last_addr;
+ struct hvm_start_info start_info = { 0 };
+ struct hvm_modlist_entry mod = { 0 };
+ struct vcpu *v = d->vcpu[0];
+ int rc;
+
+ /* Copy the OS image and free temporary buffer. */
+ elf_set_vcpu(elf, v);
+ rc = elf_load_binary(elf);
if ( rc < 0 )
{
printk("Failed to load kernel: %d\n", rc);
- if ( elf_check_broken(&elf) )
- printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
+ if ( elf_check_broken(elf) )
+ printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(elf));
return rc;
}
@@ -724,7 +738,7 @@ static int __init pvh_load_kernel(
if ( initrd )
{
- size_t initrd_space = elf_round_up(&elf, initrd_len);
+ size_t initrd_space = elf_round_up(elf, initrd_len);
if ( initrd->arch.cmdline_pa )
{
@@ -741,9 +755,9 @@ static int __init pvh_load_kernel(
initrd = NULL;
}
- extra_space += elf_round_up(&elf, cmdline_len);
+ extra_space += elf_round_up(elf, cmdline_len);
- last_addr = find_memory(d, &elf, extra_space);
+ last_addr = find_memory(d, elf, extra_space);
if ( last_addr == INVALID_PADDR )
{
printk("Unable to find a memory region to load initrd and metadata\n");
@@ -763,7 +777,7 @@ static int __init pvh_load_kernel(
mod.paddr = last_addr;
mod.size = initrd_len;
- last_addr += elf_round_up(&elf, initrd_len);
+ last_addr += elf_round_up(elf, initrd_len);
if ( initrd_cmdline )
{
size_t len = strlen(initrd_cmdline) + 1;
@@ -796,7 +810,7 @@ static int __init pvh_load_kernel(
* Round up to 32/64 bits (depending on the guest kernel bitness) so
* the modlist/start_info is aligned.
*/
- last_addr += elf_round_up(&elf, cmdline_len);
+ last_addr += elf_round_up(elf, cmdline_len);
if ( initrd != NULL )
{
@@ -820,7 +834,6 @@ static int __init pvh_load_kernel(
return rc;
}
- *entry = parms.phys_entry;
*start_info_addr = last_addr;
return 0;
@@ -1338,6 +1351,7 @@ int __init dom0_construct_pvh(const stru
{
paddr_t entry, start_info;
struct domain *d = bd->d;
+ struct elf_binary elf;
int rc;
printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id);
@@ -1375,6 +1389,13 @@ int __init dom0_construct_pvh(const stru
iommu_hwdom_init(d);
+ rc = pvh_place_kernel(bd, &elf, &entry);
+ if ( rc )
+ {
+ printk("Failed to place Dom0 kernel\n");
+ return rc;
+ }
+
rc = pvh_populate_p2m(d);
if ( rc )
{
@@ -1382,7 +1403,7 @@ int __init dom0_construct_pvh(const stru
return rc;
}
- rc = pvh_load_kernel(bd, &entry, &start_info);
+ rc = pvh_load_kernel(bd, &elf, &start_info);
if ( rc )
{
printk("Failed to load Dom0 kernel\n");
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |