From patchwork Thu Feb 25 14:56:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 8424231 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 73087C0553 for ; Thu, 25 Feb 2016 14:59:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B017620204 for ; Thu, 25 Feb 2016 14:59:54 +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 E259920361 for ; Thu, 25 Feb 2016 14:59:53 +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-0001V7-9w; 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-0001SF-8O for xen-devel@lists.xen.org; Thu, 25 Feb 2016 14:57:15 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id F3/3B-03497-A461FC65; Thu, 25 Feb 2016 14:57:14 +0000 X-Env-Sender: prvs=85652c963=anthony.perard@citrix.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1456412231!26664967!2 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 13532 invoked from network); 25 Feb 2016 14:57:13 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2016 14:57:13 -0000 X-IronPort-AV: E=Sophos;i="5.22,498,1449532800"; d="scan'208";a="334491063" From: Anthony PERARD To: Date: Thu, 25 Feb 2016 14:56:05 +0000 Message-ID: <1456412174-20162-8-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: Anthony PERARD , Andrew Cooper , Wei Liu , Stefano Stabellini Subject: [Xen-devel] [PATCH v3 07/16] hvmloader: Grab the hvm_start_info pointer 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 Signed-off-by: Anthony PERARD --- Change in V3: - remove cmdline parser - load hvm_start_info pointer earlier, before calling main(). - Add struct hvm_start_info definition to hvmloader. --- tools/firmware/hvmloader/hvm_start_info.h | 32 +++++++++++++++++++++++++++++++ tools/firmware/hvmloader/hvmloader.c | 6 ++++++ 2 files changed, 38 insertions(+) create mode 100644 tools/firmware/hvmloader/hvm_start_info.h diff --git a/tools/firmware/hvmloader/hvm_start_info.h b/tools/firmware/hvmloader/hvm_start_info.h new file mode 100644 index 0000000..b95d60d --- /dev/null +++ b/tools/firmware/hvmloader/hvm_start_info.h @@ -0,0 +1,32 @@ +#ifndef __HVM_START_INFO_H__ +#define __HVM_START_INFO_H__ + +/* C representation of the x86/HVM start info layout. + * + * The canonical definition of this layout resides in public/xen.h, this + * is just a way to represent the layout described there using C types. + * + * NB: the packed attribute is not really needed, but it helps us enforce + * the fact this this is just a representation, and it might indeed + * be required in the future if there are alignment changes. + */ +struct hvm_start_info { + uint32_t magic; /* Contains the magic value 0x336ec578 */ + /* ("xEn3" with the 0x80 bit of the "E" set).*/ + uint32_t version; /* Version of this structure. */ + uint32_t flags; /* SIF_xxx flags. */ + uint32_t cmdline_paddr; /* Physical address of the command line. */ + uint32_t nr_modules; /* Number of modules passed to the kernel. */ + uint32_t modlist_paddr; /* Physical address of an array of */ + /* hvm_modlist_entry. */ + uint32_t rsdp_paddr; /* Physical address of the RSDP ACPI data */ + /* structure. */ +} __attribute__((packed)); + +struct hvm_modlist_entry { + uint64_t paddr; /* Physical address of the module. */ + uint64_t size; /* Size of the module in bytes. */ + uint64_t cmdline_paddr; /* Physical address of the command line. */ + uint64_t reserved; +} __attribute__((packed)); +#endif /* __HVM_START_INFO_H__ */ diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 716d03c..20ec8dc 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -28,6 +28,9 @@ #include "vnuma.h" #include #include +#include "hvm_start_info.h" + +const struct hvm_start_info *hvm_start_info; asm ( " .text \n" @@ -46,6 +49,8 @@ asm ( " ljmp $"STR(SEL_CODE32)",$1f \n" "1: movl $stack_top,%esp \n" " movl %esp,%ebp \n" + /* store HVM start info ptr */ + " mov %ebx, hvm_start_info \n" " call main \n" /* Relocate real-mode trampoline to 0x0. */ " mov $trampoline_start,%esi \n" @@ -258,6 +263,7 @@ int main(void) memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE); printf("HVM Loader\n"); + BUG_ON(hvm_start_info->magic != XEN_HVM_START_MAGIC_VALUE); init_hypercalls();