From patchwork Fri Feb 5 12:28:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8233791 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E9DE79F37A for ; Fri, 5 Feb 2016 12:31:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5A2C202C8 for ; Fri, 5 Feb 2016 12:31:54 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E8CA20279 for ; Fri, 5 Feb 2016 12:31:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aRfVM-00043P-82; Fri, 05 Feb 2016 12:28:52 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aRfVK-00043K-32 for xen-devel@lists.xenproject.org; Fri, 05 Feb 2016 12:28:50 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id 53/06-08977-18594B65; Fri, 05 Feb 2016 12:28:49 +0000 X-Env-Sender: prvs=836227de0=roger.pau@citrix.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1454675326!14181810!1 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 9069 invoked from network); 5 Feb 2016 12:28:48 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 5 Feb 2016 12:28:48 -0000 X-IronPort-AV: E=Sophos;i="5.22,400,1449532800"; d="scan'208";a="329903313" From: Roger Pau Monne To: Date: Fri, 5 Feb 2016 13:28:40 +0100 Message-ID: <1454675320-29429-1-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.5.4 (Apple Git-61) MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , Ian Campbell , Andrew Cooper , Ian Jackson , Jan Beulich , Samuel Thibault , Roger Pau Monne Subject: [Xen-devel] [PATCH] x86/HVM: rewrite the start info structure definition in binary form X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable 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 This will prevent alignments from getting in the way. It's not safe to define this memory structures using C anyway, since the ABI depends on the bitness, while our protocol does not. Also add a command line parameter to each module, and a reserved field in order to have the layout aligned. Note that the current implementation in libxc doesn't make use of the module command line at all. Signed-off-by: Roger Pau Monné --- Cc: Samuel Thibault Cc: Ian Jackson Cc: Ian Campbell Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper --- tools/libxc/include/xc_dom.h | 28 ++++++++++++++++++++++++++++ xen/include/public/xen.h | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index cac4698..e5ab56c 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -216,6 +216,34 @@ struct xc_dom_image { struct xc_hvm_firmware_module smbios_module; }; +#if defined(__i386__) || defined(__x86_64__) +/* 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 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. */ +} __attribute__((packed)); + +struct hvm_modlist_entry { + uint32_t paddr; /* Physical address of the module. */ + uint32_t size; /* Size of the module in bytes. */ + uint32_t cmdline_paddr; /* Physical address of the command line. */ + uint32_t reserved; +} __attribute__((packed)); +#endif /* x86 */ + /* --- pluggable kernel loader ------------------------------------- */ struct xc_dom_loader { diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 7b629b1..e1350d0 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -790,22 +790,36 @@ typedef struct start_info start_info_t; * NOTE: nothing will be loaded at physical address 0, so * a 0 value in any of the address fields should be treated * as not present. + * + * 0 +----------------+ + * | magic | Contains the magic value HVM_START_MAGIC_VALUE + * | | ("xEn3" with the 0x80 bit of the "E" set). + * 4 +----------------+ + * | flags | SIF_xxx flags. + * 8 +----------------+ + * | cmdline_paddr | Physical address of the command line, + * | | a zero-terminated ASCII string. + * 12 +----------------+ + * | nr_modules | Number of modules passed to the kernel. + * 16 +----------------+ + * | modlist_paddr | Physical address of an array of modules + * | | (layout of the structure below). + * 20 +----------------+ + * + * The layout of each entry in the module structure is the following: + * + * 0 +----------------+ + * | paddr | Physical address of the module. + * 4 +----------------+ + * | size | Size of the module in bytes. + * 8 +----------------+ + * | cmdline_paddr | Physical address of the command line, + * | | a zero-terminated ASCII string. + * 12 +----------------+ + * | reserved | + * 16 +----------------+ */ -struct hvm_start_info { #define HVM_START_MAGIC_VALUE 0x336ec578 - uint32_t magic; /* Contains the magic value 0x336ec578 */ - /* ("xEn3" with the 0x80 bit of the "E" set).*/ - 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. */ -}; - -struct hvm_modlist_entry { - uint32_t paddr; /* Physical address of the module. */ - uint32_t size; /* Size of the module in bytes. */ -}; /* New console union for dom0 introduced in 0x00030203. */ #if __XEN_INTERFACE_VERSION__ < 0x00030203