From patchwork Mon Jan 25 16:46:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 43677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 175501007D3 for ; Tue, 26 Jan 2010 15:30:35 +1100 (EST) Received: from localhost ([127.0.0.1]:37426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZd4R-0007l8-9S for incoming@patchwork.ozlabs.org; Mon, 25 Jan 2010 23:30:31 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZS5W-0003Nv-7s for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:46:54 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZS5R-0003MI-Lo for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:46:53 -0500 Received: from [199.232.76.173] (port=42982 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZS5R-0003MD-Iz for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:46:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11895) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZS5R-0005Wz-1X for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:46:49 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0PGkjUX019181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Jan 2010 11:46:46 -0500 Received: from [10.36.8.164] (vpn2-8-164.ams2.redhat.com [10.36.8.164]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0PGkhHZ025011; Mon, 25 Jan 2010 11:46:44 -0500 Message-ID: <4B5DCAF2.3010105@redhat.com> Date: Mon, 25 Jan 2010 17:46:42 +0100 From: Jes Sorensen User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-Mailman-Approved-At: Mon, 25 Jan 2010 23:24:30 -0500 Cc: Anthony Liguori , Kevin O'Connor , Avi Kivity , kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH] Seabios - read e820 reserve from qemu_cfg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, Right now KVM/QEMU relies on hard coded values in Seabios for the reserved area for the TSS pages and the EPT page. I'd like to suggest we change this to pass the value from QEMU via qemu-cfg making it possible to move it around dynamically in the future. Attached is a patch to Seabios for this, which defaults to the current hard coded value if no value is provided by qemu-cfg. We can remove the backwards compatibility later. I'll post the QEMU patches for upstream QEMU and QEMU-KVM in a minute. Comments most welcome! Cheers, Jes Read location and size of KVM switch area from qemu-cfg Read location of KVM's switch area (VMX TSS pages and EPT) from QEMU via qemu-cfg instead of relying on hard coded values. For now, fall back to the old hard coded values for compatibility reasons. Compatibility code can be removed in the future. Signed-off-by: Jes Sorensen --- src/paravirt.c | 9 +++++++++ src/paravirt.h | 7 +++++++ src/post.c | 14 ++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) Index: seabios/src/paravirt.c =================================================================== --- seabios.orig/src/paravirt.c +++ seabios/src/paravirt.c @@ -132,6 +132,15 @@ u16 qemu_cfg_smbios_entries(void) return cnt; } +int qemu_cfg_read_e820_reserve(struct qemu_cfg_e820_reserve *reserve) +{ + if (!qemu_cfg_present) + return 0; + + qemu_cfg_read((void *)reserve, sizeof(*reserve)); + return reserve->length; +} + struct smbios_header { u16 length; u8 type; Index: seabios/src/paravirt.h =================================================================== --- seabios.orig/src/paravirt.h +++ seabios/src/paravirt.h @@ -36,6 +36,7 @@ static inline int kvm_para_available(voi #define QEMU_CFG_ACPI_TABLES (QEMU_CFG_ARCH_LOCAL + 0) #define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1) #define QEMU_CFG_IRQ0_OVERRIDE (QEMU_CFG_ARCH_LOCAL + 2) +#define QEMU_CFG_E820_RESERVE (QEMU_CFG_ARCH_LOCAL + 3) extern int qemu_cfg_present; @@ -61,8 +62,14 @@ typedef struct QemuCfgFile { char name[56]; } QemuCfgFile; +struct qemu_cfg_e820_reserve { + u32 addr; + u32 length; +}; + u16 qemu_cfg_first_file(QemuCfgFile *entry); u16 qemu_cfg_next_file(QemuCfgFile *entry); u32 qemu_cfg_read_file(QemuCfgFile *entry, void *dst, u32 maxlen); +int qemu_cfg_read_e820_reserve(struct qemu_cfg_e820_reserve *reserve); #endif Index: seabios/src/post.c =================================================================== --- seabios.orig/src/post.c +++ seabios/src/post.c @@ -135,10 +135,16 @@ ram_probe(void) , E820_RESERVED); add_e820(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED); - if (kvm_para_available()) - // 4 pages before the bios, 3 pages for vmx tss pages, the - // other page for EPT real mode pagetable - add_e820(0xfffbc000, 4*4096, E820_RESERVED); + if (kvm_para_available()) { + struct qemu_cfg_e820_reserve e820_reserve; + if (qemu_cfg_read_e820_reserve(&e820_reserve)) + add_e820(e820_reserve.addr, e820_reserve.length, E820_RESERVED); + else { + // 4 pages before the bios, 3 pages for vmx tss pages, the + // other page for EPT real mode pagetable + add_e820(0xfffbc000, 4*4096, E820_RESERVED); + } + } dprintf(1, "Ram Size=0x%08x (0x%08x%08x high)\n" , RamSize, (u32)(RamSizeOver4G >> 32), (u32)RamSizeOver4G);