All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alexander Graf <agraf@suse.de>, Peter Maydell <peter.maydell@linaro.org>
Cc: Nitin Srivastava <nitins@juniper.net>,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Michael Tokarev <mjt@tls.msk.ru>,
	qemu-devel <qemu-devel@nongnu.org>,
	"qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
	Anthony PERARD <anthony.perard@citrix.com>
Subject: Re: [Qemu-devel] [Qemu-ppc] standard test image not booting with qemu-system-ppc
Date: Tue, 04 Feb 2014 14:17:55 +0100	[thread overview]
Message-ID: <52F0E883.1020704@redhat.com> (raw)
In-Reply-To: <AB25BFF7-7DD3-4066-9511-E017DD87C1A6@suse.de>

Il 04/02/2014 08:55, Alexander Graf ha scritto:
>> With this change, the
>> memory system is now refusing to allow an access of size
>> 2 through, because it's greater than the region length. So
> 
> Ouch. Yes, for ioport reads/writes we definitely have to only cap the port range, not the length.

We can do it in general for MMIO.  Something like this?

diff --git a/exec.c b/exec.c
index 9ad0a4b..9a1eef3 100644
--- a/exec.c
+++ b/exec.c
@@ -325,7 +325,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
                                  hwaddr *plen, bool resolve_subpage)
 {
     MemoryRegionSection *section;
-    Int128 diff, diff_page;
+    Int128 diff;
 
     section = address_space_lookup_region(d, addr, resolve_subpage);
     /* Compute offset within MemoryRegionSection */
@@ -334,9 +334,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
     /* Compute offset within MemoryRegion */
     *xlat = addr + section->offset_within_region;
 
-    diff_page = int128_make64(((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr);
     diff = int128_sub(section->mr->size, int128_make64(addr));
-    diff = int128_min(diff, diff_page);
     *plen = int128_get64(int128_min(diff, int128_make64(*plen)));
     return section;
 }
@@ -370,6 +368,11 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
         as = iotlb.target_as;
     }
 
+    if (memory_access_is_direct(mr, is_write)) {
+        hwaddr page = (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE - addr;
+        len = MIN(page, len);
+    }
+
     *plen = len;
     *xlat = addr;
     return mr;


Stefano, Anthony, can you test it on Xen?

I wouldn't mind sticking a "xen_enabled()" in there, and/or a comment to document
why we do it.

Paolo

  reply	other threads:[~2014-02-04 13:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <246b6975027245a0bc428eb33808390d@CO1PR05MB490.namprd05.prod.outlook.com>
     [not found] ` <52EFFFC1.7040303@ilande.co.uk>
2014-02-03 21:13   ` [Qemu-devel] [Qemu-ppc] standard test image not booting with qemu-system-ppc Alexander Graf
2014-02-03 22:58     ` Alexander Graf
2014-02-03 23:28       ` Alexander Graf
2014-02-04  0:44         ` Peter Maydell
2014-02-04  7:55           ` Alexander Graf
2014-02-04 13:17             ` Paolo Bonzini [this message]
2014-02-04 14:37               ` Stefano Stabellini
2014-02-04 18:18               ` Anthony PERARD

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=52F0E883.1020704@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --cc=anthony.perard@citrix.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mjt@tls.msk.ru \
    --cc=nitins@juniper.net \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.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.