From: "Alex Bennée" <alex.bennee@linaro.org>
To: Aaron Lindsay <aaron@os.amperecomputing.com>
Cc: cota@braap.org, richard.henderson@linaro.org, qemu-devel@nongnu.org
Subject: Re: Plugin Address Translations Inconsistent/Incorrect?
Date: Mon, 22 Feb 2021 19:30:04 +0000 [thread overview]
Message-ID: <8735xn6fy7.fsf@linaro.org> (raw)
In-Reply-To: <YDPk08PCwhD7Nm2+@strawberry.localdomain>
Aaron Lindsay <aaron@os.amperecomputing.com> writes:
> Hello,
>
> I've been doing some more work with plugins and found something I didn't
> expect with regards to address translation.
>
> If I call (inside a memory callback):
>
> `uint64_t pa = qemu_plugin_hwaddr_device_offset(hwaddr);`
>
> I see that `pa` takes the value 0xe0e58760. If, however, I plumb
> `cpu_get_phys_page_debug` through to the plugin interface and call it
> like:
>
> `pa = cpu_get_phys_page_debug(current_cpu, va);`
>
> I see it takes the value 0x120e58760.
>
> I notice that 0x120e58760-0xe0e58760 is exactly one gigabyte, which is
> also the offset of the beginning of RAM for the 'virt' AArch64 machine
> I'm using. Furthermore, I see the name of the plugin function includes
> "device_offset", so perhaps this discrepancy is by design. However, it
> seems awkward to not be able to get a true physical address.
It certainly is by design. The comment for the helper states:
/*
* The following additional queries can be run on the hwaddr structure
* to return information about it. For non-IO accesses the device
* offset will be into the appropriate block of RAM.
*/
> I've done some digging and found that inside `qemu_ram_addr_from_host`
> (called by `qemu_plugin_hwaddr_device_offset`), `block->mr->addr`
> appears to hold the offset of the beginning of RAM.
>
> Do you think it would be reasonable to modify
> `qemu_plugin_hwaddr_device_offset` to add the beginning of the RAM block
> or otherwise return the true physical address (or at least expose a way
> to find the beginning of it through the plugin interface)?
Well the problem here is what is the address map? For example if you
have a secure block of RAM you might have two physical addresses which
are the same. That said with the current qemu_plugin_hwaddr_device_name
helper both will get reported as "RAM" so maybe it's not that helpful
yet.
I also worry about what happens if devices get moved around. Do you end
up with aliasing of address space have a remap of the HW.
That said I think we could add an additional helper to translate a
hwaddr to a global address space address. I'm open to suggestions of the
best way to structure this.
>
> Thanks!
>
> -Aaron
--
Alex Bennée
next prev parent reply other threads:[~2021-02-22 19:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 17:07 Plugin Address Translations Inconsistent/Incorrect? Aaron Lindsay
2021-02-22 19:30 ` Alex Bennée [this message]
2021-02-22 20:08 ` Peter Maydell
2021-02-23 8:52 ` Alex Bennée
2021-02-23 10:55 ` Peter Maydell
2021-02-22 20:48 ` Aaron Lindsay via
2021-02-23 20:53 ` Aaron Lindsay via
2021-03-02 15:33 ` Aaron Lindsay via
2021-03-02 16:06 ` Alex Bennée
2021-03-02 19:41 ` Aaron Lindsay via
2021-03-02 21:04 ` Alex Bennée
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=8735xn6fy7.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=aaron@os.amperecomputing.com \
--cc=cota@braap.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.