qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Joel Schopp <joel.schopp@amd.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH] arm64: 64K pages and > 1024MB guest
Date: Wed, 23 Jul 2014 15:09:25 -0500	[thread overview]
Message-ID: <20140723200925.9787.75225.stgit@joelaarch64.amd.com> (raw)

kvm_set_phys_mem doesn't work on arm64 with memory > 1GB.  It exits with:
kvm_set_phys_mem: error registering slot: Invalid argument

An example of the failing address and size are start_addr == 0x90011000
and size=0xaffef000.  As you can see both of these are 4K aligned, not
64K aligned.

At 1024MB or smaller qemu only makes one call to kvm_set_user_memory_region,
so the start_addr and size are aligned by accident and the bug doesn't happen.

The following patch makes things work for me on an arm64 SOC.  I also smoke
tested the patch on an x86-64 box and qemu seemed to still run fine there
with the patch applied.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Joel Schopp <joel.schopp@amd.com>
---
 kvm-all.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 1402f4f..1975862 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -618,14 +618,14 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, bool add)
 
     /* kvm works in page size chunks, but the function may be called
        with sub-page size and unaligned start address. */
-    delta = TARGET_PAGE_ALIGN(size) - size;
+    delta = HOST_PAGE_ALIGN(start_addr) - start_addr;
     if (delta > size) {
         return;
     }
     start_addr += delta;
     size -= delta;
-    size &= TARGET_PAGE_MASK;
-    if (!size || (start_addr & ~TARGET_PAGE_MASK)) {
+    size &= qemu_host_page_mask;
+    if (!size || (start_addr & ~qemu_host_page_mask)) {
         return;
     }
 

             reply	other threads:[~2014-07-23 20:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23 20:09 Joel Schopp [this message]
2014-08-01 11:28 ` [Qemu-devel] [PATCH] arm64: 64K pages and > 1024MB guest Peter Maydell
2014-08-01 11:41   ` Paolo Bonzini
2014-08-01 14:02     ` Joel Schopp
2014-08-01 14:19       ` Paolo Bonzini
2014-08-01 18:36         ` Joel Schopp

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=20140723200925.9787.75225.stgit@joelaarch64.amd.com \
    --to=joel.schopp@amd.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).