[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] target/arm: Allow loading elf from aliased ROM regions
From: |
Jean-Hugues Deschênes |
Subject: |
[PATCH v2] target/arm: Allow loading elf from aliased ROM regions |
Date: |
Tue, 26 Nov 2019 12:56:23 +0000 |
With this patch, we allow loading a ROM image at an aliased address,
when it is located in a memory region for which an alias exists.
Changes since v1:
- Removes unnecessary "else rom = NULL" clause after having verified mr.
Signed-off-by: Jean-Hugues Deschenes <address@hidden>
---
target/arm/cpu.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 7a4ac9339b..bff81b51d1 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -313,13 +313,30 @@ static void arm_cpu_reset(CPUState *s)
initial_msp = ldl_p(rom);
initial_pc = ldl_p(rom + 4);
} else {
- /* Address zero not covered by a ROM blob, or the ROM blob
- * is in non-modifiable memory and this is a second reset after
- * it got copied into memory. In the latter case, rom_ptr
- * will return a NULL pointer and we should use ldl_phys instead.
- */
- initial_msp = ldl_phys(s->as, vecbase);
- initial_pc = ldl_phys(s->as, vecbase + 4);
+ /* See if the ROM blob is aliased somewhere */
+ hwaddr len = 0, xlat = 0;
+ MemoryRegion *mr = address_space_translate(s->as, vecbase, &xlat,
+ &len, false, MEMTXATTRS_UNSPECIFIED);
+
+ if (mr) {
+ rom = rom_ptr(mr->addr + xlat, 8);
+ }
+
+ if (rom) {
+ initial_msp = ldl_p(rom);
+ initial_pc = ldl_p(rom + 4);
+ } else {
+
+ /*
+ * Address zero not covered by a ROM blob, or the ROM blob
+ * is in non-modifiable memory and this is a second reset after
+ * it got copied into memory. In the latter case, rom_ptr
+ * will return a NULL pointer and we should use ldl_phys
+ * instead.
+ */
+ initial_msp = ldl_phys(s->as, vecbase);
+ initial_pc = ldl_phys(s->as, vecbase + 4);
+ }
}
env->regs[13] = initial_msp & 0xFFFFFFFC;
--
2.17.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH v2] target/arm: Allow loading elf from aliased ROM regions,
Jean-Hugues Deschênes <=