aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firmware
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-06-08 13:40:23 +0100
committerIan Campbell <ian.campbell@citrix.com>2011-06-08 13:40:23 +0100
commitd021c77cb426eaa762986eb02c4121c9da593036 (patch)
tree2e3cf97686c5231096c39d7d111e4cc21e262481 /tools/firmware
parent7096575dcdc0d87e16e381bf87d937d852560a73 (diff)
downloadxen-d021c77cb426eaa762986eb02c4121c9da593036.tar.gz
xen-d021c77cb426eaa762986eb02c4121c9da593036.tar.bz2
xen-d021c77cb426eaa762986eb02c4121c9da593036.zip
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. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/firmware')
-rw-r--r--tools/firmware/hvmloader/config.h3
-rw-r--r--tools/firmware/hvmloader/e820.c81
-rw-r--r--tools/firmware/hvmloader/rombios.c10
-rw-r--r--tools/firmware/hvmloader/seabios.c4
-rw-r--r--tools/firmware/hvmloader/util.h4
5 files changed, 77 insertions, 25 deletions
diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h
index d916442ce3..989dd345cd 100644
--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -66,6 +66,9 @@ extern unsigned long pci_mem_start, pci_mem_end;
#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__ */
diff --git a/tools/firmware/hvmloader/e820.c b/tools/firmware/hvmloader/e820.c
index 9ab5380a6b..710532f761 100644
--- a/tools/firmware/hvmloader/e820.c
+++ b/tools/firmware/hvmloader/e820.c
@@ -69,28 +69,67 @@ void dump_e820_table(struct e820entry *e820, unsigned int nr)
}
/* Create an E820 table based on memory parameters provided in hvm_info. */
-int build_e820_table(struct e820entry *e820)
+int build_e820_table(struct e820entry *e820,
+ unsigned int lowmem_reserved_base,
+ unsigned int bios_image_base)
{
unsigned int nr = 0;
- /* 0x0-0x9E000: Ordinary RAM. */
- /* (Must be at least 512K to keep Windows happy) */
- e820[nr].addr = 0x00000;
- e820[nr].size = 0x9E000;
- e820[nr].type = E820_RAM;
- nr++;
+ if ( !lowmem_reserved_base )
+ lowmem_reserved_base = 0xA0000;
- /* 0x9E000-0x9FC00: Reserved for internal use. */
- e820[nr].addr = 0x9E000;
- e820[nr].size = 0x01C00;
- e820[nr].type = E820_RESERVED;
- nr++;
+ /* Lowmem must be at least 512K to keep Windows happy) */
+ ASSERT ( lowmem_reserved_base > 512<<10 );
- /* 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA). */
- e820[nr].addr = 0x9FC00;
- e820[nr].size = 0x400;
- e820[nr].type = E820_RESERVED;
- nr++;
+ /*
+ * Lowmem reservation must either cover the ACPI info region
+ * entirely or not at all. Sitting half way through suggests
+ * something funny is going on.
+ */
+ ASSERT ( lowmem_reserved_base < ACPI_INFO_PHYSICAL_ADDRESS ||
+ lowmem_reserved_base > ACPI_INFO_PHYSICAL_END );
+
+ ASSERT ( bios_image_base < 0x100000 );
+
+ if ( lowmem_reserved_base < ACPI_INFO_PHYSICAL_ADDRESS ) {
+ /*
+ * 0x0-lowmem_reserved_base: Ordinary RAM.
+ */
+ e820[nr].addr = 0x00000;
+ e820[nr].size = lowmem_reserved_base;
+ e820[nr].type = E820_RAM;
+ nr++;
+ }
+ else
+ {
+ /* 0x0-ACPI_INFO: Ordinary RAM. */
+ e820[nr].addr = 0x00000;
+ e820[nr].size = ACPI_INFO_PHYSICAL_ADDRESS;
+ e820[nr].type = E820_RAM;
+ nr++;
+
+ /* ACPI INFO: Reserved. */
+ e820[nr].addr = ACPI_INFO_PHYSICAL_ADDRESS;
+ e820[nr].size = ACPI_INFO_SIZE;
+ e820[nr].type = E820_RESERVED;
+ nr++;
+
+ /* ACPI_INFO-lowmem_reserved_base: Ordinary RAM. */
+ e820[nr].addr = ACPI_INFO_PHYSICAL_END;
+ e820[nr].size = lowmem_reserved_base - ACPI_INFO_PHYSICAL_END;
+ e820[nr].type = E820_RAM;
+ nr++;
+ }
+
+ /* lowmem_reserved_base-0xa00000: reserved by BIOS implementation. */
+ if ( lowmem_reserved_base < 0xA0000 )
+ {
+ /* Reserved for internal use. */
+ e820[nr].addr = lowmem_reserved_base;
+ e820[nr].size = 0xA0000-lowmem_reserved_base;
+ e820[nr].type = E820_RESERVED;
+ nr++;
+ }
/*
* Following regions are standard regions of the PC memory map.
@@ -101,12 +140,10 @@ int build_e820_table(struct e820entry *e820)
*/
/*
- * 0xE0000-0x0F0000: PC-specific area. We place various tables here.
- * 0xF0000-0x100000: System BIOS.
- * TODO: free pages which turn out to be unused.
+ * BIOS region.
*/
- e820[nr].addr = 0xE0000;
- e820[nr].size = 0x20000;
+ e820[nr].addr = bios_image_base;
+ e820[nr].size = 0x100000-bios_image_base;
e820[nr].type = E820_RESERVED;
nr++;
diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c
index 137167386d..96ba718f3f 100644
--- a/tools/firmware/hvmloader/rombios.c
+++ b/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);
}
diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c
index 7297f511ff..8cd01085f7 100644
--- a/tools/firmware/hvmloader/seabios.c
+++ b/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);
}
diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h
index 27c7f90ab9..3eb6845be9 100644
--- a/tools/firmware/hvmloader/util.h
+++ b/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