thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-Fix-memory-slot-page-alignment-logic-bug-1455745.patch

619821
From be6123e0eadd895a9fa47005df38c4dce655236c Mon Sep 17 00:00:00 2001
619821
From: Paolo Bonzini <pbonzini@redhat.com>
619821
Date: Tue, 6 Jun 2017 17:08:19 +0200
619821
Subject: [PATCH 1/6] kvm: Fix memory slot page alignment logic (bug#1455745)
619821
619821
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
619821
Message-id: <20170606170819.18875-1-pbonzini@redhat.com>
619821
Patchwork-id: 75507
619821
O-Subject: [RHEL7.4 qemu-kvm PATCH] kvm: Fix memory slot page alignment logic (bug#1455745)
619821
Bugzilla: 1455745
619821
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
619821
RH-Acked-by: Marcel Apfelbaum <marcel@redhat.com>
619821
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
619821
619821
From: Alexander Graf <agraf@suse.de>
619821
619821
Brew build: 13356300
619821
619821
Memory slots have to be page aligned to get entered into KVM. There
619821
is existing logic that tries to ensure that we pad memory slots that
619821
are not page aligned to the biggest region that would still fit in the
619821
alignment requirements.
619821
619821
Unfortunately, that logic is broken. It tries to calculate the start
619821
offset based on the region size.
619821
619821
Fix up the logic to do the thing it was intended to do and document it
619821
properly in the comment above it.
619821
619821
With this patch applied, I can successfully run an e500 guest with more
619821
than 3GB RAM (at which point RAM starts overlapping subpage memory regions).
619821
[Paolo: in RHEL's case, the issue was reported with assigned devices]
619821
619821
Cc: qemu-stable@nongnu.org
619821
Signed-off-by: Alexander Graf <agraf@suse.de>
619821
(cherry picked from commit f2a64032a14c642d0ddc9a7a846fc3d737deede5)
619821
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
619821
---
619821
 kvm-all.c | 6 ++++--
619821
 1 file changed, 4 insertions(+), 2 deletions(-)
619821
619821
diff --git a/kvm-all.c b/kvm-all.c
619821
index fc6e3ab..9486b9a 100644
619821
--- a/kvm-all.c
619821
+++ b/kvm-all.c
619821
@@ -621,8 +621,10 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, bool add)
619821
     unsigned delta;
619821
 
619821
     /* kvm works in page size chunks, but the function may be called
619821
-       with sub-page size and unaligned start address. */
619821
-    delta = TARGET_PAGE_ALIGN(size) - size;
619821
+       with sub-page size and unaligned start address. Pad the start
619821
+       address to next and truncate size to previous page boundary. */
619821
+    delta = (TARGET_PAGE_SIZE - (start_addr & ~TARGET_PAGE_MASK));
619821
+    delta &= ~TARGET_PAGE_MASK;
619821
     if (delta > size) {
619821
         return;
619821
     }
619821
-- 
619821
1.8.3.1
619821