All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ide: Cap LBA28 capacity announcement to 2^28-1
@ 2021-08-24 10:43 Samuel Thibault
  2021-09-05  7:30 ` Samuel Thibault
  2021-10-05 23:57 ` Samuel Thibault
  0 siblings, 2 replies; 4+ messages in thread
From: Samuel Thibault @ 2021-08-24 10:43 UTC (permalink / raw)
  To: qemu-devel, John Snow; +Cc: Samuel Thibault, damien, qemu-block

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>
---
 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.32.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ide: Cap LBA28 capacity announcement to 2^28-1
  2021-08-24 10:43 [PATCH] ide: Cap LBA28 capacity announcement to 2^28-1 Samuel Thibault
@ 2021-09-05  7:30 ` Samuel Thibault
  2021-10-05 23:57 ` Samuel Thibault
  1 sibling, 0 replies; 4+ messages in thread
From: Samuel Thibault @ 2021-09-05  7:30 UTC (permalink / raw)
  To: qemu-devel, John Snow; +Cc: damien, qemu-block

Ping?

Samuel Thibault, le mar. 24 août 2021 12:43:44 +0200, a ecrit:
> 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>
> ---
>  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.32.0
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ide: Cap LBA28 capacity announcement to 2^28-1
  2021-08-24 10:43 [PATCH] ide: Cap LBA28 capacity announcement to 2^28-1 Samuel Thibault
  2021-09-05  7:30 ` Samuel Thibault
@ 2021-10-05 23:57 ` Samuel Thibault
  2021-10-20  8:57   ` Kevin Wolf
  1 sibling, 1 reply; 4+ messages in thread
From: Samuel Thibault @ 2021-10-05 23:57 UTC (permalink / raw)
  To: qemu-devel, John Snow; +Cc: damien, qemu-block

Ping?

Samuel Thibault, le mar. 24 août 2021 12:43:44 +0200, a ecrit:
> 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>
> ---
>  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.32.0
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ide: Cap LBA28 capacity announcement to 2^28-1
  2021-10-05 23:57 ` Samuel Thibault
@ 2021-10-20  8:57   ` Kevin Wolf
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2021-10-20  8:57 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: damien, John Snow, qemu-devel, qemu-block

Am 06.10.2021 um 01:57 hat Samuel Thibault geschrieben:
> Ping?
> 
> Samuel Thibault, le mar. 24 août 2021 12:43:44 +0200, a ecrit:
> > 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>

Thanks, applied to the block branch. (I hope John doesn't have a problem
with me stealing this patch from his maintainership area.)

Kevin



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-20  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 10:43 [PATCH] ide: Cap LBA28 capacity announcement to 2^28-1 Samuel Thibault
2021-09-05  7:30 ` Samuel Thibault
2021-10-05 23:57 ` Samuel Thibault
2021-10-20  8:57   ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.