From patchwork Mon Feb 15 17:33:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 45412 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 A9E2CB7CF4 for ; Tue, 16 Feb 2010 04:37:49 +1100 (EST) Received: from localhost ([127.0.0.1]:38865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh4rN-0005MP-PM for incoming@patchwork.ozlabs.org; Mon, 15 Feb 2010 12:35:49 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nh4pa-00053N-Jh for qemu-devel@nongnu.org; Mon, 15 Feb 2010 12:33:58 -0500 Received: from [199.232.76.173] (port=37275 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh4pa-000530-2l for qemu-devel@nongnu.org; Mon, 15 Feb 2010 12:33:58 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nh4pZ-00025C-0g for qemu-devel@nongnu.org; Mon, 15 Feb 2010 12:33:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14456) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nh4pY-00024m-HJ for qemu-devel@nongnu.org; Mon, 15 Feb 2010 12:33:56 -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 o1FHXo0I010334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Feb 2010 12:33:50 -0500 Received: from [172.17.92.15] (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 o1FHXlNn031022; Mon, 15 Feb 2010 12:33:48 -0500 Message-ID: <4B79857A.1030808@redhat.com> Date: Mon, 15 Feb 2010 18:33:46 +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: Anthony Liguori 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: Kevin O'Connor , QEMU Developers , Stefano Stabellini Subject: [Qemu-devel] [PATCH] QEMU e820 reservation patch 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, Kevin and I have agreed on the approach for this one now. So here is the latest version of the patch for QEMU, submitting e820 reservation entries via fw_cfg. Cheers, Jes Use qemu-cfg to provide the BIOS with an optional table of e820 entries. Notify the BIOS of the location of the TSS+EPT range to by reserving it via the e820 table. This matches a corresponding patch for Seabios, however older versions of Seabios will default to the hardcoded address range and stay compatible with current QEMU. Signed-off-by: Jes Sorensen Acked-by: Anthony Liguori --- hw/pc.c | 35 +++++++++++++++++++++++++++++++++++ hw/pc.h | 10 ++++++++++ target-i386/kvm.c | 8 ++++++++ 3 files changed, 53 insertions(+) Index: qemu/hw/pc.c =================================================================== --- qemu.orig/hw/pc.c +++ qemu/hw/pc.c @@ -59,6 +59,7 @@ #define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0) #define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1) #define FW_CFG_IRQ0_OVERRIDE (FW_CFG_ARCH_LOCAL + 2) +#define FW_CFG_E820_TABLE (FW_CFG_ARCH_LOCAL + 3) #define MAX_IDE_BUS 2 @@ -67,6 +68,21 @@ static RTCState *rtc_state; static PITState *pit; static PCII440FXState *i440fx_state; +#define E820_NR_ENTRIES 16 + +struct e820_entry { + uint64_t address; + uint64_t length; + uint32_t type; +}; + +struct e820_table { + uint32_t count; + struct e820_entry entry[E820_NR_ENTRIES]; +}; + +static struct e820_table e820_table; + typedef struct isa_irq_state { qemu_irq *i8259; qemu_irq *ioapic; @@ -435,6 +451,23 @@ static void bochs_bios_write(void *opaqu } } +int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) +{ + int index = e820_table.count; + struct e820_entry *entry; + + if (index >= E820_NR_ENTRIES) + return -EBUSY; + entry = &e820_table.entry[index]; + + entry->address = address; + entry->length = length; + entry->type = type; + + e820_table.count++; + return e820_table.count; +} + static void *bochs_bios_init(void) { void *fw_cfg; @@ -466,6 +499,8 @@ static void *bochs_bios_init(void) if (smbios_table) fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_table, smbios_len); + fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, (uint8_t *)&e820_table, + sizeof(struct e820_table)); /* allocate memory for the NUMA channel: one (64bit) word for the number * of nodes, one word for each VCPU->node and one word for each node to Index: qemu/hw/pc.h =================================================================== --- qemu.orig/hw/pc.h +++ qemu/hw/pc.h @@ -150,4 +150,14 @@ void isa_cirrus_vga_init(void); void isa_ne2000_init(int base, int irq, NICInfo *nd); int cpu_is_bsp(CPUState *env); + +/* e820 types */ +#define E820_RAM 1 +#define E820_RESERVED 2 +#define E820_ACPI 3 +#define E820_NVS 4 +#define E820_UNUSABLE 5 + +int e820_add_entry(uint64_t, uint64_t, uint32_t); + #endif Index: qemu/target-i386/kvm.c =================================================================== --- qemu.orig/target-i386/kvm.c +++ qemu/target-i386/kvm.c @@ -24,6 +24,7 @@ #include "cpu.h" #include "gdbstub.h" #include "host-utils.h" +#include "hw/pc.h" #ifdef CONFIG_KVM_PARA #include @@ -362,6 +363,13 @@ int kvm_arch_init(KVMState *s, int smp_c * as unavaible memory. FIXME, need to ensure the e820 map deals with * this? */ + /* + * Tell fw_cfg to notify the BIOS to reserve the range. + */ + if (e820_add_entry(0xfffbc000, 0x4000, E820_RESERVED) < 0) { + perror("e820_add_entry() table is full"); + exit(1); + } return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000); }