diff options
author | David Hildenbrand <david@redhat.com> | 2023-10-23 13:13:41 +0200 |
---|---|---|
committer | David Hildenbrand <david@redhat.com> | 2023-11-13 09:35:44 +0100 |
commit | 364eff6885a79869a074852d628dfa7a137ba492 (patch) | |
tree | 47b95ec9f31b08f9cef84d05c5e10a4f0364e084 /qemu-io.c | |
parent | 69680740eafa1838527c90155a7432d51b8ff203 (diff) | |
download | qemu-364eff6885a79869a074852d628dfa7a137ba492.zip qemu-364eff6885a79869a074852d628dfa7a137ba492.tar.gz qemu-364eff6885a79869a074852d628dfa7a137ba492.tar.bz2 |
virtio-mem: fix division by zero in virtio_mem_activate_memslots_to_plug()
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.
Message-ID: <20231023111341.219317-1-david@redhat.com>
Reprted-by: Mario Casquero <mcasquer@redhat.com>
Fixes: 177f9b1ee464 ("virtio-mem: Expose device memory dynamically via multiple memslots if enabled")
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Tested-by: Mario Casquero <mcasquer@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Diffstat (limited to 'qemu-io.c')
0 files changed, 0 insertions, 0 deletions