[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Plugin Address Translations Inconsistent/Incorrect?
From: |
Aaron Lindsay |
Subject: |
Re: Plugin Address Translations Inconsistent/Incorrect? |
Date: |
Tue, 2 Mar 2021 10:33:11 -0500 |
On Feb 23 15:53, Aaron Lindsay wrote:
> On Feb 22 15:48, Aaron Lindsay wrote:
> > On Feb 22 19:30, Alex Bennée wrote:
> > > Aaron Lindsay <aaron@os.amperecomputing.com> writes:
> > > 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.
> >
> > Haven't put a ton of thought into it, but what about something like this
> > (untested):
> >
> > uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr
> > *haddr)
> > {
> > #ifdef CONFIG_SOFTMMU
> > if (haddr) {
> > if (!haddr->is_io) {
> > RAMBlock *block;
> > ram_addr_t offset;
> >
> > block = qemu_ram_block_from_host((void *)
> > haddr->v.ram.hostaddr, false, &offset);
> > if (!block) {
> > error_report("Bad ram pointer %"PRIx64"",
> > haddr->v.ram.hostaddr);
> > abort();
> > }
> >
> > return block->offset + offset + block->mr->addr;
> > } else {
> > MemoryRegionSection *mrs = haddr->v.io.section;
> > return haddr->v.io.offset + mrs->mr->addr;
> > }
> > }
> > #endif
> > return 0;
> > }
>
> This appears to successfully return correct physical addresses for RAM
> at least, though I've not tested it thoroughly for MMIO yet.
>
> If it ends up being desirable based on the discussion elsewhere on this
> thread I am willing to perform more complete testing, turn this into a
> patch, and submit it.
Ping - Is this something worth me pursuing?
-Aaron
- Re: Plugin Address Translations Inconsistent/Incorrect?,
Aaron Lindsay <=