From 881cff0ae7424098dd4761b41398a1be4c7a3ce6 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 5 Aug 2008 13:24:47 +0100 Subject: [PATCH] xend does not pass us -m option, so direct HVM Linux loading approximates end of low memory via a different method. Signed-off-by: Keir Fraser --- hw/pc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index f6a5d46b..c13e4537 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -45,9 +45,6 @@ #define PC_MAX_BIOS_SIZE (4 * 1024 * 1024) -/* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */ -#define ACPI_DATA_SIZE 0x10000 - #define MAX_IDE_BUS 2 static fdctrl_t *floppy_controller; @@ -536,6 +533,7 @@ static void load_linux(const char *kernel_filename, uint16_t seg[6]; uint16_t real_seg; int setup_size, kernel_size, initrd_size, cmdline_size; + unsigned long end_low_ram; uint32_t initrd_max; uint8_t header[1024]; target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr; @@ -589,14 +587,14 @@ static void load_linux(const char *kernel_filename, (size_t)prot_addr); #endif - /* highest address for loading the initrd */ - if (protocol >= 0x203) - initrd_max = ldl_p(header+0x22c); - else - initrd_max = 0x37ffffff; + /* Special pages are placed at end of low RAM: pick an arbitrary one and + * subtract a suitably large amount of padding (64kB) to skip BIOS data. */ + xc_get_hvm_param(xc_handle, domid, HVM_PARAM_BUFIOREQ_PFN, &end_low_ram); + end_low_ram = (end_low_ram << 12) - (64*1024); - if (initrd_max >= ram_size-ACPI_DATA_SIZE) - initrd_max = ram_size-ACPI_DATA_SIZE-1; + /* highest address for loading the initrd */ + initrd_max = (protocol >= 0x203) ? ldl_p(header+0x22c) : 0x37ffffff; + initrd_max = MIN(initrd_max, (uint32_t)end_low_ram); /* kernel command line */ pstrcpy_targphys(cmdline_addr, 4096, kernel_cmdline); -- 2.39.5