From: Peter Maydell <peter.maydell@linaro.org>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] sub-page-sized mmio regions and address passed to read/write fns
Date: Fri, 2 Dec 2011 14:49:55 +0000 [thread overview]
Message-ID: <CAFEAcA8+Mj2orvK2RZwL1z8Da8nHYhOD4z_R+OxwR47yw6XriQ@mail.gmail.com> (raw)
Hi; I was working on a refactoring of the ARM 11MPCore/A9MP private
peripherals and encountered something odd. Rather than having a single
large mmio region, I tried splitting into several regions, like this:
memory_region_init(&s->container, "a9mp-priv-container", 0x2000);
memory_region_init_io(&s->scu_iomem, &a9_scu_ops, s, "a9mp-scu", 0x100);
memory_region_init_io(&s->gic_cpu_iomem, &a9_gic_cpu_ops, s,
"a9mp-gic-cpu", 0x100);
memory_region_init_io(&s->ptimer_iomem, &a9_ptimer_ops, s,
"a9mp-ptimer", 0x100);
memory_region_add_subregion(&s->container, 0, &s->scu_iomem);
memory_region_add_subregion(&s->container, 0x100, &s->gic_cpu_iomem);
memory_region_add_subregion(&s->container, 0x600, &s->ptimer_iomem);
memory_region_add_subregion(&s->container, 0x1000, &s->gic.iomem);
sysbus_init_mmio_region(dev, &s->container);
However what I found is that the addresses passed to the read/write
functions aren't what I would expect. For instance if the board
maps the container at address 0x1e000000, then a read from 0x1e000100
goes to the functions given by a9_gic_cpu_ops, as it should. However,
the offset parameter that the read function is passed is not 0x0
(offset from the start of the a9mp-gic-cpu region) but 0x100 (offset
from the start of the page, I think).
Is this expected behaviour? I certainly wasn't expecting it...
I looked through the code that's getting called for reads, and
it looks to me like exec.c:subpage_readlen() is causing this.
We look up the subpage_t based on the address within the page,
but we don't then adjust the address we pass to io_mem_read
(except by region_offset, which I take from the comment at the
top of cpu_register_physical_memory_log() to be for something
else.)
-- PMM
next reply other threads:[~2011-12-02 14:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-02 14:49 Peter Maydell [this message]
2011-12-04 12:17 ` [Qemu-devel] sub-page-sized mmio regions and address passed to read/write fns Avi Kivity
2011-12-04 21:15 ` Peter Maydell
2011-12-05 9:26 ` Avi Kivity
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=CAFEAcA8+Mj2orvK2RZwL1z8Da8nHYhOD4z_R+OxwR47yw6XriQ@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=avi@redhat.com \
--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).