[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/20] hw/core/loader.c: Track last-seen ROM in rom_check_and_regi
From: |
Peter Maydell |
Subject: |
[PULL 08/20] hw/core/loader.c: Track last-seen ROM in rom_check_and_register_reset() |
Date: |
Tue, 15 Dec 2020 14:12:25 +0000 |
In rom_check_and_register_reset() we detect overlaps by looking at
whether the ROM blob we're currently examining is in the same address
space and starts before the previous ROM blob ends. (This works
because the ROM list is kept sorted in order by AddressSpace and then
by address.)
Instead of keeping the AddressSpace and last address of the previous ROM
blob in local variables, just keep a pointer to it.
This will allow us to print more useful information when we do detect
an overlap.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20201129203923.10622-2-peter.maydell@linaro.org
---
hw/core/loader.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index fea22d265c7..45aaba6158b 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -1166,28 +1166,35 @@ static void rom_reset(void *unused)
}
}
+/* Return true if two consecutive ROMs in the ROM list overlap */
+static bool roms_overlap(Rom *last_rom, Rom *this_rom)
+{
+ if (!last_rom) {
+ return false;
+ }
+ return last_rom->as == this_rom->as &&
+ last_rom->addr + last_rom->romsize > this_rom->addr;
+}
+
int rom_check_and_register_reset(void)
{
- hwaddr addr = 0;
MemoryRegionSection section;
- Rom *rom;
- AddressSpace *as = NULL;
+ Rom *rom, *last_rom = NULL;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (!rom->mr) {
- if ((addr > rom->addr) && (as == rom->as)) {
+ if (roms_overlap(last_rom, rom)) {
fprintf(stderr, "rom: requested regions overlap "
"(rom %s. free=0x" TARGET_FMT_plx
", addr=0x" TARGET_FMT_plx ")\n",
- rom->name, addr, rom->addr);
+ rom->name, last_rom->addr + last_rom->romsize,
+ rom->addr);
return -1;
}
- addr = rom->addr;
- addr += rom->romsize;
- as = rom->as;
+ last_rom = rom;
}
section = memory_region_find(rom->mr ? rom->mr : get_system_memory(),
rom->addr, 1);
--
2.20.1
- [PULL 10/20] elf_ops.h: Don't truncate name of the ROM blobs we create, (continued)
- [PULL 10/20] elf_ops.h: Don't truncate name of the ROM blobs we create, Peter Maydell, 2020/12/15
- [PULL 09/20] hw/core/loader.c: Improve reporting of ROM overlap errors, Peter Maydell, 2020/12/15
- [PULL 06/20] target/nios2: Move nios2_check_interrupts() into target/nios2, Peter Maydell, 2020/12/15
- [PULL 11/20] elf_ops.h: Be more verbose with ROM blob names, Peter Maydell, 2020/12/15
- [PULL 01/20] gdbstub: Correct misparsing of vCont C/S requests, Peter Maydell, 2020/12/15
- [PULL 15/20] arm: xlnx-versal: Connect usb to virt-versal, Peter Maydell, 2020/12/15
- [PULL 14/20] usb: xlnx-usb-subsystem: Add xilinx usb subsystem, Peter Maydell, 2020/12/15
- [PULL 13/20] usb: Add DWC3 model, Peter Maydell, 2020/12/15
- [PULL 16/20] hw/misc/zynq_slcr: Avoid #DIV/0! error, Peter Maydell, 2020/12/15
- [PULL 17/20] hw/block/m25p80: Make Numonyx config field names more accurate, Peter Maydell, 2020/12/15
- [PULL 08/20] hw/core/loader.c: Track last-seen ROM in rom_check_and_register_reset(),
Peter Maydell <=
- [PULL 12/20] usb: Add versal-usb2-ctrl-regs module, Peter Maydell, 2020/12/15
- [PULL 18/20] hw/block/m25p80: Fix when VCFG XIP bit is set for Numonyx, Peter Maydell, 2020/12/15
- [PULL 20/20] hw/block/m25p80: Fix Numonyx fast read dummy cycle count, Peter Maydell, 2020/12/15
[PULL 19/20] hw/block/m25p80: Check SPI mode before running some Numonyx commands, Peter Maydell, 2020/12/15
Re: [PULL 00/20] target-arm queue, Peter Maydell, 2020/12/15