Skip to contentSkip to conversation

align vga rom to 4k boundary.

PATCH In review Glauber Costa 2 participants 2 messages Apr 7, 2009 – Apr 11, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 align vga rom to 4k boundary.

Instead of aligning to 2k boundary, as required by the bios, align to 4k boundary, as required by kvm memory functions. Without this patch, starting kvm with -vga std option fails with:

create_userspace_phys_mem: Invalid argument
kvm_cpu_register_physical_memory: failed

as described by: https://bugzilla.redhat.com/show_bug.cgi?id=494376

It does not fail with cirrus vga, because it is naturally aligned. This problem does not seem to affect upstream qemu.

---
 qemu/hw/pc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu/hw/pc.c +1 -1
index cc84772..680d4a2 100644
@@ -919,7 +919,7 @@ vga_bios_error:
             exit(1);
         }
 	/* Round up vga bios size to the next 2k boundary */
-	vga_bios_size = (vga_bios_size + 2047) & ~2047;
+	vga_bios_size = (vga_bios_size + 4095) & ~4095;
 	option_rom_start = 0xc0000 + vga_bios_size;
 
         /* setup basic memory access */
Signature · 1 line
1.5.6.6
#1 lore raw
Quoted 15 lines · Glauber Costa

Instead of aligning to 2k boundary, as required by the bios, align to 4k boundary, as required by kvm memory functions. Without this patch, starting kvm with -vga std option fails with:

create_userspace_phys_mem: Invalid argument
kvm_cpu_register_physical_memory: failed

as described by: https://bugzilla.redhat.com/show_bug.cgi?id=494376

It does not fail with cirrus vga, because it is naturally aligned. This problem does not seem to affect upstream qemu.

             exit(1);
         }

qemu/hw/pc.c vga_bios_error: · line 925

Quoted 6 lines
qemu/hw/pc.c +1 -1
 	/* Round up vga bios size to the next 2k boundary */
-	vga_bios_size = (vga_bios_size + 2047) & ~2047;
+	vga_bios_size = (vga_bios_size + 4095) & ~4095;
 	option_rom_start = 0xc0000 + vga_bios_size;
 
         /* setup basic memory access */

Comment needs updating.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.