|
|
ae23c9 |
From c39a8362df8c09b9c66bb9c5295dc26373244fed Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: David Hildenbrand <david@redhat.com>
|
|
|
ae23c9 |
Date: Mon, 26 Nov 2018 09:57:34 +0000
|
|
|
ae23c9 |
Subject: [PATCH 35/35] pc-dimm: turn alignment assert into check
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: David Hildenbrand <david@redhat.com>
|
|
|
ae23c9 |
Message-id: <20181126095734.30666-1-david@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 83163
|
|
|
ae23c9 |
O-Subject: [RHEL-8.0 qemu-kvm PATCH] pc-dimm: turn alignment assert into check
|
|
|
ae23c9 |
Bugzilla: 1630116
|
|
|
ae23c9 |
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1630116
|
|
|
ae23c9 |
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=19276337
|
|
|
ae23c9 |
Upstream: 4d8938a05db15dea2c86c4ab9c5f872f160d2188
|
|
|
ae23c9 |
Branch: rhel8/master-2.12.0
|
|
|
ae23c9 |
|
|
|
ae23c9 |
The start of the address space indicates which maximum alignment is
|
|
|
ae23c9 |
supported by our machine (e.g. ppc, x86 1GB). This is helpful to
|
|
|
ae23c9 |
catch fragmenting guest physical memory in strange fashions.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Right now we can crash QEMU by e.g. (there might be easier examples)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
qemu-system-x86_64 -m 256M,maxmem=20G,slots=2 \
|
|
|
ae23c9 |
-object memory-backend-file,id=mem0,size=8192M,mem-path=/dev/zero,align=8192M \
|
|
|
ae23c9 |
-device pc-dimm,id=dimm1,memdev=mem0
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Backport conflicts:
|
|
|
ae23c9 |
hw/mem/memory-device.c: The memory device refactoring is part of 3.0,
|
|
|
ae23c9 |
so fix it in previous pc-dimm code.
|
|
|
ae23c9 |
Note: The upstream patch missed a "x" (0% .. vs. 0x% ..), which was
|
|
|
ae23c9 |
fixed in 7c63ba2055a0 ("memory-device: fix alignment error message"),
|
|
|
ae23c9 |
however as this is not a clean cherry pick, I'm fixing it right
|
|
|
ae23c9 |
away (like in the RHEL7.6 backport).
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
ae23c9 |
Message-Id: <20180607154705.6316-2-david@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 4d8938a05db15dea2c86c4ab9c5f872f160d2188)
|
|
|
ae23c9 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
hw/mem/pc-dimm.c | 9 +++++++--
|
|
|
ae23c9 |
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
|
|
|
ae23c9 |
index 51350d9..a9d7c51 100644
|
|
|
ae23c9 |
--- a/hw/mem/pc-dimm.c
|
|
|
ae23c9 |
+++ b/hw/mem/pc-dimm.c
|
|
|
ae23c9 |
@@ -298,14 +298,19 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
|
|
|
ae23c9 |
uint64_t new_addr, ret = 0;
|
|
|
ae23c9 |
uint64_t address_space_end = address_space_start + address_space_size;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- g_assert(QEMU_ALIGN_UP(address_space_start, align) == address_space_start);
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
if (!address_space_size) {
|
|
|
ae23c9 |
error_setg(errp, "memory hotplug is not enabled, "
|
|
|
ae23c9 |
"please add maxmem option");
|
|
|
ae23c9 |
goto out;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ /* address_space_start indicates the maximum alignment we expect */
|
|
|
ae23c9 |
+ if (QEMU_ALIGN_UP(address_space_start, align) != address_space_start) {
|
|
|
ae23c9 |
+ error_setg(errp, "the alignment (0x%" PRIx64 ") is not supported",
|
|
|
ae23c9 |
+ align);
|
|
|
ae23c9 |
+ goto out;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
if (hint && QEMU_ALIGN_UP(*hint, align) != *hint) {
|
|
|
ae23c9 |
error_setg(errp, "address must be aligned to 0x%" PRIx64 " bytes",
|
|
|
ae23c9 |
align);
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|