From patchwork Tue Jan 26 21:52:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 75241 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0QLqUm3016014 for ; Tue, 26 Jan 2010 21:52:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754792Ab0AZVw0 (ORCPT ); Tue, 26 Jan 2010 16:52:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754807Ab0AZVw0 (ORCPT ); Tue, 26 Jan 2010 16:52:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49133 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754412Ab0AZVwZ (ORCPT ); Tue, 26 Jan 2010 16:52:25 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0QLqGvb009804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 26 Jan 2010 16:52:16 -0500 Received: from [10.36.4.211] (vpn1-4-211.ams2.redhat.com [10.36.4.211]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0QLqCIp012632; Tue, 26 Jan 2010 16:52:13 -0500 Message-ID: <4B5F640C.2030907@redhat.com> Date: Tue, 26 Jan 2010 22:52:12 +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: "Kevin O'Connor" CC: qemu-devel@nongnu.org, kvm@vger.kernel.org, Avi Kivity , Anthony Liguori , seabios@seabios.org, Alexander Graf Subject: [PATCH] Seabios - read e820 table from qemu_cfg References: <4B5DCAF2.3010105@redhat.com> <20100126002447.GA8800@morn.localdomain> In-Reply-To: <20100126002447.GA8800@morn.localdomain> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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_entry)); + 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_entry { + 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,25 @@ 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()) { + u32 count; + + count = qemu_cfg_e820_entries(); + if (count) { + struct e820_entry entry; + int i; + + for (i = 0; i < count; i++) { + qemu_cfg_e820_load_next(&entry); + add_e820(entry.address, entry.length, entry.type); + } + } else { + // 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);