From patchwork Thu Feb 25 14:56:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 8424241 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D35E3C0553 for ; Thu, 25 Feb 2016 14:59:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 00D222026F for ; Thu, 25 Feb 2016 14:59:52 +0000 (UTC) Received: from lists.xen.org (unknown [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E74022034C for ; Thu, 25 Feb 2016 14:59:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aYxLw-0001W1-NJ; Thu, 25 Feb 2016 14:57:16 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aYxLv-0001SJ-F0 for xen-devel@lists.xen.org; Thu, 25 Feb 2016 14:57:15 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 28/52-03645-A461FC65; Thu, 25 Feb 2016 14:57:14 +0000 X-Env-Sender: prvs=85652c963=anthony.perard@citrix.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1456412230!26701674!4 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23754 invoked from network); 25 Feb 2016 14:57:14 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2016 14:57:14 -0000 X-IronPort-AV: E=Sophos;i="5.22,498,1449532800"; d="scan'208";a="334491066" From: Anthony PERARD To: Date: Thu, 25 Feb 2016 14:56:06 +0000 Message-ID: <1456412174-20162-9-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1456412174-20162-1-git-send-email-anthony.perard@citrix.com> References: <1456412174-20162-1-git-send-email-anthony.perard@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Keir Fraser , Stefano Stabellini , Andrew Cooper , Ian Jackson , Jan Beulich , Anthony PERARD , Wei Liu Subject: [Xen-devel] [PATCH v3 08/16] hvmloader: Locate the BIOS blob X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changes in V3: - fix some codying style - use module.cmdline to look for a module name instead of the main cmdline from hvm_start_info. --- tools/firmware/hvmloader/config.h | 2 +- tools/firmware/hvmloader/hvmloader.c | 34 ++++++++++++++++++++++++++++++++-- tools/firmware/hvmloader/ovmf.c | 3 ++- tools/firmware/hvmloader/rombios.c | 3 ++- tools/firmware/hvmloader/util.h | 2 ++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h index b838cf9..4c6d8ad 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 20ec8dc..d319de0 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -254,10 +254,32 @@ 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; + int i; + + for ( i = 0; i < info->nr_modules; i++ ) + { + uint32_t module_name = modlist[i].cmdline_paddr; + if ( !strcmp(name, (char*)module_name) ) + { + BUG_ON(modlist[i].paddr > 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); @@ -293,8 +315,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 > diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c index db9fa7a..858a2d4 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 1f15b94..2ded844 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; diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 132d915..d45c107 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -25,6 +25,8 @@ #undef NULL #define NULL ((void*)0) +#define UINT_MAX (~0U) + void __assert_failed(char *assertion, char *file, int line) __attribute__((noreturn)); #define ASSERT(p) \