[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] hvmloader: Locate the BIOS blob
commit 8aa944d48e988a618eb0e0965289030d36e3e240 Author: Anthony PERARD <anthony.perard@xxxxxxxxxx> AuthorDate: Tue Oct 20 16:55:49 2015 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Thu Aug 18 17:24:39 2016 +0100 hvmloader: Locate the BIOS blob The BIOS blob can be found an entry called "firmware" 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. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- tools/firmware/hvmloader/config.h | 2 +- tools/firmware/hvmloader/hvmloader.c | 59 ++++++++++++++++++++++++++++++++++-- tools/firmware/hvmloader/ovmf.c | 3 +- tools/firmware/hvmloader/rombios.c | 3 +- 4 files changed, 62 insertions(+), 5 deletions(-) diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h index da1e7cf..a4429f4 100644 --- a/tools/firmware/hvmloader/config.h +++ b/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); diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 67a18af..c6ff7fc 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -266,10 +266,56 @@ 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 *)(uintptr_t)info->modlist_paddr; + unsigned int i; + + if ( !modlist || + info->modlist_paddr > UINTPTR_MAX || + (info->modlist_paddr + info->nr_modules * sizeof(*modlist) - 1) + > UINTPTR_MAX ) + return NULL; + + for ( i = 0; i < info->nr_modules; i++ ) + { + char *module_name = (char*)(uintptr_t)modlist[i].cmdline_paddr; + + /* Skip if the module or its cmdline is missing. */ + if ( !module_name || !modlist[i].paddr ) + continue; + + /* Skip if the cmdline cannot be read. */ + if ( modlist[i].cmdline_paddr > UINTPTR_MAX || + (modlist[i].cmdline_paddr + strlen(name)) > UINTPTR_MAX ) + continue; + + if ( !strcmp(name, module_name) ) + { + if ( modlist[i].paddr > UINTPTR_MAX || + modlist[i].size > UINTPTR_MAX || + (modlist[i].paddr + modlist[i].size - 1) > UINTPTR_MAX ) + { + printf("Cannot load \"%s\" from 0x"PRIllx" (0x"PRIllx")\n", + name, PRIllx_arg(modlist[i].paddr), + PRIllx_arg(modlist[i].size)); + BUG(); + } + 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); @@ -305,8 +351,17 @@ 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, "firmware"); + 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, NULL, 0); + } else { BUG_ON(bios->bios_address + bios->image_size > diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c index e7d0785..60d000f 100644 --- a/tools/firmware/hvmloader/ovmf.c +++ b/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; diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c index b66f8e9..9acf03f 100644 --- a/tools/firmware/hvmloader/rombios.c +++ b/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; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |