Skip to contentSkip to conversation

get roms more room.

PATCH Applied Glauber Costa 4 participants 4 messages Mar 28, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 get roms more room.

This patch increases by 50 % the size available for option roms. The main motivator is that some roms grew bigger than the 64k we currently allocate for them (Hey, it's 2009!)

One example is the gpxe project, that produces some roms with 69k, 70k, etc. The space proposed by this patch actually makes it as big as 84k. Probably still a fit for some time.

But there is no free lunch. This space must come from somewhere, and we take it from vga rom space. Currently, our vga roms are around 35k in size. With this patch, option rom space will begin just after vga ends, aligned to the next 2k boundary.

Technicaly, we could do the same with the uper space (the bios itself), but since bochs bios is already 128 k in size, I don't see an urgent need to do it.

[ fix case for vgabioses smaller than 30k, by Carl-Daniel Hailfinger ]

---
 hw/pc.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
hw/pc.c +19 -10
index 69f25f3..f9cfd1f 100644
@@ -763,7 +763,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
 {
     char buf[1024];
     int ret, linux_boot, i;
-    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
+    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset, option_rom_start = 0;
     ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
     int bios_size, isa_bios_size, vga_bios_size;
     PCIBus *pci_bus;
@@ -774,6 +774,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
     int index;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     BlockDriverState *fd[MAX_FD];
+    int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
 
     if (ram_size >= 0xe0000000 ) {
         above_4g_mem_size = ram_size - 0xe0000000;
@@ -856,7 +857,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
         exit(1);
     }
 
-    if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
+    if (using_vga) {
         /* VGA BIOS load */
         if (cirrus_vga_enabled) {
             snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
@@ -874,12 +875,21 @@ vga_bios_error:
             fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
             exit(1);
         }
+	/* Round up vga bios size to the next 2k boundary */
+	vga_bios_size = (vga_bios_size + 2047) & ~2047;
+	option_rom_start = 0xc0000 + vga_bios_size;
 
         /* setup basic memory access */
-        cpu_register_physical_memory(0xc0000, 0x10000,
+        cpu_register_physical_memory(0xc0000, vga_bios_size,
                                      vga_bios_offset | IO_MEM_ROM);
     }
 
+    /* No point in placing option roms before this address, since bochs bios
+     * will only start looking for it at 0xc8000 */
+    if (option_rom_start < 0xc8000)
+	    option_rom_start = 0xc8000;
+
+
     /* map the last 128KB of the BIOS in ISA space */
     isa_bios_size = bios_size;
     if (isa_bios_size > (128 * 1024))
@@ -892,14 +902,14 @@ vga_bios_error:
         ram_addr_t option_rom_offset;
         int size, offset;
 
-        offset = 0;
+        offset = option_rom_start;
         if (linux_boot) {
             option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE);
             load_linux(phys_ram_base + option_rom_offset,
                        kernel_filename, initrd_filename, kernel_cmdline);
-            cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE,
+            cpu_register_physical_memory(option_rom_start, TARGET_PAGE_SIZE,
                                          option_rom_offset | IO_MEM_ROM);
-            offset = TARGET_PAGE_SIZE;
+            offset += TARGET_PAGE_SIZE;
         }
 
         for (i = 0; i < nb_option_roms; i++) {
@@ -909,18 +919,17 @@ vga_bios_error:
                         option_rom[i]);
                 exit(1);
             }
-            if (size > (0x10000 - offset))
+            if (size > (0xe0000  - offset))
                 goto option_rom_error;
             option_rom_offset = qemu_ram_alloc(size);
             ret = load_image(option_rom[i], phys_ram_base + option_rom_offset);
             if (ret != size) {
             option_rom_error:
-                fprintf(stderr, "Too many option ROMS\n");
+                fprintf(stderr, "Could not fit %soption roms in available space\n", using_vga ? "VGA bios and " : "");
                 exit(1);
             }
             size = (size + 4095) & ~4095;
-            cpu_register_physical_memory(0xd0000 + offset,
-                                         size, option_rom_offset | IO_MEM_ROM);
+            cpu_register_physical_memory(offset, size, option_rom_offset | IO_MEM_ROM);
             offset += size;
         }
     }
Signature · 1 line
1.6.2
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Glauber Costa

