Skip to contentSkip to conversation

virtio-mem: Don't skip alignment checks when warning about block size

PATCH In review David Hildenbrand 2 participants 5 messages Oct 11, 2021 – Dec 17, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-mem: Don't skip alignment checks when warning about block size

If we warn about the block size being smaller than the default, we skip some alignment checks.

This can currently only fail on x86-64, when specifying a block size of 1 MiB, however, we detect the THP size of 2 MiB.

Fixes 228957fea3a9 ("virtio-mem: Probe THP size to determine default block size")
Cc "Michael S. Tsirkin" <[email protected]>
---
 hw/virtio/virtio-mem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/virtio-mem.c +2 -1
index df91e454b2..7ce9901791 100644
@@ -701,7 +701,8 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
         warn_report("'%s' property is smaller than the default block size (%"
                     PRIx64 " MiB)", VIRTIO_MEM_BLOCK_SIZE_PROP,
                     virtio_mem_default_block_size(rb) / MiB);
-    } else if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
+    }
+    if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
         error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" PRIx64
                    ")", VIRTIO_MEM_REQUESTED_SIZE_PROP,
                    VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size);
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · David Hildenbrand

If we warn about the block size being smaller than the default, we skip some alignment checks.

This can currently only fail on x86-64, when specifying a block size of 1 MiB, however, we detect the THP size of 2 MiB.

Fixes 228957fea3a9 ("virtio-mem: Probe THP size to determine default block size")
Cc "Michael S. Tsirkin" <[email protected]>
Quoted 20 lines
---
 hw/virtio/virtio-mem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/virtio-mem.c +2 -1
index df91e454b2..7ce9901791 100644
@@ -701,7 +701,8 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
         warn_report("'%s' property is smaller than the default block size (%"
                     PRIx64 " MiB)", VIRTIO_MEM_BLOCK_SIZE_PROP,
                     virtio_mem_default_block_size(rb) / MiB);
-    } else if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
+    }
+    if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
         error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" PRIx64
                    ")", VIRTIO_MEM_REQUESTED_SIZE_PROP,
                    VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size);
Signature · 1 line
2.31.1
#2 lore raw
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · David Hildenbrand

If we warn about the block size being smaller than the default, we skip some alignment checks.

Quoted 8 lines
Quoted 6 lines

This can currently only fail on x86-64, when specifying a block size of 1 MiB, however, we detect the THP size of 2 MiB.

Fixes 228957fea3a9 ("virtio-mem: Probe THP size to determine default block size")
Cc "Michael S. Tsirkin" <[email protected]>

Thanks Michael, will you send this for the v6.2 release?

Signature · 3 lines
Thanks,

David / dhildenb
#3 lore raw
Quoted 8 lines · David Hildenbrand
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · David Hildenbrand

If we warn about the block size being smaller than the default, we skip some alignment checks.

This can currently only fail on x86-64, when specifying a block size of 1 MiB, however, we detect the THP size of 2 MiB.

Quoted 13 lines
Quoted 5 lines
Quoted 3 lines
Fixes 228957fea3a9 ("virtio-mem: Probe THP size to determine default block size")
Cc "Michael S. Tsirkin" <[email protected]>

Thanks Michael, will you send this for the v6.2 release?

Signature · 3 lines
Thanks,

David / dhildenb

sure

#4 lore raw
In reply to David Hildenbrand
Quoted 19 lines · David Hildenbrand

If we warn about the block size being smaller than the default, we skip some alignment checks.

This can currently only fail on x86-64, when specifying a block size of 1 MiB, however, we detect the THP size of 2 MiB.

Fixes 228957fea3a9 ("virtio-mem: Probe THP size to determine default block size")
Cc "Michael S. Tsirkin" <[email protected]>
---
 hw/virtio/virtio-mem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/virtio-mem.c +0 -0
index df91e454b2..7ce9901791 100644

hw/virtio/virtio-mem.c static void virtio_mem_device_realize(DeviceState *dev, Error **errp) · line 708

Quoted 9 lines
hw/virtio/virtio-mem.c +2 -1
@@ -701,7 +701,8 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
         warn_report("'%s' property is smaller than the default block size (%"
                     PRIx64 " MiB)", VIRTIO_MEM_BLOCK_SIZE_PROP,
                     virtio_mem_default_block_size(rb) / MiB);
-    } else if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
+    }
+    if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
         error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" PRIx64
                    ")", VIRTIO_MEM_REQUESTED_SIZE_PROP,
                    VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size);

Ping, this already missed the v6.2 release ...

Signature · 3 lines
Thanks,

David / dhildenb