[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/47] virtio-mem: Fix the bitmap index of the section offset
From: |
Michael Tokarev |
Subject: |
[PATCH 03/47] virtio-mem: Fix the bitmap index of the section offset |
Date: |
Wed, 8 Mar 2023 19:57:06 +0300 |
From: Chenyi Qiang <chenyi.qiang@intel.com>
vmem->bitmap indexes the memory region of the virtio-mem backend at a
granularity of block_size. To calculate the index of target section offset,
the block_size should be divided instead of the bitmap_size.
Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface")
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Message-Id: <20221216062231.11181-1-chenyi.qiang@intel.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: David Hildenbrand <david@redhat.com>
(cherry picked from commit b11cf32e07a2f7ff0d171b89497381a04c9d07e0)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/virtio/virtio-mem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ed170def48..e19ee817fe 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -235,7 +235,7 @@ static int virtio_mem_for_each_plugged_section(const
VirtIOMEM *vmem,
uint64_t offset, size;
int ret = 0;
- first_bit = s->offset_within_region / vmem->bitmap_size;
+ first_bit = s->offset_within_region / vmem->block_size;
first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
while (first_bit < vmem->bitmap_size) {
MemoryRegionSection tmp = *s;
@@ -267,7 +267,7 @@ static int virtio_mem_for_each_unplugged_section(const
VirtIOMEM *vmem,
uint64_t offset, size;
int ret = 0;
- first_bit = s->offset_within_region / vmem->bitmap_size;
+ first_bit = s->offset_within_region / vmem->block_size;
first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
while (first_bit < vmem->bitmap_size) {
MemoryRegionSection tmp = *s;
--
2.30.2
- [PATCH 35/47] vhost-user-rng: Back up vqs before cleaning up vhost_dev, (continued)
- [PATCH 35/47] vhost-user-rng: Back up vqs before cleaning up vhost_dev, Michael Tokarev, 2023/03/08
- [PATCH 38/47] hw/timer/hpet: Fix expiration time overflow, Michael Tokarev, 2023/03/08
- [PATCH 39/47] vdpa: stop all svq on device deletion, Michael Tokarev, 2023/03/08
- [PATCH 37/47] virtio-rng-pci: fix transitional migration compat for vectors, Michael Tokarev, 2023/03/08
- [PATCH 43/47] intel-iommu: fail MAP notifier without caching mode, Michael Tokarev, 2023/03/08
- [PATCH 45/47] block: Handle curl 7.55.0, 7.85.0 version changes, Michael Tokarev, 2023/03/08
- [PATCH 44/47] intel-iommu: fail DEVIOTLB_UNMAP without dt mode, Michael Tokarev, 2023/03/08
- [PATCH 46/47] tests/tcg: fix unused variable in linux-test, Michael Tokarev, 2023/03/08
- [PATCH 47/47] build-sys: fix crlf-ending C code, Michael Tokarev, 2023/03/08
- [PATCH 01/47] target/sh4: Mask restore of env->flags from tb->flags, Michael Tokarev, 2023/03/08
- [PATCH 03/47] virtio-mem: Fix the bitmap index of the section offset,
Michael Tokarev <=
- [PATCH 09/47] hw/nvme: fix missing endian conversions for doorbell buffers, Michael Tokarev, 2023/03/08
- [PATCH 08/47] acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block, Michael Tokarev, 2023/03/08
- [PATCH 04/47] virtio-mem: Fix the iterator variable in a vmem->rdl_list loop, Michael Tokarev, 2023/03/08
- [PATCH 36/47] virtio-rng-pci: fix migration compat for vectors, Michael Tokarev, 2023/03/08
- Re: [RFC PATCH 00/47] Patch Round-up for stable 7.2.1, Thomas Huth, 2023/03/22