[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 3/5] memory-device: Support big alignment requirements
From: |
David Hildenbrand |
Subject: |
[PATCH v1 3/5] memory-device: Support big alignment requirements |
Date: |
Wed, 23 Sep 2020 13:38:58 +0200 |
Let's warn instead of bailing out - the worst thing that can happen is
that we'll fail hot/coldplug later. The user got warned, and this should
be rare.
This will be necessary for memory devices with rather big (user-defined)
alignment requirements - say a virtio-mem device with a 2G block size -
which will become important, for example, when supporting vfio in the
future.
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/mem/memory-device.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 4bc9cf0917..8a736f1a26 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -119,9 +119,10 @@ static uint64_t memory_device_get_free_addr(MachineState
*ms,
/* start of address space indicates the maximum alignment we expect */
if (!QEMU_IS_ALIGNED(range_lob(&as), align)) {
- error_setg(errp, "the alignment (0x%" PRIx64 ") is not supported",
- align);
- return 0;
+ warn_report("the alignment (0x%" PRIx64 ") exceeds the expected"
+ " maximum alignment, memory will get fragmented and not"
+ " all 'maxmem' might be usable for memory devices.",
+ align);
}
memory_device_check_addable(ms, size, &err);
@@ -151,7 +152,7 @@ static uint64_t memory_device_get_free_addr(MachineState
*ms,
return 0;
}
} else {
- if (range_init(&new, range_lob(&as), size)) {
+ if (range_init(&new, QEMU_ALIGN_UP(range_lob(&as), align), size)) {
error_setg(errp, "can't add memory device, device too big");
return 0;
}
--
2.26.2
- [PATCH v1 0/5] virtio-mem: block size and address-assignment optimizations, David Hildenbrand, 2020/09/23
- [PATCH v1 1/5] virtio-mem: Probe THP size to determine default block size, David Hildenbrand, 2020/09/23
- [PATCH v1 2/5] virtio-mem: Check that "memaddr" is multiples of the block size, David Hildenbrand, 2020/09/23
- [PATCH v1 3/5] memory-device: Support big alignment requirements,
David Hildenbrand <=
- [PATCH v1 4/5] memory-device: Add get_min_alignment() callback, David Hildenbrand, 2020/09/23
- [PATCH v1 5/5] virito-mem: Implement get_min_alignment(), David Hildenbrand, 2020/09/23
- Re: [PATCH v1 0/5] virtio-mem: block size and address-assignment optimizations, David Hildenbrand, 2020/09/25