qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: finding all the places in an AddressSpace that alias a specific address
Date: Mon, 22 Mar 2021 19:51:16 +0100	[thread overview]
Message-ID: <14d4a39f-1a32-8d35-4624-b7b73dd0bcae@redhat.com> (raw)
In-Reply-To: <CAFEAcA8wAi6gYOLQG1u8wHS8--9+OENGyKs9mLiufJd9vHYQkg@mail.gmail.com>

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	other threads:[~2021-03-22 18:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 16:05 finding all the places in an AddressSpace that alias a specific address Peter Maydell
2021-03-22 18:51 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14d4a39f-1a32-8d35-4624-b7b73dd0bcae@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).