On 29 June 2017 at 10:28, KONRAD Frederic <frederic.kon...@adacore.com> wrote: > This fixes an odd bug when a ROM is present somewhere and an alias @0x00000000 > is pointing to the ROM. The "if (rom)" test fails and we don't get a valid > reset > state. QEMU later crashes with an exception because the ARMv7-M starts with > the > ARM instruction set. (eg: PC & 0x01 is 0). > > This patch uses memory_region_get_offset_within_address_space introduced > before > to check if an alias doesn't point to a flash somewhere. > > Signed-off-by: KONRAD Frederic <frederic.kon...@adacore.com>
This is awkward, because in the "we have a ROM but it's not been copied into memory yet" case, the only thing we have is the rom->addr, which is the address which the user's ROM blob said it ought to be loaded in at. If the user didn't actually provide a ROM blob that loads at 0 that seems a bit like a user error, and I don't think this patch will catch all the cases of that sort of mistake. For instance if address 0 is real flash and the high address alias is modelled by having the high address be the alias, then if the user passes us an ELF file saying "load to the high address" then this change won't catch that I think (because doing the memory_region_find/get_offset_within_address_space will return 0, which has already been tried). You'd need to somehow have a way to say "find all the addresses within this AS where this MR is mapped" and try them all... thanks -- PMM