9ae3a8
From b65927de7dd0ac9a52fa9b855cd17860c5303e6c Mon Sep 17 00:00:00 2001
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Wed, 18 Sep 2013 09:31:06 +0200
9ae3a8
Subject: [PATCH 22/29] exec: Drop incorrect & dead S390 code in qemu_ram_remap()
9ae3a8
9ae3a8
RH-Author: Markus Armbruster <armbru@redhat.com>
9ae3a8
Message-id: <1379496669-22778-6-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 54426
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 5/8] exec: Drop incorrect & dead S390 code in qemu_ram_remap()
9ae3a8
Bugzilla: 1009328
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
9ae3a8
Old S390 KVM wants guest RAM mapped in a peculiar way.  Commit 6b02494
9ae3a8
implemented that.
9ae3a8
9ae3a8
When qemu_ram_remap() got added in commit cd19cfa, its code carefully
9ae3a8
mimicked the allocation code: peculiar way if defined(TARGET_S390X) &&
9ae3a8
defined(CONFIG_KVM), else normal way.
9ae3a8
9ae3a8
For new S390 KVM, we actually want the normal way.  Commit fdec991
9ae3a8
changed qemu_ram_alloc_from_ptr() accordingly, but forgot to update
9ae3a8
qemu_ram_remap().  If qemu_ram_alloc_from_ptr() maps RAM the normal
9ae3a8
way, but qemu_ram_remap() remaps it the peculiar way, remapping
9ae3a8
changes protection and flags, which it shouldn't.
9ae3a8
9ae3a8
Fortunately, this can't happen, as we never remap on S390.
9ae3a8
9ae3a8
Replace the incorrect code with an assertion.
9ae3a8
9ae3a8
Thanks to Christian Borntraeger for help with assessing the bug's
9ae3a8
(non-)impact.
9ae3a8
9ae3a8
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
9ae3a8
Message-id: 1375276272-15988-6-git-send-email-armbru@redhat.com
9ae3a8
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
9ae3a8
(cherry picked from commit 2eb9fbaab56c6350c7d137428f4bd0bc79168214)
9ae3a8
---
9ae3a8
 exec.c | 13 +++++++------
9ae3a8
 1 file changed, 7 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 exec.c |   13 +++++++------
9ae3a8
 1 files changed, 7 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
diff --git a/exec.c b/exec.c
9ae3a8
index 42a0005..185155c 100644
9ae3a8
--- a/exec.c
9ae3a8
+++ b/exec.c
9ae3a8
@@ -1201,15 +1201,16 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
9ae3a8
                     area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
9ae3a8
                                 flags, block->fd, offset);
9ae3a8
                 } else {
9ae3a8
-#if defined(TARGET_S390X) && defined(CONFIG_KVM)
9ae3a8
-                    flags |= MAP_SHARED | MAP_ANONYMOUS;
9ae3a8
-                    area = mmap(vaddr, length, PROT_EXEC|PROT_READ|PROT_WRITE,
9ae3a8
-                                flags, -1, 0);
9ae3a8
-#else
9ae3a8
+                    /*
9ae3a8
+                     * Remap needs to match alloc.  Accelerators that
9ae3a8
+                     * set phys_mem_alloc never remap.  If they did,
9ae3a8
+                     * we'd need a remap hook here.
9ae3a8
+                     */
9ae3a8
+                    assert(phys_mem_alloc == qemu_anon_ram_alloc);
9ae3a8
+
9ae3a8
                     flags |= MAP_PRIVATE | MAP_ANONYMOUS;
9ae3a8
                     area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
9ae3a8
                                 flags, -1, 0);
9ae3a8
-#endif
9ae3a8
                 }
9ae3a8
                 if (area != vaddr) {
9ae3a8
                     fprintf(stderr, "Could not remap addr: "
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8