Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 785

kvm-83-270.el5_11.src.rpm

From 900c0552fd45bef03081ed97b4a830370a714fc2 Mon Sep 17 00:00:00 2001
From: Glauber Costa <glommer@redhat.com>
Date: Fri, 11 Dec 2009 18:30:32 -0200
Subject: [PATCH 4/4] v2: RHEL5 BZ543979 get roms more room. (Glauber Costa)

RH-Author: Glauber Costa <glommer@redhat.com>
Message-id: <1260556232-17767-1-git-send-email-glommer@redhat.com>
Patchwork-id: 3928
O-Subject: [PATCH] v2: RHEL5 BZ543979 get roms more room. (Glauber Costa)
Bugzilla: 543979
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>

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 ]

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

[ RHv2: include dev assignment changes, by Juan ]
Signed-off-by: Glauber Costa <glommer@redhat.com>
RH-Upstream-status: qemu/master
RH-Bugzilla: 543979
---
 qemu/hw/device-assignment.c |    8 ++++----
 qemu/hw/pc.c                |   28 ++++++++++++++++++----------
 2 files changed, 22 insertions(+), 14 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/hw/device-assignment.c |    8 ++++----
 qemu/hw/pc.c                |   28 ++++++++++++++++++----------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index bee0bd8..d8a52d5 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -1319,17 +1319,17 @@ static int scan_option_rom(uint8_t devfn, void *roms, ram_addr_t offset)
                   : TARGET_PAGE_ALIGN(size + 1);
 
     /* Size of all available ram space is 0x10000 (0xd0000 to 0xe0000) */
-    if ((offset + total_size) > 0x10000u) {
+    if ((offset + total_size) > 0xe0000u) {
         fprintf(stderr, "Option ROM size %x exceeds available space\n", size);
         return 0;
     }
 
     addr = qemu_ram_alloc(total_size);
-    cpu_register_physical_memory(0xd0000 + offset, total_size, addr | IO_MEM_ROM);
+    cpu_register_physical_memory(offset, total_size, addr | IO_MEM_ROM);
 
     /* Write ROM data and devfn to phys_addr */
-    cpu_physical_memory_write_rom(0xd0000 + offset, (uint8_t *)rom, size);
-    cpu_physical_memory_write_rom(0xd0000 + offset + size, &devfn, 1);
+    cpu_physical_memory_write_rom(offset, (uint8_t *)rom, size);
+    cpu_physical_memory_write_rom(offset + size, &devfn, 1);
 
     return total_size;
 }
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 5bbde07..1a7e896 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -825,7 +825,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;
     int pci_option_rom_offset;
@@ -932,10 +932,19 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
         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))
@@ -956,14 +965,14 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
         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, below_4g_mem_size);
-            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++) {
@@ -973,13 +982,13 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
                         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 option roms in available space\n");
                 exit(1);
             }
             size = (size + 4095) & ~4095;
@@ -987,9 +996,8 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
        initialization, and (optionally) marked readonly by the BIOS
        before INT 19h.  See the PNPBIOS specification, appendix B.
        DDIM support is mandatory for proper PCI expansion ROM support. */
-            cpu_register_physical_memory(0xd0000 + offset,
-                                         size, option_rom_offset /* | IO_MEM_ROM */);
-            option_rom_setup_reset(0xd0000 + offset, size);
+            cpu_register_physical_memory(offset, size, option_rom_offset /* | IO_MEM_ROM */);
+            option_rom_setup_reset(offset, size);
             offset += size;
         }
         pci_option_rom_offset = offset;
-- 
1.6.3.rc4.29.g8146