qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v1] virtio-mem: fix division by zero in virtio_mem_activate_m


From: David Hildenbrand
Subject: Re: [PATCH v1] virtio-mem: fix division by zero in virtio_mem_activate_memslots_to_plug()
Date: Thu, 2 Nov 2023 14:25:07 +0100
User-agent: Mozilla Thunderbird

On 23.10.23 13:13, David Hildenbrand wrote:
When running with "dynamic-memslots=off", we enter
virtio_mem_activate_memslots_to_plug() to return immediately again
because "vmem->dynamic_memslots == false". However, the compiler might
not optimize out calculating start_idx+end_idx, where we divide by
vmem->memslot_size. In such a configuration, the memslot size is 0 and
we'll get a division by zero:

     (qemu) qom-set vmem0 requested-size 3G
     (qemu) q35.sh: line 38: 622940 Floating point exception(core dumped)

The same is true for virtio_mem_deactivate_unplugged_memslots(), however
we never really reach that code without a prior
virtio_mem_activate_memslots_to_plug() call.

Let's fix it by simply calling these functions only with
"dynamic-memslots=on".

This was found when using a debug build of QEMU.

Reprted-by: Mario Casquero <mcasquer@redhat.com>
Fixes: 177f9b1ee464 ("virtio-mem: Expose device memory dynamically via multiple 
memslots if enabled")
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---

Queued to

https://github.com/davidhildenbrand/qemu.git mem-next

--
Cheers,

David / dhildenb




reply via email to

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