cryptospore / rpms / qemu-kvm

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