qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] virtio-mem: Fix the bitmap index of the section offset


From: Michael S. Tsirkin
Subject: Re: [PATCH] virtio-mem: Fix the bitmap index of the section offset
Date: Mon, 19 Dec 2022 05:51:51 -0500

On Fri, Dec 16, 2022 at 02:22:31PM +0800, Chenyi Qiang wrote:
> 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>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

I see David's queueing this.

> ---
>  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.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]