6b2ce2692f
- kvm-hv-balloon-use-get_min_alignment-to-express-32-GiB-a.patch [RHEL-20341] - kvm-memory-device-reintroduce-memory-region-size-check.patch [RHEL-20341] - kvm-block-backend-Allow-concurrent-context-changes.patch [RHEL-24593] - kvm-scsi-Await-request-purging.patch [RHEL-24593] - kvm-string-output-visitor-show-structs-as-omitted.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-string-output-visitor-Fix-pseudo-struct-handling.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-qdev-properties-alias-all-object-class-properties.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-qdev-add-IOThreadVirtQueueMappingList-property-type.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-add-iothread-vq-mapping-parameter.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-Fix-potential-nullpointer-read-access-in-.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-iotests-add-filter_qmp_generated_node_ids.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-iotests-port-141-to-Python-for-reliable-QMP-testing.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-monitor-only-run-coroutine-commands-in-qemu_aio_cont.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-move-dataplane-code-into-virtio-blk.c.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-rename-dataplane-create-destroy-functions.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-rename-dataplane-to-ioeventfd.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-restart-s-rq-reqs-in-vq-AioContexts.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-tolerate-failure-to-set-BlockBackend-AioC.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-blk-always-set-ioeventfd-during-startup.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-tests-unit-Bump-test-replication-timeout-to-60-secon.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-iotests-iothreads-stream-Use-the-right-TimeoutError.patch [RHEL-17369 RHEL-20764 RHEL-7356] - kvm-virtio-mem-default-enable-dynamic-memslots.patch [RHEL-24045] - Resolves: RHEL-20341 (memory-device size alignment check invalid in QEMU 8.2) - Resolves: RHEL-24593 (qemu crash blk_get_aio_context(BlockBackend *): Assertion `ctx == blk->ctx' when repeatedly hotplug/unplug disk) - Resolves: RHEL-17369 ([nfv virt][rt][post-copy migration] qemu-kvm: ../block/qcow2.c:5263: ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *, Error **): Assertion `false' failed.) - Resolves: RHEL-20764 ([qemu-kvm] Enable qemu multiqueue block layer support) - Resolves: RHEL-7356 ([qemu-kvm] no response with QMP command device_add when repeatedly hotplug/unplug virtio disks [RHEL-9]) - Resolves: RHEL-24045 (QEMU: default-enable dynamically using multiple memslots for virtio-mem)
113 lines
4.5 KiB
Diff
113 lines
4.5 KiB
Diff
From 633c6a52ac88526534466ae311522fe5447bcf91 Mon Sep 17 00:00:00 2001
|
|
From: David Hildenbrand <david@redhat.com>
|
|
Date: Wed, 17 Jan 2024 14:55:54 +0100
|
|
Subject: [PATCH 02/22] memory-device: reintroduce memory region size check
|
|
|
|
RH-Author: David Hildenbrand <david@redhat.com>
|
|
RH-MergeRequest: 221: memory-device: reintroduce memory region size check
|
|
RH-Jira: RHEL-20341
|
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
RH-Commit: [2/2] e9ff2339b0c07c3f48f5834c9c80cd6d4cbc8f71
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-20341
|
|
|
|
We used to check that the memory region size is multiples of the overall
|
|
requested address alignment for the device memory address.
|
|
|
|
We removed that check, because there are cases (i.e., hv-balloon) where
|
|
devices unconditionally request an address alignment that has a very large
|
|
alignment (i.e., 32 GiB), but the actual memory device size might not be
|
|
multiples of that alignment.
|
|
|
|
However, this change:
|
|
|
|
(a) allows for some practically impossible DIMM sizes, like "1GB+1 byte".
|
|
(b) allows for DIMMs that partially cover hugetlb pages, previously
|
|
reported in [1].
|
|
|
|
Both scenarios don't make any sense: we might even waste memory.
|
|
|
|
So let's reintroduce that check, but only check that the
|
|
memory region size is multiples of the memory region alignment (i.e.,
|
|
page size, huge page size), but not any additional memory device
|
|
requirements communicated using md->get_min_alignment().
|
|
|
|
The following examples now fail again as expected:
|
|
|
|
(a) 1M with 2M THP
|
|
qemu-system-x86_64 -m 4g,maxmem=16g,slots=1 -S -nodefaults -nographic \
|
|
-object memory-backend-ram,id=mem1,size=1M \
|
|
-device pc-dimm,id=dimm1,memdev=mem1
|
|
-> backend memory size must be multiple of 0x200000
|
|
|
|
(b) 1G+1byte
|
|
|
|
qemu-system-x86_64 -m 4g,maxmem=16g,slots=1 -S -nodefaults -nographic \
|
|
-object memory-backend-ram,id=mem1,size=1073741825B \
|
|
-device pc-dimm,id=dimm1,memdev=mem1
|
|
-> backend memory size must be multiple of 0x200000
|
|
|
|
(c) Unliagned hugetlb size (2M)
|
|
|
|
qemu-system-x86_64 -m 4g,maxmem=16g,slots=1 -S -nodefaults -nographic \
|
|
-object memory-backend-file,id=mem1,mem-path=/dev/hugepages/tmp,size=511M \
|
|
-device pc-dimm,id=dimm1,memdev=mem1
|
|
backend memory size must be multiple of 0x200000
|
|
|
|
(d) Unliagned hugetlb size (1G)
|
|
|
|
qemu-system-x86_64 -m 4g,maxmem=16g,slots=1 -S -nodefaults -nographic \
|
|
-object memory-backend-file,id=mem1,mem-path=/dev/hugepages1G/tmp,size=2047M \
|
|
-device pc-dimm,id=dimm1,memdev=mem1
|
|
-> backend memory size must be multiple of 0x40000000
|
|
|
|
Note that this fix depends on a hv-balloon change to communicate its
|
|
additional alignment requirements using get_min_alignment() instead of
|
|
through the memory region.
|
|
|
|
[1] https://lkml.kernel.org/r/f77d641d500324525ac036fe1827b3070de75fc1.1701088320.git.mprivozn@redhat.com
|
|
|
|
Message-ID: <20240117135554.787344-3-david@redhat.com>
|
|
Reported-by: Zhenyu Zhang <zhenyzha@redhat.com>
|
|
Reported-by: Michal Privoznik <mprivozn@redhat.com>
|
|
Fixes: eb1b7c4bd413 ("memory-device: Drop size alignment check")
|
|
Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
|
|
Tested-by: Mario Casquero <mcasquer@redhat.com>
|
|
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
|
|
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
(cherry picked from commit 540a1abbf0b243e4cfb4333c5d30a041f7080ba4)
|
|
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
---
|
|
hw/mem/memory-device.c | 14 ++++++++++++++
|
|
1 file changed, 14 insertions(+)
|
|
|
|
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
|
|
index a1b1af26bc..e098585cda 100644
|
|
--- a/hw/mem/memory-device.c
|
|
+++ b/hw/mem/memory-device.c
|
|
@@ -374,6 +374,20 @@ void memory_device_pre_plug(MemoryDeviceState *md, MachineState *ms,
|
|
goto out;
|
|
}
|
|
|
|
+ /*
|
|
+ * We always want the memory region size to be multiples of the memory
|
|
+ * region alignment: for example, DIMMs with 1G+1byte size don't make
|
|
+ * any sense. Note that we don't check that the size is multiples
|
|
+ * of any additional alignment requirements the memory device might
|
|
+ * have when it comes to the address in physical address space.
|
|
+ */
|
|
+ if (!QEMU_IS_ALIGNED(memory_region_size(mr),
|
|
+ memory_region_get_alignment(mr))) {
|
|
+ error_setg(errp, "backend memory size must be multiple of 0x%"
|
|
+ PRIx64, memory_region_get_alignment(mr));
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (legacy_align) {
|
|
align = *legacy_align;
|
|
} else {
|
|
--
|
|
2.39.3
|
|
|