On 12/03/21 17:05, Peter Maydell wrote:
For that I would need to find all the addresses in an AddressSpace that alias vecbase, so that we can call rom_ptr() on all of them. I think something like this would work:hwaddr xlat, len; RCU_READ_LOCK_GUARD(); FlatView *fv = address_space_to_flatview(s->as); MemoryRegion *main_mr = flatview_translate(fv, vecbase, &xlat, &len, false, MEMTXATTRS_UNSPECIFIED); flatview_for_each_range(fv, callback_fn, ...); where callback_fn() does: if (mr != main_mr) { return; } do arithmetic with flatview range start and len, etc to figure out the overall address in the AS corresponding to vecbase rom = rom_ptr(that_addr); ... Does this seem like it would work ? Is there a nicer way ?
Yes, it should work. I can't think of a nicer way, except of course wrapping it in a nicer that hides the walk.
For what it's worth, it wouldn't be a problem to make FlatRange public and export FOR_EACH_FLAT_RANGE as well.
Paolo
