Skip to contentSkip to conversation

Multiboot support: Fix rom_copy

PATCH New Kevin Wolf 1 participant 1 message Dec 19, 2009

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 Multiboot support: Fix rom_copy

ROMs need to be loaded if they are anywhere in the requested area, not only at the very beginning. This fixes Multiboot with ELF kernels that have more than one program header.

---
 hw/loader.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
hw/loader.c +5 -2
index c7d43f6..2ceb8eb 100644
@@ -698,6 +698,11 @@ static Rom *find_rom(target_phys_addr_t addr)
     return NULL;
 }
 
+/*
+ * Copies memory from registered ROMs to dest. Any memory that is contained in
+ * a ROM between addr and addr + size is copied. Note that this can involve
+ * multiple ROMs, which need not start at addr and need not end at addr + size.
+ */
 int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size)
 {
     target_phys_addr_t end = addr + size;
@@ -706,8 +711,6 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (rom->addr > addr)
-            continue;
         if (rom->addr + rom->romsize < addr)
             continue;
         if (rom->addr > end)
Signature · 1 line
1.6.0.2