diff options
author | Chenyi Qiang <chenyi.qiang@intel.com> | 2022-12-16 14:22:31 +0800 |
---|---|---|
committer | David Hildenbrand <david@redhat.com> | 2022-12-28 14:59:47 +0100 |
commit | b11cf32e07a2f7ff0d171b89497381a04c9d07e0 (patch) | |
tree | 9c717a8ecab78676c5255249dc0336b9d6e6ff9c /hw | |
parent | 222059a0fccf4af3be776fe35a5ea2d6a68f9a0b (diff) | |
download | qemu-b11cf32e07a2f7ff0d171b89497381a04c9d07e0.zip qemu-b11cf32e07a2f7ff0d171b89497381a04c9d07e0.tar.gz qemu-b11cf32e07a2f7ff0d171b89497381a04c9d07e0.tar.bz2 |
virtio-mem: Fix the bitmap index of the section offset
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>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/virtio/virtio-mem.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index d96bde1..5c22c4b 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; |