[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/12] ide: Cap LBA28 capacity announcement to 2^28-1
From: |
Kevin Wolf |
Subject: |
[PULL 04/12] ide: Cap LBA28 capacity announcement to 2^28-1 |
Date: |
Tue, 2 Nov 2021 17:05:20 +0100 |
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
The LBA28 capacity (at offsets 60/61 of identification) is supposed to
express the maximum size supported by LBA28 commands. If the device is
larger than this, we have to cap it to 2^28-1.
At least NetBSD happens to be using this value to determine whether to use
LBA28 or LBA48 for its commands, using LBA28 for sectors that don't need
LBA48. This commit thus fixes NetBSD access to disks larger than 128GiB.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-Id: <20210824104344.3878849-1-samuel.thibault@ens-lyon.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/ide/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index fd69ca3167..e28f8aad61 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -98,8 +98,12 @@ static void put_le16(uint16_t *p, unsigned int v)
static void ide_identify_size(IDEState *s)
{
uint16_t *p = (uint16_t *)s->identify_data;
- put_le16(p + 60, s->nb_sectors);
- put_le16(p + 61, s->nb_sectors >> 16);
+ int64_t nb_sectors_lba28 = s->nb_sectors;
+ if (nb_sectors_lba28 >= 1 << 28) {
+ nb_sectors_lba28 = (1 << 28) - 1;
+ }
+ put_le16(p + 60, nb_sectors_lba28);
+ put_le16(p + 61, nb_sectors_lba28 >> 16);
put_le16(p + 100, s->nb_sectors);
put_le16(p + 101, s->nb_sectors >> 16);
put_le16(p + 102, s->nb_sectors >> 32);
--
2.31.1
- [PULL 00/12] Block layer patches, Kevin Wolf, 2021/11/02
- [PULL 02/12] block: Fail gracefully when blockdev-snapshot creates loops, Kevin Wolf, 2021/11/02
- [PULL 01/12] block/file-posix: Fix return value translation for AIO discards, Kevin Wolf, 2021/11/02
- [PULL 03/12] block/rbd: implement bdrv_co_block_status, Kevin Wolf, 2021/11/02
- [PULL 04/12] ide: Cap LBA28 capacity announcement to 2^28-1,
Kevin Wolf <=
- [PULL 05/12] block/export/fuse.c: fix musl build, Kevin Wolf, 2021/11/02
- [PULL 09/12] block-backend: Silence clang -m32 compiler warning, Kevin Wolf, 2021/11/02
- [PULL 11/12] block/nvme: Display CQ/SQ pointer in nvme_free_queue_pair(), Kevin Wolf, 2021/11/02
- [PULL 08/12] linux-aio: add `dev_max_batch` parameter to laio_io_unplug(), Kevin Wolf, 2021/11/02
- [PULL 12/12] block/nvme: Extract nvme_free_queue() from nvme_free_queue_pair(), Kevin Wolf, 2021/11/02
- [PULL 10/12] block/nvme: Automatically free qemu_memalign() with QEMU_AUTO_VFREE, Kevin Wolf, 2021/11/02
- [PULL 06/12] file-posix: add `aio-max-batch` option, Kevin Wolf, 2021/11/02
- [PULL 07/12] linux-aio: add `dev_max_batch` parameter to laio_co_submit(), Kevin Wolf, 2021/11/02
- Re: [PULL 00/12] Block layer patches, Richard Henderson, 2021/11/03