hvmloader: fix SeaBIOS interface
authorJan Beulich <jbeulich@suse.com>
Thu, 5 Sep 2013 09:47:03 +0000 (11:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 5 Sep 2013 09:47:03 +0000 (11:47 +0200)
The SeaBIOS ROM image may validly exceed 128k in size, it's only our
interface code that so far assumed that it wouldn't. Remove that
restriction by setting the base address depending on image size.

Add a check to HVM loader so that too big images won't result in silent
guest failure anymore.

Uncomment the intended build-time size check for rombios, moving it
into a function so that it would actually compile.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/firmware/hvmloader/config-seabios.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/hvmloader/rombios.c
tools/firmware/hvmloader/seabios.c

index e025243a3aec840e475b238744b5330c76630ea6..c4d114270a9f79fc1e5985a19057414d3ad29eee 100644 (file)
@@ -3,8 +3,6 @@
 
 #define BIOS_INFO_PHYSICAL_ADDRESS  0x00001000
 
-#define SEABIOS_PHYSICAL_ADDRESS    0x000E0000
-
 #endif /* __HVMLOADER_CONFIG_SEABIOS_H__ */
 
 /*
index 9c1cba2211d7f837e55d2519b8b9d3cf367205f6..1cc8cf2801526489c745003c469d1c24f8076b32 100644 (file)
@@ -292,8 +292,12 @@ int main(void)
     if ( bios->bios_load )
         bios->bios_load(bios);
     else
+    {
+        BUG_ON(bios->bios_address + bios->image_size >
+               HVMLOADER_PHYSICAL_ADDRESS);
         memcpy((void *)bios->bios_address, bios->image,
                bios->image_size);
+    }
 
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     {
index f6f5310b6dfcdd9f6ae53418436906bf48ffc7d0..810bd24ce7393f9c0de60411adcd2b4ffdeea904 100644 (file)
@@ -127,6 +127,8 @@ static void rombios_load(const struct bios_config *config)
     uint32_t bioshigh;
     struct rombios_info *info;
 
+    BUILD_BUG_ON(sizeof(rombios) > 0x100000 - ROMBIOS_PHYSICAL_ADDRESS);
+
     memcpy((void *)config->bios_address, config->image,
            config->image_size);
 
@@ -206,8 +208,6 @@ static void rombios_create_smbios_tables(void)
         SMBIOS_PHYSICAL_END);
 }
 
-//BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS));
-
 struct bios_config rombios_config =  {
     .name = "ROMBIOS",
 
index f17e67b32e90cdff39e7385d658fc23611a4e26d..dd7dfbe0e8a571e2239a1753d38fa0d1b8f0b5c7 100644 (file)
@@ -133,15 +133,13 @@ static void seabios_setup_e820(void)
     dump_e820_table(e820, info->e820_nr);
 }
 
-//BUILD_BUG_ON(sizeof(seabios) > (0x00100000U - SEABIOS_PHYSICAL_ADDRESS));
-
 struct bios_config seabios_config = {
     .name = "SeaBIOS",
 
     .image = seabios,
     .image_size = sizeof(seabios),
 
-    .bios_address = SEABIOS_PHYSICAL_ADDRESS,
+    .bios_address = 0x100000 - sizeof(seabios),
 
     .load_roms = NULL,