qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"KONRAD Frederic" <frederic.konrad@adacore.com>,
	"Peter Crosthwaite" <crosthwaitepeter@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH] memory: fix access_with_adjusted_size() on big-endian
Date: Fri, 11 Aug 2017 16:25:36 +0200	[thread overview]
Message-ID: <bd1e9b06-56fd-fed0-e19b-c8a0c036c58c@redhat.com> (raw)
In-Reply-To: <20170811140628.31935-1-f4bug@amsat.org>

On 11/08/2017 16:06, Philippe Mathieu-Daudé wrote:
> remove unnecessary memory_region_big_endian()

Can you explain why it's unnecessary?...

Paolo

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> This is part of a branch with many cross-endianness tests for 2.11
> 
> Frederic does it helps your issues on armeb?
> 
>  memory.c | 28 ++++++++++------------------
>  1 file changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/memory.c b/memory.c
> index c0adc35410..600f5d5b1a 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -338,15 +338,6 @@ static void flatview_simplify(FlatView *view)
>      }
>  }
>  
> -static bool memory_region_big_endian(MemoryRegion *mr)
> -{
> -#ifdef TARGET_WORDS_BIGENDIAN
> -    return mr->ops->endianness != DEVICE_LITTLE_ENDIAN;
> -#else
> -    return mr->ops->endianness == DEVICE_BIG_ENDIAN;
> -#endif
> -}
> -
>  static bool memory_region_wrong_endianness(MemoryRegion *mr)
>  {
>  #ifdef TARGET_WORDS_BIGENDIAN
> @@ -572,7 +563,8 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
>  {
>      uint64_t access_mask;
>      unsigned access_size;
> -    unsigned i;
> +    hwaddr access_addr;
> +    unsigned offset;
>      MemTxResult r = MEMTX_OK;
>  
>      if (!access_size_min) {
> @@ -585,17 +577,17 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
>      /* FIXME: support unaligned access? */
>      access_size = MAX(MIN(size, access_size_max), access_size_min);
>      access_mask = -1ULL >> (64 - access_size * 8);
> -    if (memory_region_big_endian(mr)) {
> -        for (i = 0; i < size; i += access_size) {
> -            r |= access(mr, addr + i, value, access_size,
> -                        (size - access_size - i) * 8, access_mask, attrs);
> +    access_addr = addr & ~(access_size - 1);
> +    if (access_size < size) {
> +        for (offset = 0; offset < size; offset += access_size) {
> +            r |= access(mr, access_addr + offset, value, access_size,
> +                        offset * 8, access_mask, attrs);
>          }
>      } else {
> -        for (i = 0; i < size; i += access_size) {
> -            r |= access(mr, addr + i, value, access_size, i * 8,
> -                        access_mask, attrs);
> -        }
> +        r = access(mr, access_addr, value, access_size,
> +                    0, access_mask, attrs);
>      }
> +
>      return r;
>  }
>  
> 

  reply	other threads:[~2017-08-11 14:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 14:06 [Qemu-devel] [RFC PATCH] memory: fix access_with_adjusted_size() on big-endian Philippe Mathieu-Daudé
2017-08-11 14:25 ` Paolo Bonzini [this message]
2017-08-11 14:49   ` Philippe Mathieu-Daudé
2017-08-11 17:13     ` KONRAD Frederic

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=bd1e9b06-56fd-fed0-e19b-c8a0c036c58c@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=crosthwaitepeter@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=frederic.konrad@adacore.com \
    --cc=peter.maydell@linaro.org \
    --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).