This patch increases by 50 % the size available for option roms. The main motivator is that some roms grew bigger than the 64k we currently allocate for them (Hey, it's 2009!)

One example is the gpxe project, that produces some roms with 69k, 70k, etc. The space proposed by this patch actually makes it as big as 84k. Probably still a fit for some time.

But there is no free lunch. This space must come from somewhere, and we take it from vga rom space. Currently, our vga roms are around 35k in size. With this patch, option rom space will begin just after vga ends, aligned to the next 2k boundary.

Quoted 8 lines

Technicaly, we could do the same with the uper space (the bios itself), but since bochs bios is already 128 k in size, I don't see an urgent need to do it.

[ fix case for vgabioses smaller than 30k, by Carl-Daniel Hailfinger ]

Thanks for your patience with my comments!

Regards,
Carl-Daniel

Signature · 1 line
http://www.hailfinger.org/
#2 lore raw
In reply to Glauber Costa
Quoted 13 lines · Glauber Costa

This patch increases by 50 % the size available for option roms. The main motivator is that some roms grew bigger than the 64k we currently allocate for them (Hey, it's 2009!)

One example is the gpxe project, that produces some roms with 69k, 70k, etc. The space proposed by this patch actually makes it as big as 84k. Probably still a fit for some time.

But there is no free lunch. This space must come from somewhere, and we take it from vga rom space. Currently, our vga roms are around 35k in size. With this patch, option rom space will begin just after vga ends, aligned to the next 2k boundary.

Quoted 8 lines

Technicaly, we could do the same with the uper space (the bios itself), but since bochs bios is already 128 k in size, I don't see an urgent need to do it.

[ fix case for vgabioses smaller than 30k, by Carl-Daniel Hailfinger ]

Applied. Thanks.

Sounds like it's time to switch to gpxe roms. I wonder what ever happened to the gpxe virtio-blk patches...

Regards,

Anthony Liguori

Quoted 98 lines
---
 hw/pc.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
hw/pc.c +19 -10
index 69f25f3..f9cfd1f 100644
@@ -763,7 +763,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
 {
     char buf[1024];
     int ret, linux_boot, i;
-    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
+    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset, option_rom_start = 0;
     ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
     int bios_size, isa_bios_size, vga_bios_size;
     PCIBus *pci_bus;
@@ -774,6 +774,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
     int index;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     BlockDriverState *fd[MAX_FD];
+    int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
 
     if (ram_size >= 0xe0000000 ) {
         above_4g_mem_size = ram_size - 0xe0000000;
@@ -856,7 +857,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
         exit(1);
     }
 
-    if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
+    if (using_vga) {
         /* VGA BIOS load */
         if (cirrus_vga_enabled) {
             snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
@@ -874,12 +875,21 @@ vga_bios_error:
             fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
             exit(1);
         }
+	/* Round up vga bios size to the next 2k boundary */
+	vga_bios_size = (vga_bios_size + 2047) & ~2047;
+	option_rom_start = 0xc0000 + vga_bios_size;
 
         /* setup basic memory access */
-        cpu_register_physical_memory(0xc0000, 0x10000,
+        cpu_register_physical_memory(0xc0000, vga_bios_size,
                                      vga_bios_offset | IO_MEM_ROM);
     }
 
+    /* No point in placing option roms before this address, since bochs bios
+     * will only start looking for it at 0xc8000 */
+    if (option_rom_start < 0xc8000)
+	    option_rom_start = 0xc8000;
+
+
     /* map the last 128KB of the BIOS in ISA space */
     isa_bios_size = bios_size;
     if (isa_bios_size > (128 * 1024))
@@ -892,14 +902,14 @@ vga_bios_error:
         ram_addr_t option_rom_offset;
         int size, offset;
 
-        offset = 0;
+        offset = option_rom_start;
         if (linux_boot) {
             option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE);
             load_linux(phys_ram_base + option_rom_offset,
                        kernel_filename, initrd_filename, kernel_cmdline);
-            cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE,
+            cpu_register_physical_memory(option_rom_start, TARGET_PAGE_SIZE,
                                          option_rom_offset | IO_MEM_ROM);
-            offset = TARGET_PAGE_SIZE;
+            offset += TARGET_PAGE_SIZE;
         }
 
         for (i = 0; i < nb_option_roms; i++) {
@@ -909,18 +919,17 @@ vga_bios_error:
                         option_rom[i]);
                 exit(1);
             }
-            if (size > (0x10000 - offset))
+            if (size > (0xe0000  - offset))
                 goto option_rom_error;
             option_rom_offset = qemu_ram_alloc(size);
             ret = load_image(option_rom[i], phys_ram_base + option_rom_offset);
             if (ret != size) {
             option_rom_error:
-                fprintf(stderr, "Too many option ROMS\n");
+                fprintf(stderr, "Could not fit %soption roms in available space\n", using_vga ? "VGA bios and " : "");
                 exit(1);
             }
             size = (size + 4095) & ~4095;
-            cpu_register_physical_memory(0xd0000 + offset,
-                                         size, option_rom_offset | IO_MEM_ROM);
+            cpu_register_physical_memory(offset, size, option_rom_offset | IO_MEM_ROM);
             offset += size;
         }
     }
#3 lore raw
Quoted 24 lines · Anthony Liguori
Quoted 14 lines · Glauber Costa

This patch increases by 50 % the size available for option roms. The main motivator is that some roms grew bigger than the 64k we currently allocate for them (Hey, it's 2009!)

One example is the gpxe project, that produces some roms with 69k, 70k, etc. The space proposed by this patch actually makes it as big as 84k. Probably still a fit for some time.

But there is no free lunch. This space must come from somewhere, and we take it from vga rom space. Currently, our vga roms are around 35k in size. With this patch, option rom space will begin just after vga ends, aligned to the next 2k boundary.

Quoted 8 lines

Technicaly, we could do the same with the uper space (the bios itself), but since bochs bios is already 128 k in size, I don't see an urgent need to do it.

[ fix case for vgabioses smaller than 30k, by Carl-Daniel Hailfinger ]

Quoted 6 lines

Applied.  Thanks.

Sounds like it's time to switch to gpxe roms.  I wonder what ever happened to the gpxe virtio-blk patches...

Regards,

Not yet.

There's still a patch that needs to be applied to the bios. I've already sent it to bochs-developers list, I believe it should go there, rather than here.

Also, currently gpxe does not work with kvm, just qemu. Stiil unsure why, but something to do with interrupts being disabled when they shouldn't. I'm still on this,
expect news soon.

Signature · 5 lines
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."