[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 1/8] virtio-blk: store opt_io_size with correct size
From: |
Roman Kagan |
Subject: |
[PATCH v8 1/8] virtio-blk: store opt_io_size with correct size |
Date: |
Fri, 29 May 2020 01:55:09 +0300 |
The width of opt_io_size in virtio_blk_config is 32bit. However, it's
written with virtio_stw_p; this may result in value truncation, and on
big-endian systems with legacy virtio in completely bogus readings in
the guest.
Use the appropriate accessor to store it.
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
hw/block/virtio-blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index f5f6fc925e..413083e62f 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -918,7 +918,7 @@ static void virtio_blk_update_config(VirtIODevice *vdev,
uint8_t *config)
virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls);
virtio_stl_p(vdev, &blkcfg.blk_size, blk_size);
virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size);
- virtio_stw_p(vdev, &blkcfg.opt_io_size, conf->opt_io_size / blk_size);
+ virtio_stl_p(vdev, &blkcfg.opt_io_size, conf->opt_io_size / blk_size);
blkcfg.geometry.heads = conf->heads;
/*
* We must ensure that the block device capacity is a multiple of
--
2.26.2
- [PATCH v8 0/8] block: enhance handling of size-related BlockConf properties, Roman Kagan, 2020/05/28
- [PATCH v8 1/8] virtio-blk: store opt_io_size with correct size,
Roman Kagan <=
- [PATCH v8 2/8] block: consolidate blocksize properties consistency checks, Roman Kagan, 2020/05/28
- [PATCH v8 3/8] qdev-properties: blocksize: use same limits in code and description, Roman Kagan, 2020/05/28
- [PATCH v8 4/8] qdev-properties: add size32 property type, Roman Kagan, 2020/05/28
- [PATCH v8 5/8] qdev-properties: make blocksize accept size suffixes, Roman Kagan, 2020/05/28
- [PATCH v8 6/8] block: make BlockConf size props 32bit and accept size suffixes, Roman Kagan, 2020/05/28
- [PATCH v8 7/8] qdev-properties: add getter for size32 and blocksize, Roman Kagan, 2020/05/28
- [PATCH v8 8/8] block: lift blocksize property limit to 2 MiB, Roman Kagan, 2020/05/28