[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 2/6] virtio-mem: Make sure "usable_region_size" is always mult
From: |
David Hildenbrand |
Subject: |
[PATCH v3 2/6] virtio-mem: Make sure "usable_region_size" is always multiples of the block size |
Date: |
Thu, 8 Oct 2020 10:30:25 +0200 |
The spec states:
"The device MUST set addr, region_size, usable_region_size, plugged_size,
requested_size to multiples of block_size."
With block sizes > 256MB, we currently wouldn't guarantee that for the
usable_region_size.
Note that we cannot exceed the region_size, as we already enforce the
alignment there properly.
Fixes: 910b25766b33 ("virtio-mem: Paravirtualized memory hot(un)plug")
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Wei Yang <richardw.yang@linux.intel.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/virtio/virtio-mem.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index 70200b4eac..461ac68ee8 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -227,6 +227,9 @@ static void virtio_mem_resize_usable_region(VirtIOMEM *vmem,
uint64_t newsize = MIN(memory_region_size(&vmem->memdev->mr),
requested_size + VIRTIO_MEM_USABLE_EXTENT);
+ /* The usable region size always has to be multiples of the block size. */
+ newsize = QEMU_ALIGN_UP(newsize, vmem->block_size);
+
if (!requested_size) {
newsize = 0;
}
--
2.26.2
- [PATCH v3 0/6] virtio-mem: block size and address-assignment optimizations, David Hildenbrand, 2020/10/08
- [PATCH v3 1/6] virtio-mem: Make sure "addr" is always multiples of the block size, David Hildenbrand, 2020/10/08
- [PATCH v3 2/6] virtio-mem: Make sure "usable_region_size" is always multiples of the block size,
David Hildenbrand <=
- [PATCH v3 3/6] virtio-mem: Probe THP size to determine default block size, David Hildenbrand, 2020/10/08
- [PATCH v3 4/6] memory-device: Support big alignment requirements, David Hildenbrand, 2020/10/08
- [PATCH v3 5/6] memory-device: Add get_min_alignment() callback, David Hildenbrand, 2020/10/08
- [PATCH v3 6/6] virito-mem: Implement get_min_alignment(), David Hildenbrand, 2020/10/08
- Re: [PATCH v3 0/6] virtio-mem: block size and address-assignment optimizations, David Hildenbrand, 2020/10/22