[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 05/31] memory-device: Support big alignment requirements
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 05/31] memory-device: Support big alignment requirements |
Date: |
Wed, 4 Nov 2020 13:41:30 -0500 |
From: David Hildenbrand <david@redhat.com>
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.
Reviewed-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
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>
Message-Id: <20201008083029.9504-5-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@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;
}
--
MST
- [PULL v3 00/31] pc,pci,vhost,virtio: fixes, Michael S. Tsirkin, 2020/11/04
- [PULL v3 01/31] pc: comment style fixup, Michael S. Tsirkin, 2020/11/04
- [PULL v3 02/31] virtio-mem: Make sure "addr" is always multiples of the block size, Michael S. Tsirkin, 2020/11/04
- [PULL v3 03/31] virtio-mem: Make sure "usable_region_size" is always multiples of the block size, Michael S. Tsirkin, 2020/11/04
- [PULL v3 04/31] virtio-mem: Probe THP size to determine default block size, Michael S. Tsirkin, 2020/11/04
- [PULL v3 05/31] memory-device: Support big alignment requirements,
Michael S. Tsirkin <=
- [PULL v3 06/31] memory-device: Add get_min_alignment() callback, Michael S. Tsirkin, 2020/11/04
- [PULL v3 08/31] hw/acpi : Don't use '#' flag of printf format, Michael S. Tsirkin, 2020/11/04
- [PULL v3 07/31] virito-mem: Implement get_min_alignment(), Michael S. Tsirkin, 2020/11/04
- [PULL v3 09/31] hw/acpi : add space before the open parenthesis '(', Michael S. Tsirkin, 2020/11/04
- [PULL v3 11/31] hw/virtio/vhost-backend: Fix Coverity CID 1432871, Michael S. Tsirkin, 2020/11/04
- [PULL v3 12/31] hw/smbios: Fix leaked fd in save_opt_one() error path, Michael S. Tsirkin, 2020/11/04
- [PULL v3 13/31] virtio-iommu: Fix virtio_iommu_mr(), Michael S. Tsirkin, 2020/11/04
- [PULL v3 14/31] virtio-iommu: Store memory region in endpoint struct, Michael S. Tsirkin, 2020/11/04
- [PULL v3 15/31] virtio-iommu: Add memory notifiers for map/unmap, Michael S. Tsirkin, 2020/11/04
- [PULL v3 16/31] virtio-iommu: Call memory notifiers in attach/detach, Michael S. Tsirkin, 2020/11/04