From: Jes Sorensen <Jes.Sorensen@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Kevin O'Connor <kevin@koconnor.net>,
QEMU Developers <qemu-devel@nongnu.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [Qemu-devel] [PATCH] QEMU e820 reservation patch
Date: Mon, 15 Feb 2010 18:33:46 +0100 [thread overview]
Message-ID: <4B79857A.1030808@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 178 bytes --]
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
[-- Attachment #2: 0001-qemu-e820-table.patch --]
[-- Type: text/plain, Size: 3646 bytes --]
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 <Jes.Sorensen@redhat.com>
---
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 <linux/kvm_para.h>
@@ -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);
}
next reply other threads:[~2010-02-15 17:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-15 17:33 Jes Sorensen [this message]
2010-02-15 18:54 ` [Qemu-devel] Re: [PATCH] QEMU e820 reservation patch Stefano Stabellini
2010-02-16 8:49 ` Jes Sorensen
2010-02-19 21:02 ` [Qemu-devel] " Anthony Liguori
2010-02-21 17:44 ` Jes Sorensen
2010-02-21 19:13 ` Kevin O'Connor
2010-02-22 8:33 ` Gleb Natapov
2010-02-23 1:31 ` Kevin O'Connor
2010-02-23 8:22 ` Gleb Natapov
2010-02-23 13:50 ` Anthony Liguori
2010-02-23 14:01 ` Gleb Natapov
2010-02-22 9:23 ` Avi Kivity
2010-02-19 22:00 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B79857A.1030808@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=kevin@koconnor.net \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.