From patchwork Wed Dec 5 22:31:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10714993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83DC5109C for ; Wed, 5 Dec 2018 22:33:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72FDA2E659 for ; Wed, 5 Dec 2018 22:33:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 668492E65C; Wed, 5 Dec 2018 22:33:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AEF1D2E659 for ; Wed, 5 Dec 2018 22:33:30 +0000 (UTC) Received: from localhost ([::1]:37277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUfjV-0002U6-QF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Dec 2018 17:33:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUfiC-000143-F1 for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUfi7-0003oO-IT for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:08 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gUfi7-0003nf-8i for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:03 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB5MStwq120190; Wed, 5 Dec 2018 22:32:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=wKUPvs6EweI7IDY5HaoeBj/C5KvTFks1ydvBGYwzcUo=; b=VAK9n0SwxzB6TRBvmAuYe/qmqqjnGNG9iTzyJnCB8t/I5Loy09/nr5GS7cbTkEt0R+UK h6CLcV3E5geQM2AtP356ZY41MFISDH1zmtlwGtl089CpV4LGU5x1tp8Tjr344DampZ2M HkSn1MeoqNQDNP5WEErnqsNQlFUDm2JM9BsdK15uyNApsWSM7lgeNIBRCAoTJRuXJsAO TGQbBeSG+o14AQ3DnjfmdjAq5AtaP1MpNdJAHzqRtS6rNcNw8aw3O99nKqVRqLvrGPsS TCW2NByNbrtftahDVGoRaUrB1agtawIhCdxJyS6XclB2FwByKIT2V8LnaegDI8P8l/yV pg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2p3hqu58dy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Dec 2018 22:32:02 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB5MVuxs030798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Dec 2018 22:31:56 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB5MVuTF025956; Wed, 5 Dec 2018 22:31:56 GMT Received: from ol7.uk.oracle.com (/10.175.200.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 05 Dec 2018 14:31:55 -0800 From: Liam Merwick To: pbonzini@redhat.com Date: Wed, 5 Dec 2018 22:31:21 +0000 Message-Id: <1544049083-16087-2-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544049083-16087-1-git-send-email-liam.merwick@oracle.com> References: <1544049083-16087-1-git-send-email-liam.merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9098 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=857 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812050197 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC qboot 1/3] pvh: Add x86/HVM direct boot ABI header file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maran.wilson@oracle.com, qemu-devel@nongnu.org, sgarzare@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The x86/HVM direct boot ABI permits a guest to be able to boot directly into the uncompressed Linux kernel binary. https://xenbits.xen.org/docs/unstable/misc/pvh.html This commit adds the header file that defines the start_info struct that needs to be populated in order to use this ABI. Signed-off-by: Maran Wilson Signed-off-by: Liam Merwick --- include/start_info.h | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 include/start_info.h diff --git a/include/start_info.h b/include/start_info.h new file mode 100644 index 000000000000..348779eb10cd --- /dev/null +++ b/include/start_info.h @@ -0,0 +1,146 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2016, Citrix Systems, Inc. + */ + +#ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ +#define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ + +/* + * Start of day structure passed to PVH guests and to HVM guests in %ebx. + * + * 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 XEN_HVM_START_MAGIC_VALUE + * | | ("xEn3" with the 0x80 bit of the "E" set). + * 4 +----------------+ + * | version | Version of this structure. Current version is 1. New + * | | versions are guaranteed to be backwards-compatible. + * 8 +----------------+ + * | flags | SIF_xxx flags. + * 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). + * 24 +----------------+ + * | cmdline_paddr | Physical address of the command line, + * | | a zero-terminated ASCII string. + * 32 +----------------+ + * | rsdp_paddr | Physical address of the RSDP ACPI data structure. + * 40 +----------------+ + * | memmap_paddr | Physical address of the (optional) memory map. Only + * | | present in version 1 and newer of the structure. + * 48 +----------------+ + * | memmap_entries | Number of entries in the memory map table. Only + * | | present in version 1 and newer of the structure. + * | | Zero if there is no memory map being provided. + * 52 +----------------+ + * | reserved | Version 1 and newer only. + * 56 +----------------+ + * + * The layout of each entry in the module structure is the following: + * + * 0 +----------------+ + * | paddr | Physical address of the module. + * 8 +----------------+ + * | size | Size of the module in bytes. + * 16 +----------------+ + * | cmdline_paddr | Physical address of the command line, + * | | a zero-terminated ASCII string. + * 24 +----------------+ + * | reserved | + * 32 +----------------+ + * + * The layout of each entry in the memory map table is as follows: + * + * 0 +----------------+ + * | addr | Base address + * 8 +----------------+ + * | size | Size of mapping in bytes + * 16 +----------------+ + * | type | Type of mapping as defined between the hypervisor + * | | and guest it's starting. E820_TYPE_xxx, for example. + * 20 +----------------| + * | reserved | + * 24 +----------------+ + * + * The address and sizes are always a 64bit little endian unsigned integer. + * + * NB: Xen on x86 will always try to place all the data below the 4GiB + * boundary. + * + * Version numbers of the hvm_start_info structure have evolved like this: + * + * Version 0: + * + * Version 1: Added the memmap_paddr/memmap_entries fields (plus 4 bytes of + * padding) to the end of the hvm_start_info struct. These new + * fields can be used to pass a memory map to the guest. The + * memory map is optional and so guests that understand version 1 + * of the structure must check that memmap_entries is non-zero + * before trying to read the memory map. + */ +#define XEN_HVM_START_MAGIC_VALUE 0x336ec578 + +/* + * C representation of the x86/HVM start info layout. + * + * The canonical definition of this layout is above, this is just a way to + * represent the layout described there using C types. + */ +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 nr_modules; /* Number of modules passed to the kernel. */ + uint64_t modlist_paddr; /* Physical address of an array of */ + /* hvm_modlist_entry. */ + uint64_t cmdline_paddr; /* Physical address of the command line. */ + uint64_t rsdp_paddr; /* Physical address of the RSDP ACPI data */ + /* structure. */ + uint64_t memmap_paddr; /* Physical address of an array of */ + /* hvm_memmap_table_entry. Only present in */ + /* version 1 and newer of the structure */ + uint32_t memmap_entries; /* Number of entries in the memmap table. */ + /* Only present in version 1 and newer of */ + /* the structure. Value will be zero if */ + /* there is no memory map being provided. */ + uint32_t reserved; +}; + +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; +}; + +struct hvm_memmap_table_entry { + uint64_t addr; /* Base address of the memory region */ + uint64_t size; /* Size of the memory region in bytes */ + uint32_t type; /* Mapping type */ + uint32_t reserved; +}; + +#endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */ From patchwork Wed Dec 5 22:31:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10714999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D8E515A6 for ; Wed, 5 Dec 2018 22:36:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F24322DF8E for ; Wed, 5 Dec 2018 22:36:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3A042E05A; Wed, 5 Dec 2018 22:36:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 523512DF8E for ; Wed, 5 Dec 2018 22:36:26 +0000 (UTC) Received: from localhost ([::1]:37300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUfmL-00059g-G6 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Dec 2018 17:36:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUfiD-00014x-ML for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUfi9-0003pU-0g for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:09 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48230) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gUfi8-0003ow-Nu for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:04 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB5MSt4f120198; Wed, 5 Dec 2018 22:32:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=cBY0a8AYYyl8R5SQXCClRhKrEBgJiHY8WnUDp0xwers=; b=2JAtFL2MghpJlNy9bNB/IhJMynAhB96UqKDRaQwq6HqK90SFicT8RLTyQQaUnQo/OXV9 Yaon+Jsa9E9ELgY37f0iNO6UWRKl1Xg8Q7KmBYHCwGWcT7CCFXzgDuw7RJ0tRWEtG/8I oYCA9TGfgI/BjQulqLUS35txctMUYHotx4GIQGzoOkysoPQwBs1oUzz83i4SIQm1fdvM zjNvMn3+8G75k65Z2KqEJ92FfOj/gUc5ojFFVx4etqtXQE2ADBZEpBgT2lkkaiPg8OrL lVv/ydctdtojjuqpfYQRfoL/M5rve2MGZGnfvNImcJCZls9WX6TxcEqwAi7caw2L/f8B iQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2p3hqu58e5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Dec 2018 22:32:03 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB5MVv4r003176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Dec 2018 22:31:57 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wB5MVv9P002618; Wed, 5 Dec 2018 22:31:57 GMT Received: from ol7.uk.oracle.com (/10.175.200.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 05 Dec 2018 14:31:57 -0800 From: Liam Merwick To: pbonzini@redhat.com Date: Wed, 5 Dec 2018 22:31:22 +0000 Message-Id: <1544049083-16087-3-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544049083-16087-1-git-send-email-liam.merwick@oracle.com> References: <1544049083-16087-1-git-send-email-liam.merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9098 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=914 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812050197 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC qboot 2/3] pvh: use x86/HVM direct boot ABI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maran.wilson@oracle.com, qemu-devel@nongnu.org, sgarzare@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP These changes (along with corresponding QEMU and Linux kernel changes) enable a guest to be booted using the x86/HVM direct boot ABI. QEMU parses the uncompressed kernel binary passed to it via -kernel to read the ELF Note which contains the address to be loaded. QEMU then depends on qboot to populate the start_info struct needed by the direct boot ABI and configure the guest e820 tables before jumping to the loaded kernel entry. Signed-off-by: George Kennedy Signed-off-by: Liam Merwick --- fw_cfg.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- linuxboot.c | 2 +- main.c | 3 +++ tables.c | 9 ++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) diff --git a/fw_cfg.c b/fw_cfg.c index f5aac739b921..e13ec20d0e8b 100644 --- a/fw_cfg.c +++ b/fw_cfg.c @@ -8,6 +8,10 @@ #include "linuxboot.h" #include "multiboot.h" #include "benchmark.h" +#include "start_info.h" + +extern struct hvm_start_info start_info; +extern inline uint32_t ldl_p(void *p); struct fw_cfg_file { uint32_t size; @@ -184,6 +188,67 @@ static void boot_multiboot_from_fw_cfg(void) panic(); } +static void pvh_e820_setup() +{ + struct hvm_memmap_table_entry *pvh_e820p; + int i, pvh_e820_sz; + + pvh_e820_sz = sizeof(struct hvm_memmap_table_entry) * e820->nr_map; + + pvh_e820p = malloc(pvh_e820_sz); + memset(pvh_e820p, 0, pvh_e820_sz); + + for (i = 0; i < e820->nr_map; i++) { + pvh_e820p[i].addr = e820->map[i].addr; + pvh_e820p[i].size = e820->map[i].size; + pvh_e820p[i].type = e820->map[i].type; + } + start_info.memmap_paddr = (uintptr_t)pvh_e820p; + start_info.memmap_entries = e820->nr_map; +} + +void boot_pvh_from_fw_cfg(void) +{ + void *kernel_entry; + uint32_t sz; + struct linuxboot_args args; + struct hvm_modlist_entry ramdisk_mod; + + start_info.magic = XEN_HVM_START_MAGIC_VALUE; + start_info.version = 1; + start_info.flags = 0; + start_info.nr_modules = 1; + start_info.reserved = 0; + + fw_cfg_select(FW_CFG_CMDLINE_SIZE); + args.cmdline_size = fw_cfg_readl_le(); + args.cmdline_addr = malloc(args.cmdline_size); + fw_cfg_read_entry(FW_CFG_CMDLINE_DATA, args.cmdline_addr, + args.cmdline_size); + start_info.cmdline_paddr = (uintptr_t)args.cmdline_addr; + + /* Use this field for pvhboot. Not used by pvhboot otherwise */ + fw_cfg_read_entry(FW_CFG_KERNEL_DATA, &ramdisk_mod, + sizeof(ramdisk_mod)); + ramdisk_mod.cmdline_paddr = (uintptr_t)&ramdisk_mod; + start_info.modlist_paddr = (uintptr_t)&ramdisk_mod; + + pvh_e820_setup(); + + fw_cfg_select(FW_CFG_KERNEL_SIZE); + sz = fw_cfg_readl_le(); + if (!sz) + panic(); + + fw_cfg_select(FW_CFG_KERNEL_ENTRY); + kernel_entry = (void *) fw_cfg_readl_le(); + asm volatile("movl %0, %%ebx" : : "r"(&start_info)); + + asm volatile("jmp *%2" : : "a" (0x2badb002), + "b"(&start_info), "c"(kernel_entry)); + panic(); +} + void boot_from_fwcfg(void) { struct linuxboot_args args; @@ -208,8 +273,13 @@ void boot_from_fwcfg(void) fw_cfg_select(FW_CFG_SETUP_DATA); fw_cfg_read(args.header, sizeof(args.header)); - if (!parse_bzimage(&args)) + if (!parse_bzimage(&args)) { + uint8_t *header = args.header; + + if (ldl_p(header) == 0x464c457f) /* ELF magic */ + boot_pvh_from_fw_cfg(); boot_multiboot_from_fw_cfg(); + } /* SETUP_DATA already selected */ if (args.setup_size > sizeof(args.header)) diff --git a/linuxboot.c b/linuxboot.c index a5f1c4fa078d..573052cc0f78 100644 --- a/linuxboot.c +++ b/linuxboot.c @@ -12,7 +12,7 @@ static inline uint16_t lduw_p(void *p) return val; } -static inline uint32_t ldl_p(void *p) +inline uint32_t ldl_p(void *p) { uint32_t val; memcpy(&val, p, 4); diff --git a/main.c b/main.c index 699cc1a8e6e7..725d50b94e1e 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,9 @@ #include "pflash.h" #include "pci.h" #include "benchmark.h" +#include "start_info.h" + +struct hvm_start_info start_info = {0}; static void set_realmode_int(int vec, void *p) { diff --git a/tables.c b/tables.c index 32b2406b9aed..47bef4125d9e 100644 --- a/tables.c +++ b/tables.c @@ -2,6 +2,9 @@ #include "stdio.h" #include "fw_cfg.h" #include "string.h" +#include "start_info.h" + +extern struct hvm_start_info start_info; struct loader_cmd { uint32_t cmd; @@ -122,6 +125,8 @@ static void do_checksum(char *file, uint32_t offset, uint32_t start, uint32_t le p[offset] -= csum8(&p[start], len); } +#define RSDP_FILE "etc/acpi/rsdp" + void extract_acpi(void) { int id = fw_cfg_file_id("etc/table-loader"); @@ -138,6 +143,10 @@ void extract_acpi(void) struct loader_cmd *s = &script[i]; switch(script[i].cmd) { case CMD_ALLOC: + if (strcmp(s->alloc.file, RSDP_FILE) == 0) { + start_info.rsdp_paddr = + (uintptr_t)id_to_addr(id); + } do_alloc(s->alloc.file, s->alloc.align, s->alloc.zone); break; case CMD_PTR: From patchwork Wed Dec 5 22:31:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10714997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AA61109C for ; Wed, 5 Dec 2018 22:35:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7D4F2DD88 for ; Wed, 5 Dec 2018 22:35:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC4002DD93; Wed, 5 Dec 2018 22:35:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BA8B2DD89 for ; Wed, 5 Dec 2018 22:35:06 +0000 (UTC) Received: from localhost ([::1]:37291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUfl3-0004RU-F5 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Dec 2018 17:35:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUfiA-00013B-Ut for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUfi6-0003nL-2M for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:06 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48184) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gUfi5-0003mq-Pd for qemu-devel@nongnu.org; Wed, 05 Dec 2018 17:32:01 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB5MT2LT120357; Wed, 5 Dec 2018 22:32:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=y+DrkfeVA5l1wkaZci+Tr6Hyj7tMkDVeJNAAT0vkm5Q=; b=C1QlxBwuaO/7IhEtURACila64xCxvBf2h8w8XSqBak+s0PSI8WZzaI5xpA74SCY8zpsb BqmPKVQnhdXJcGijfNDmhNiPfBfdtdsH/2MZ5+822hnenMZ/AfeJFJqmyrkXtt+vpFqU KFdmHVpa9LIuv8SPatasv2ZzdbgQMwhqOxuVZB9aXx8AJxqED93aK+ho3u/EhzSsvg+7 cxS3o4KNDALNjeSVO41KTXeXl7Vwdr+qY8cU3YJObbMU0rWGkOznmpS+09jwkfS5w8Zy pGo7Wupd4KYYN02IzyWhsQZGPoFDKTY63TSY0kzyGq8RGt0A6ohMmTfzmimw+VZo6WW9 1A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2p3hqu58ds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Dec 2018 22:32:00 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB5MVxXj003257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Dec 2018 22:31:59 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wB5MVxMw018753; Wed, 5 Dec 2018 22:31:59 GMT Received: from ol7.uk.oracle.com (/10.175.200.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 05 Dec 2018 14:31:58 -0800 From: Liam Merwick To: pbonzini@redhat.com Date: Wed, 5 Dec 2018 22:31:23 +0000 Message-Id: <1544049083-16087-4-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544049083-16087-1-git-send-email-liam.merwick@oracle.com> References: <1544049083-16087-1-git-send-email-liam.merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9098 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=742 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812050197 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC qboot 3/3] pvh: add benchmark exit point X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maran.wilson@oracle.com, qemu-devel@nongnu.org, sgarzare@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This commit adds a PVH specific VM exit point for use in benchmarking boot times using a QEMU specific device that terminates the QEMU process and thus the VM itself when handling those VM exits. Since the VM terminates right at those exit points, generic tools like time can be used to measure the time spent between the QEMU startup and termination moments. The QEMU device used for those measurement is called isa-debug-exit for the PC and Q35 machine types. These devices take 2 arguments: iobase and iosize. iobase specifies which IO port we need to write into to have these devices eventually handle the corresponding VM exit. If for example, QEMU is started with the following argument: -device isa-debug-exit,iobase=0xf4 then any IO write to 0xf4 will terminate the QEMU process and the corresponding VM. Signed-off-by: Liam Merwick --- benchmark.h | 3 ++- fw_cfg.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/benchmark.h b/benchmark.h index 089c549b5803..2be08e7b2cec 100644 --- a/benchmark.h +++ b/benchmark.h @@ -9,5 +9,6 @@ #define FW_START 1 #define LINUX_START_FWCFG 2 #define LINUX_START_BOOT 3 +#define LINUX_START_PVHBOOT 4 -#endif +#endif /* BENCHMARK_H */ diff --git a/fw_cfg.c b/fw_cfg.c index e13ec20d0e8b..690ff19e74a0 100644 --- a/fw_cfg.c +++ b/fw_cfg.c @@ -240,10 +240,17 @@ void boot_pvh_from_fw_cfg(void) if (!sz) panic(); + fw_cfg_select(FW_CFG_KERNEL_ENTRY); kernel_entry = (void *) fw_cfg_readl_le(); asm volatile("movl %0, %%ebx" : : "r"(&start_info)); +#ifdef BENCHMARK_HACK + /* Exit just before jumping to vmlinux, so that it is easy + * to time/profile the firmware. + */ + outb(LINUX_EXIT_PORT, LINUX_START_PVHBOOT); +#endif asm volatile("jmp *%2" : : "a" (0x2badb002), "b"(&start_info), "c"(kernel_entry)); panic();