From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Peter Crosthwaite" <peter.crosthwaite@xilinx.com>,
"Richard Henderson" <rth@twiddle.net>,
"Andreas Färber" <afaerber@suse.de>,
"Greg Bellows" <greg.bellows@linaro.org>
Subject: Re: [Qemu-devel] RFC: memory API changes
Date: Mon, 23 Mar 2015 15:39:16 +0100 [thread overview]
Message-ID: <55102594.6000902@redhat.com> (raw)
In-Reply-To: <CAFEAcA-8AmagfK1NBE02J7kLEvVNdcm_oRbEmJpWAArL-2jc2Q@mail.gmail.com>
On 23/03/2015 13:24, Peter Maydell wrote:
> (This is part of the work I'm doing for transaction attributes.)
>
> Currently we have several APIs used for making physical
> memory accesses:
>
> 1. cpu_physical_memory_rw &c
>
> 2. address_space_rw/read/write/map
>
> 3. ld/st*_phys
>
> These do more-or-less overlapping jobs and it's not
> obvious which should be used when. Also they need to be
> expanded to support transaction attributes and (in some
> cases) reporting of failed memory transactions. I propose:
>
> * ld/st*_phys to be renamed to as_ld*, eg
> ldub_phys -> as_ldub
> ldl_be_phys -> as_ldl_be
> stq_phys -> as_stq
> stl_le_phys -> as_ldl_le
I think shorthand functions with no extra arguments still have a place.
I was thinking of having them only temporarily, until we add functions
(e.g. pci_dma_ld or amba_ld) that deal with the MemTxResult by setting
some bus-specific abort bit. However, this API would complicate the
case when the same core code is used for both PCI and sysbus devices.
Perhaps AddressSpaces can grow a callback that transforms a "bad"
MemTxResult to a "good" one with some side effects?
I do not like the as_ prefix, mostly because it is an English word. It
doesn't help that ", MEMTXATTRS_UNSPECIFIED, NULL", tacked on each
ld*_phys function invocation, is way more verbose than any savings you
get from shortening the name. :)
I could be persuaded about addrspace_ as the prefix. Hence, adding new
functions addrspace_ld* and addrspace_st* with the two extra arguments
would be fine. Still, rather than saving four characters in the prefix,
I'd rather move the maximum line length up from 80 to 90 characters, and
actually change that to a checkpatch error.
> and to take two new arguments:
> MemTxAttrs attrs, MemTxResult *result
> (existing callsites can pass MEMTXATTRS_UNSPECIFIED, NULL
> to get their current behaviour.)
> * address_space_rw &c to be renamed:
> address_space_rw -> as_rw_buf
> address_space_read -> as_read_buf
> address_space_write -> as_write_buf
> address_space_map -> as_map_buf &c
address_space_map doesn't map into or out of a buffer, so the name is
fine as it is.
> This is just so the names line up nicely and we have a
> clear indication that this is a family of functions
> * address_space_read/write/rw should return MemTxResult rather
> than plain bool
Certainly okay. Same for address_space_access_valid.
> * we should put all the as_* function prototypes in one
> header, probably memory.h, rather than some in cpu-common.h
> and some in memory.h
I think separating "creator" and "user" functions in two headers could
be nice. If we cannot come up with a name for the two headers (memory.h
and mem_ldst.h?), putting both in the same is okay too.
> * cpu_physical_memory_rw are obsolete and should be replaced
> with uses of the as_* functions -- we should at least note
> this in the header file. (Can't do this as an automated change
> really because the correct AS to use is callsite dependent.)
All users that should _not_ be using address_space_memory have been
already changed to address_space_rw, or should have, so it can be done
automatically. Same for cpu_physical_memory_map/unmap, BTW.
> The point of indicating failure via MemTxResult is that at
> some point we need to correct the current broken handling of
> the CPUClass do_unassigned_access hook, because that should
> only be invoked if the CPU itself does an access to an unassigned
> address, not if some random DMA'ing device does!
100% agreement on this.
Paolo
next prev parent reply other threads:[~2015-03-23 14:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 12:24 [Qemu-devel] RFC: memory API changes Peter Maydell
2015-03-23 12:30 ` Andreas Färber
2015-03-23 12:33 ` Peter Maydell
2015-03-23 14:39 ` Paolo Bonzini [this message]
2015-03-23 15:11 ` Peter Maydell
2015-03-23 15:18 ` Paolo Bonzini
2015-03-23 15:26 ` Peter Maydell
2015-03-23 15:27 ` Paolo Bonzini
2015-03-23 15:39 ` Peter Maydell
2015-03-23 15:47 ` Paolo Bonzini
2015-03-23 16:00 ` Peter Maydell
2015-03-23 16:30 ` Paolo Bonzini
2015-03-23 16:43 ` Peter Maydell
2015-03-23 16:32 ` Andreas Färber
2015-03-25 10:56 ` Igor Mammedov
2015-03-23 17:51 ` Andreas Färber
2015-03-23 17:59 ` Peter Maydell
2015-03-24 13:47 ` Peter Maydell
2015-03-24 14:45 ` Paolo Bonzini
2015-03-24 14:53 ` Peter Maydell
2015-03-24 15:08 ` Paolo Bonzini
2015-03-24 15:12 ` Peter Maydell
2015-03-24 16:23 ` Paolo Bonzini
2015-03-24 16:35 ` Peter Maydell
2015-03-24 17:51 ` Paolo Bonzini
2015-03-24 18:06 ` Peter Maydell
2015-03-24 20:00 ` Paolo Bonzini
2015-03-24 23:41 ` Peter Maydell
2015-03-25 11:34 ` Paolo Bonzini
2015-03-25 11:43 ` Peter Maydell
2015-03-25 11:50 ` Paolo Bonzini
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=55102594.6000902@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=edgar.iglesias@gmail.com \
--cc=greg.bellows@linaro.org \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).