Skip to contentSkip to conversation

vga: fix vram double-mapping with -vga std and -M pc-0.12

PATCH In review Avi Kivity 2 participants 3 messages May 9, 2012 – May 14, 2012

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 vga: fix vram double-mapping with -vga std and -M pc-0.12

With pc-0.12, we map the video RAM both through the PCI BAR (the guest does this) and through a fixed mapping at 0xe0000000. The memory API doesn't allow this double map, and aborts.

Fix by using an alias.

---
 hw/vga.c     |    7 ++++++-
 hw/vga_int.h |    1 +
 2 files changed, 7 insertions(+), 1 deletion(-)
hw/vga.c +6 -1
index 5824f85..d784df7 100644
@@ -2357,10 +2357,15 @@ void vga_init(VGACommonState *s, MemoryRegion *address_space,
 void vga_init_vbe(VGACommonState *s, MemoryRegion *system_memory)
 {
 #ifdef CONFIG_BOCHS_VBE
+    /* With pc-0.12 and below we map both the PCI BAR and the fixed VBE region,
+     * so use an alias to avoid double-mapping the same region.
+     */
+    memory_region_init_alias(&s->vram_vbe, "vram.vbe",
+                             &s->vram, 0, memory_region_size(&s->vram));
     /* XXX: use optimized standard vga accesses */
     memory_region_add_subregion(system_memory,
                                 VBE_DISPI_LFB_PHYSICAL_ADDRESS,
-                                &s->vram);
+                                &s->vram_vbe);
     s->vbe_mapped = 1;
 #endif 
 }
hw/vga_int.h +1 -0
index 7685b2b..d244d8f 100644
@@ -105,6 +105,7 @@ typedef struct VGACommonState {
     MemoryRegion *legacy_address_space;
     uint8_t *vram_ptr;
     MemoryRegion vram;
+    MemoryRegion vram_vbe;
     uint32_t vram_size;
     uint32_t latch;
     MemoryRegion *chain4_alias;
Signature · 1 line
1.7.10.1
Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Avi Kivity

With pc-0.12, we map the video RAM both through the PCI BAR (the guest does this) and through a fixed mapping at 0xe0000000. The memory API doesn't allow this double map, and aborts.

Fix by using an alias.

This appears to work now, at least with -M pc-0.12 -vga std, a win7 guest boots and works (before qemu were aborting at startup). So you can add

if necessary. Thank you for the quick fix!

/mjt

author
#2 lore raw
In reply to Avi Kivity
Quoted 7 lines · Avi Kivity

With pc-0.12, we map the video RAM both through the PCI BAR (the guest does this) and through a fixed mapping at 0xe0000000. The memory API doesn't allow this double map, and aborts.

Fix by using an alias.

Ping; should be 1.1ed.

Signature · 1 line
error compiling committee.c: too many arguments to function