Seabios e820 reservation portion v3
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 16 Feb 2010 08:46:08 +0000 (09:46 +0100)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 21 Feb 2010 19:15:44 +0000 (14:15 -0500)
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 <Jes.Sorensen@redhat.com>
src/paravirt.c
src/paravirt.h
src/post.c

index fc0cbfe11e6c31acb481860066a341849b3ff1fa..5c77b5c7d06395893facaf1e16b83079ec468142 100644 (file)
@@ -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 4cef48e16e51c6f00e357ba9a759eab92aa98f96..c46418f5261fd4cd8705d6eb4fd48a800436f68b 100644 (file)
@@ -36,6 +36,7 @@ static inline int kvm_para_available(void)
 #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 fb3b37f96d06d268d5071b828e91c272c22ef88c..c781aa44ea555c9f537b376d154876f579f8ccd8 100644 (file)
@@ -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);