]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
kvmvapic: align start address as well as size
authorAvi Kivity <avi@redhat.com>
Tue, 6 Mar 2012 15:50:10 +0000 (17:50 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 14 Mar 2012 20:30:38 +0000 (15:30 -0500)
The kvmvapic code remaps a section of ROM as RAM to allow the guest to
maintain state there.  It is careful to align the section size to a page
boundary, to avoid creating subpages, but neglects to do the same for
the start address.  These leads to an assert later on when the memory
core tries to create a page which is half RAM and half ROM.

Fix by aligning the start address to a page boundary.

This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/kvmvapic.c

index 36ccfbcdbdfbebae0d5df4f29f7451bb0934971a..e8bfeec3de27ff974d932077d3731fe8883f82a5 100644 (file)
@@ -578,8 +578,10 @@ static void vapic_map_rom_writable(VAPICROMState *s)
     rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
     s->rom_size = rom_size;
 
-    /* We need to round up to avoid creating subpages
+    /* We need to round to avoid creating subpages
      * from which we cannot run code. */
+    rom_size += rom_paddr & ~TARGET_PAGE_MASK;
+    rom_paddr &= TARGET_PAGE_MASK;
     rom_size = TARGET_PAGE_ALIGN(rom_size);
 
     memory_region_init_alias(&s->rom, "kvmvapic-rom", section.mr, rom_paddr,