From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZtKi-0004es-Ri for qemu-devel@nongnu.org; Tue, 26 Jan 2010 16:52:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZtKe-0004XQ-2V for qemu-devel@nongnu.org; Tue, 26 Jan 2010 16:52:24 -0500 Received: from [199.232.76.173] (port=39910 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZtKe-0004XL-08 for qemu-devel@nongnu.org; Tue, 26 Jan 2010 16:52:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45709) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZtKd-0007mv-Ml for qemu-devel@nongnu.org; Tue, 26 Jan 2010 16:52:19 -0500 Message-ID: <4B5F640C.2030907@redhat.com> Date: Tue, 26 Jan 2010 22:52:12 +0100 From: Jes Sorensen MIME-Version: 1.0 References: <4B5DCAF2.3010105@redhat.com> <20100126002447.GA8800@morn.localdomain> In-Reply-To: <20100126002447.GA8800@morn.localdomain> Content-Type: multipart/mixed; boundary="------------070200010106010907010400" Subject: [Qemu-devel] [PATCH] Seabios - read e820 table from qemu_cfg List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin O'Connor Cc: Anthony Liguori , kvm@vger.kernel.org, seabios@seabios.org, Alexander Graf , qemu-devel@nongnu.org, Avi Kivity This is a multi-part message in MIME format. --------------070200010106010907010400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, Based on the feedback I received over the e820 reserve patch, I have changed it to have QEMU pass in a list of entries that can cover more than just the TSS/EPT range. This should provide the flexibility that people were asking for. The Seabios portion should allow for unlimited sized tables in theory, whereas for QEMU I have set a fixed limit for now, but it can easily be extended. Please let me know what you think of this version! Cheers, Jes --------------070200010106010907010400 Content-Type: text/plain; name="0005-seabios-e820-table.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0005-seabios-e820-table.patch" 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 | 23 +++++++++++++++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) 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); --------------070200010106010907010400--