|
|
383d26 |
From 84d49bc7469905877fc22f6faea1e53c8c0cbe1c Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: David Hildenbrand <david@redhat.com>
|
|
|
383d26 |
Date: Fri, 21 Sep 2018 09:19:39 +0200
|
|
|
383d26 |
Subject: [PATCH 03/22] pc-dimm: turn alignment assert into check
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: David Hildenbrand <david@redhat.com>
|
|
|
383d26 |
Message-id: <20180921091939.4107-1-david@redhat.com>
|
|
|
383d26 |
Patchwork-id: 82227
|
|
|
383d26 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH] pc-dimm: turn alignment assert into check
|
|
|
383d26 |
Bugzilla: 1629720
|
|
|
383d26 |
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1629720
|
|
|
383d26 |
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=18439425
|
|
|
383d26 |
Upstream: 4d8938a05db15dea2c86c4ab9c5f872f160d2188
|
|
|
383d26 |
|
|
|
383d26 |
The start of the address space indicates which maximum alignment is
|
|
|
383d26 |
supported by our machine (e.g. ppc, x86 1GB). This is helpful to
|
|
|
383d26 |
catch fragmenting guest physical memory in strange fashions.
|
|
|
383d26 |
|
|
|
383d26 |
Right now we can crash QEMU by e.g. (there might be easier examples)
|
|
|
383d26 |
|
|
|
383d26 |
qemu-system-x86_64 -m 256M,maxmem=20G,slots=2 \
|
|
|
383d26 |
-object memory-backend-file,id=mem0,size=8192M,mem-path=/dev/zero,align=8192M \
|
|
|
383d26 |
-device pc-dimm,id=dimm1,memdev=mem0
|
|
|
383d26 |
|
|
|
383d26 |
Backport conflicts:
|
|
|
383d26 |
hw/mem/memory-device.c: The memory device refactoring is part of 3.0
|
|
|
383d26 |
and probably not worth backporting to 7.X.
|
|
|
383d26 |
So fix it in previous pc-dimm code.
|
|
|
383d26 |
Note: The upstream patch missed a "x" (0% .. vs. 0x% ..), will fix that
|
|
|
383d26 |
upstream, too.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
383d26 |
Message-Id: <20180607154705.6316-2-david@redhat.com>
|
|
|
383d26 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
383d26 |
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
383d26 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
383d26 |
(cherry picked from commit 4d8938a05db15dea2c86c4ab9c5f872f160d2188)
|
|
|
383d26 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
hw/mem/pc-dimm.c | 9 +++++++--
|
|
|
383d26 |
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
|
|
|
383d26 |
index 51350d9..a9d7c51 100644
|
|
|
383d26 |
--- a/hw/mem/pc-dimm.c
|
|
|
383d26 |
+++ b/hw/mem/pc-dimm.c
|
|
|
383d26 |
@@ -298,14 +298,19 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
|
|
|
383d26 |
uint64_t new_addr, ret = 0;
|
|
|
383d26 |
uint64_t address_space_end = address_space_start + address_space_size;
|
|
|
383d26 |
|
|
|
383d26 |
- g_assert(QEMU_ALIGN_UP(address_space_start, align) == address_space_start);
|
|
|
383d26 |
-
|
|
|
383d26 |
if (!address_space_size) {
|
|
|
383d26 |
error_setg(errp, "memory hotplug is not enabled, "
|
|
|
383d26 |
"please add maxmem option");
|
|
|
383d26 |
goto out;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
+ /* address_space_start indicates the maximum alignment we expect */
|
|
|
383d26 |
+ if (QEMU_ALIGN_UP(address_space_start, align) != address_space_start) {
|
|
|
383d26 |
+ error_setg(errp, "the alignment (0x%" PRIx64 ") is not supported",
|
|
|
383d26 |
+ align);
|
|
|
383d26 |
+ goto out;
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+
|
|
|
383d26 |
if (hint && QEMU_ALIGN_UP(*hint, align) != *hint) {
|
|
|
383d26 |
error_setg(errp, "address must be aligned to 0x%" PRIx64 " bytes",
|
|
|
383d26 |
align);
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|