From patchwork Tue Feb 16 08:46:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 45457 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 40216B7CB6 for ; Tue, 16 Feb 2010 20:15:47 +1100 (EST) Received: from localhost ([127.0.0.1]:45731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhJMv-0003LZ-2R for incoming@patchwork.ozlabs.org; Tue, 16 Feb 2010 04:05:21 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NhJ4Z-0007ZT-9S for qemu-devel@nongnu.org; Tue, 16 Feb 2010 03:46:23 -0500 Received: from [199.232.76.173] (port=33472 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhJ4W-0007ZF-87 for qemu-devel@nongnu.org; Tue, 16 Feb 2010 03:46:20 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NhJ4V-0006Q0-9R for qemu-devel@nongnu.org; Tue, 16 Feb 2010 03:46:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18267) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NhJ4U-0006Ps-SI for qemu-devel@nongnu.org; Tue, 16 Feb 2010 03:46:19 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1G8kDhE022924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 16 Feb 2010 03:46:13 -0500 Received: from [172.17.80.9] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1G8k98G008378; Tue, 16 Feb 2010 03:46:10 -0500 Message-ID: <4B7A5B50.7050800@redhat.com> Date: Tue, 16 Feb 2010 09:46:08 +0100 From: Jes Sorensen User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc12 Lightning/1.0b2pre Thunderbird/3.0.1 MIME-Version: 1.0 To: "Kevin O'Connor" References: <4B798587.8080906@redhat.com> <20100216004322.GD9677@morn.localdomain> In-Reply-To: <20100216004322.GD9677@morn.localdomain> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Anthony Liguori , seabios@seabios.org, QEMU Developers , Stefano Stabellini Subject: [Qemu-devel] [PATCH] Seabios e820 reservation portion v3 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 On 02/16/10 01:43, Kevin O'Connor wrote: > On Mon, Feb 15, 2010 at 06:33:59PM +0100, Jes Sorensen wrote: >> Hi, >> >> This is the Seabios part to match my e820 reservation via fw_cfg patch. > > This still has 'struct e820_entry' which is too similar to 'struct > e820entry' in memmap.h. Otherwise, it looks good to me. Hmmm didn't catch that one earlier, thanks for pointing it out. I have renamed it to struct e820_reservation to make it different. Hope this version does the trick then. Cheers, Jes Read optional table of e820 entries from qemu_cfg Read optional table of e820 entries through qemu_cfg, allowing QEMU to provide the location of KVM's switch area etc. rather than rely on hard coded values. For now, fall back to the old hard coded values for the TSS and EPT switch page for compatibility reasons. Compatibility code could possibly be removed in the future. Signed-off-by: Jes Sorensen --- src/paravirt.c | 17 +++++++++++++++++ src/paravirt.h | 9 +++++++++ src/post.c | 13 ++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) Index: seabios/src/paravirt.c =================================================================== --- seabios.orig/src/paravirt.c +++ seabios/src/paravirt.c @@ -132,6 +132,23 @@ u16 qemu_cfg_smbios_entries(void) return cnt; } +u32 qemu_cfg_e820_entries(void) +{ + u32 cnt; + + if (!qemu_cfg_present) + return 0; + + qemu_cfg_read_entry(&cnt, QEMU_CFG_E820_TABLE, sizeof(cnt)); + return cnt; +} + +void* qemu_cfg_e820_load_next(void *addr) +{ + qemu_cfg_read(addr, sizeof(struct e820_reservation)); + return addr; +} + 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_TABLE (QEMU_CFG_ARCH_LOCAL + 3) extern int qemu_cfg_present; @@ -61,8 +62,16 @@ typedef struct QemuCfgFile { char name[56]; } QemuCfgFile; +struct e820_reservation { + u64 address; + u64 length; + u32 type; +}; + 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); +u32 qemu_cfg_e820_entries(void); +void* qemu_cfg_e820_load_next(void *addr); #endif Index: seabios/src/post.c =================================================================== --- seabios.orig/src/post.c +++ seabios/src/post.c @@ -135,10 +135,21 @@ ram_probe(void) , E820_RESERVED); add_e820(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED); - if (kvm_para_available()) + u32 count = qemu_cfg_e820_entries(); + if (count) { + struct e820_reservation entry; + int i; + + for (i = 0; i < count; i++) { + qemu_cfg_e820_load_next(&entry); + add_e820(entry.address, entry.length, entry.type); + } + } else if (kvm_para_available()) { + // Backwards compatibility - provide hard coded range. // 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);