qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finding all the places in an AddressSpace that alias a specific addr


From: Paolo Bonzini
Subject: Re: finding all the places in an AddressSpace that alias a specific address
Date: Mon, 22 Mar 2021 19:51:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]