[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 1/5] virtio-blk: store opt_io_size with correct size
From: |
Roman Kagan |
Subject: |
[PATCH v5 1/5] virtio-blk: store opt_io_size with correct size |
Date: |
Tue, 26 May 2020 11:17:36 +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 <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
---
v4 -> v5:
- expand the log [Michael]
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 v5 0/5] block: widen and check consistency of size-related BlockConf properties, Roman Kagan, 2020/05/26
- [PATCH v5 2/5] block: consolidate blocksize properties consistency checks, Roman Kagan, 2020/05/26
- [PATCH v5 1/5] virtio-blk: store opt_io_size with correct size,
Roman Kagan <=
- [PATCH v5 3/5] qdev-properties: blocksize: use same limits in code and description, Roman Kagan, 2020/05/26
- [PATCH v5 5/5] block: lift blocksize property limit to 2 MiB, Roman Kagan, 2020/05/26
- [PATCH v5 4/5] block: make size-related BlockConf properties accept size suffixes, Roman Kagan, 2020/05/26
- Re: [PATCH v5 0/5] block: widen and check consistency of size-related BlockConf properties, no-reply, 2020/05/26
- Re: [PATCH v5 0/5] block: widen and check consistency of size-related BlockConf properties, no-reply, 2020/05/26
- Re: [PATCH v5 0/5] block: widen and check consistency of size-related BlockConf properties, no-reply, 2020/05/26
- Re: [PATCH v5 0/5] block: widen and check consistency of size-related BlockConf properties, Roman Kagan, 2020/05/26