Skip to contentSkip to conversation

hvmloader: reduce unnecessary e820 reservations for SeaBIOS

PATCH New Ian Campbell 1 participant 1 message Jun 6, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hvmloader: reduce unnecessary e820 reservations for SeaBIOS

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1307373107 -3600
# Node ID b9f424fd0c854afb3fd76090fdbe1ac534be2eff # Parent b4ec90b846d342858c2efbef2f18bf5f4b1959e6
hvmloader: reduce unnecessary e820 reservations for SeaBIOS

SeaBIOS will reserve memory in the e820 as necessary, including BIOS data structures such as the EBDA, any tables it creates or copies into pleace etc. Therefore arrange that the memory map provided by hvmloader to SeaBIOS reserves only things which HVMloader has created.

Since ROMBIOS is more tightly coupled with hvmloader we retain the ability to reserve BIOS regions in the hvmloader produced e820 and use that from the ROMBIOS backend.

The code for this could probably have been simpler but the existing code avoids overlapping e820 areas and so the new code does the same (many guest OSes sanitize the e820 map to handle this, but I wouldn't trust that all do, so I didn't take the risk)

For ROMBIOS the resulting e820 map as seen by the guest is the same except the reserved regions at 0x9e000-0x9fc00,0x9fc00-0xa0000 are merged into a single region 0x9e000-0xa0000 (Linux guests sanitize the e820 to look like this anyway).

For SeaBIOS the result is that the lowmem reserved region is from 0x9f000-0xa0000 rather than 0x9e000-0xa0000 which correctly reflects SeaBIOS's actual usage.

tools/firmware/hvmloader/config.h +3 -0
diff -r b4ec90b846d3 -r b9f424fd0c85 tools/firmware/hvmloader/config.h
@@ -66,6 +66,9 @@ extern unsigned long pci_mem_start, pci_
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
 #define HVMLOADER_PHYSICAL_ADDRESS    0x00100000
 
+#define ACPI_INFO_SIZE                     0xC00
+#define ACPI_INFO_PHYSICAL_END (ACPI_INFO_PHYSICAL_ADDRESS + ACPI_INFO_SIZE)
+
 extern unsigned long scratch_start;
 
 #endif /* __HVMLOADER_CONFIG_H__ */
tools/firmware/hvmloader/e820.c +59 -22

99 lines not on this page · raw message

tools/firmware/hvmloader/rombios.c +9 -1
diff -r b4ec90b846d3 -r b9f424fd0c85 tools/firmware/hvmloader/rombios.c
@@ -61,7 +61,15 @@ static void rombios_init_vm86_tss(void)
 
 static void rombios_setup_e820(void)
 {
-    *E820_NR = build_e820_table(E820);
+    /*
+     * 0x9E000-0x09F000: Stack.
+     * 0x9F000-0x09C000: ACPI info.
+     * 0x9FC00-0x0A0000: Extended BIOS Data Area (EBDA).
+     * ...
+     * 0xE0000-0x0F0000: PC-specific area. We place various tables here.
+     * 0xF0000-0x100000: System BIOS.
+     */
+    *E820_NR = build_e820_table(E820, 0x9E000, 0xE0000);
     dump_e820_table(E820, *E820_NR);
 }
 
tools/firmware/hvmloader/seabios.c +3 -1
diff -r b4ec90b846d3 -r b9f424fd0c85 tools/firmware/hvmloader/seabios.c
@@ -117,7 +117,9 @@ static void seabios_setup_e820(void)
     struct seabios_info *info = (void *)BIOS_INFO_PHYSICAL_ADDRESS;
     struct e820entry *e820 = scratch_alloc(sizeof(struct e820entry)*16, 0);
     info->e820 = (uint32_t)e820;
-    info->e820_nr = build_e820_table(e820);
+
+    /* SeaBIOS reserves memory in e820 as necessary so no low reservation. */
+    info->e820_nr = build_e820_table(e820, 0, 0x100000-sizeof(seabios));
     dump_e820_table(e820, info->e820_nr);
 }
 
tools/firmware/hvmloader/util.h +3 -1
diff -r b4ec90b846d3 -r b9f424fd0c85 tools/firmware/hvmloader/util.h
@@ -200,7 +200,9 @@ unsigned long create_pir_tables(void);
 void smp_initialise(void);
 
 #include "e820.h"
-int build_e820_table(struct e820entry *e820);
+int build_e820_table(struct e820entry *e820,
+		     unsigned int lowmem_reserved_base,
+		     unsigned int bios_image_base);
 void dump_e820_table(struct e820entry *e820, unsigned int nr);
 
 #ifndef NDEBUG