From: Paolo Bonzini <pbonzini@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Li Zhijian <lizhijian@cn.fujitsu.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
Jason Wang <jasowang@redhat.com>, Peter Xu <peterx@redhat.com>,
Tony Nguyen <tony.nguyen@bt.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH 1/2] exec/memory: Let address_space_read/write_cached() propagate MemTxResult
Date: Thu, 21 May 2020 17:37:21 +0200 [thread overview]
Message-ID: <485e95c2-1663-aa43-bf22-7bc3f6935fcf@redhat.com> (raw)
In-Reply-To: <20200517164817.5371-2-f4bug@amsat.org>
On 17/05/20 18:48, Philippe Mathieu-Daudé wrote:
> Both address_space_read_cached_slow() and
> address_space_write_cached_slow() return a MemTxResult type.
> Do not discard it, return it to the caller.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> include/exec/memory.h | 19 +++++++++++--------
> exec.c | 16 ++++++++--------
> 2 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index e000bd2f97..5e8c009169 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -2343,10 +2343,11 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr);
>
> /* Internal functions, part of the implementation of address_space_read_cached
> * and address_space_write_cached. */
> -void address_space_read_cached_slow(MemoryRegionCache *cache,
> - hwaddr addr, void *buf, hwaddr len);
> -void address_space_write_cached_slow(MemoryRegionCache *cache,
> - hwaddr addr, const void *buf, hwaddr len);
> +MemTxResult address_space_read_cached_slow(MemoryRegionCache *cache,
> + hwaddr addr, void *buf, hwaddr len);
> +MemTxResult address_space_write_cached_slow(MemoryRegionCache *cache,
> + hwaddr addr, const void *buf,
> + hwaddr len);
>
> static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)
> {
> @@ -2411,15 +2412,16 @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
> * @buf: buffer with the data transferred
> * @len: length of the data transferred
> */
> -static inline void
> +static inline MemTxResult
> address_space_read_cached(MemoryRegionCache *cache, hwaddr addr,
> void *buf, hwaddr len)
> {
> assert(addr < cache->len && len <= cache->len - addr);
> if (likely(cache->ptr)) {
> memcpy(buf, cache->ptr + addr, len);
> + return MEMTX_OK;
> } else {
> - address_space_read_cached_slow(cache, addr, buf, len);
> + return address_space_read_cached_slow(cache, addr, buf, len);
> }
> }
>
> @@ -2431,15 +2433,16 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr,
> * @buf: buffer with the data transferred
> * @len: length of the data transferred
> */
> -static inline void
> +static inline MemTxResult
> address_space_write_cached(MemoryRegionCache *cache, hwaddr addr,
> const void *buf, hwaddr len)
> {
> assert(addr < cache->len && len <= cache->len - addr);
> if (likely(cache->ptr)) {
> memcpy(cache->ptr + addr, buf, len);
> + return MEMTX_OK;
> } else {
> - address_space_write_cached_slow(cache, addr, buf, len);
> + return address_space_write_cached_slow(cache, addr, buf, len);
> }
> }
>
> diff --git a/exec.c b/exec.c
> index 5162f0d12f..877b51cc5c 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -3716,7 +3716,7 @@ static inline MemoryRegion *address_space_translate_cached(
> /* Called from RCU critical section. address_space_read_cached uses this
> * out of line function when the target is an MMIO or IOMMU region.
> */
> -void
> +MemTxResult
> address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
> void *buf, hwaddr len)
> {
> @@ -3726,15 +3726,15 @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
> l = len;
> mr = address_space_translate_cached(cache, addr, &addr1, &l, false,
> MEMTXATTRS_UNSPECIFIED);
> - flatview_read_continue(cache->fv,
> - addr, MEMTXATTRS_UNSPECIFIED, buf, len,
> - addr1, l, mr);
> + return flatview_read_continue(cache->fv,
> + addr, MEMTXATTRS_UNSPECIFIED, buf, len,
> + addr1, l, mr);
> }
>
> /* Called from RCU critical section. address_space_write_cached uses this
> * out of line function when the target is an MMIO or IOMMU region.
> */
> -void
> +MemTxResult
> address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
> const void *buf, hwaddr len)
> {
> @@ -3744,9 +3744,9 @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
> l = len;
> mr = address_space_translate_cached(cache, addr, &addr1, &l, true,
> MEMTXATTRS_UNSPECIFIED);
> - flatview_write_continue(cache->fv,
> - addr, MEMTXATTRS_UNSPECIFIED, buf, len,
> - addr1, l, mr);
> + return flatview_write_continue(cache->fv,
> + addr, MEMTXATTRS_UNSPECIFIED, buf, len,
> + addr1, l, mr);
> }
>
> #define ARG1_DECL MemoryRegionCache *cache
>
Queued patch 1, thanks.
Paolo
next prev parent reply other threads:[~2020-05-21 15:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-17 16:48 [PATCH 0/2] exec/memory: Enforce checking MemTxResult values Philippe Mathieu-Daudé
2020-05-17 16:48 ` [PATCH 1/2] exec/memory: Let address_space_read/write_cached() propagate MemTxResult Philippe Mathieu-Daudé
2020-05-21 15:37 ` Paolo Bonzini [this message]
2020-05-17 16:48 ` [RFC PATCH 2/2] exec/memory: Emit warning when MemTxResult is ignored Philippe Mathieu-Daudé
2020-05-17 18:06 ` [PATCH 0/2] exec/memory: Enforce checking MemTxResult values no-reply
2020-05-17 18:13 ` no-reply
2020-05-17 18:19 ` no-reply
2020-05-18 9:46 ` Peter Maydell
2020-05-18 11:20 ` Philippe Mathieu-Daudé
2020-05-18 12:33 ` Peter Maydell
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=485e95c2-1663-aa43-bf22-7bc3f6935fcf@redhat.com \
--to=pbonzini@redhat.com \
--cc=aik@ozlabs.ru \
--cc=f4bug@amsat.org \
--cc=jasowang@redhat.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=tony.nguyen@bt.com \
/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.