hw/block/hd-geometry: Do not override specified bios-chs-trans
PATCH 1/1 hw/block/hd-geometry: Do not override specified bios-chs-trans
For small disk images (<4 GiB), QEMU and SeaBIOS default to the LARGE/ECHS disk translation method, but it is not uncommon for other BIOS software to use LBA in these cases as well. Some operating system boot loaders (e.g., NT 4) do not handle LARGE translations outside of fixed configurations. See, e.g., Q154052:
"When starting an x86 based computer, Ntdetect.com retrieves and stores Interrupt 13 information. . . If the disk controller is using a 32 sector/64 head translation scheme, this boundary will be 1 GB. If the controller uses 63 sector/255 head translation [AUTHOR: i.e., LBA], the limit will be 4 GB."
To accommodate these situations, hd_geometry_guess() now follows the disk translation specified by the user even when the ATA disk geometry is guessed.
hd_geometry_guess():
* Only set the disk translation when translation is AUTO.
* Show the soon-to-be active translation (*ptrans) in the trace rather than what was guessed.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/56
--- hw/block/hd-geometry.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
hw/block/hd-geometry.c +6 -1
@@ -150,7 +150,12 @@ void hd_geometry_guess(BlockBackend *blk, translation =BIOS_ATA_TRANSLATION_NONE ; }if (ptrans) { - *ptrans = translation; +if (*ptrans ==BIOS_ATA_TRANSLATION_AUTO ) { + *ptrans = translation; + }else { +/* Defer to the translation specified by the user. */ + translation = *ptrans; + } }trace_hd_geometry_guess (blk, *pcyls, *pheads, *psecs, translation); }
Signature · 1 line
2.34.1
Am 07.07.2022 um 22:40 hat Lev Kujawski geschrieben:
Quoted 5 lines
For small disk images (<4 GiB), QEMU and SeaBIOS default to the LARGE/ECHS disk translation method, but it is not uncommon for other BIOS software to use LBA in these cases as well. Some operating system boot loaders (e.g., NT 4) do not handle LARGE translations outside of fixed configurations. See, e.g., Q154052:
I wonder if this means that we should just always use LBA by default instead of using LARGE for smaller disks, or if this would break other cases that are working well with the current default.
Quoted 15 lines
"When starting an x86 based computer, Ntdetect.com retrieves and stores Interrupt 13 information. . . If the disk controller is using a 32 sector/64 head translation scheme, this boundary will be 1 GB. If the controller uses 63 sector/255 head translation [AUTHOR: i.e., LBA], the limit will be 4 GB."
To accommodate these situations,
hd_geometry_guess()now follows the disk translation specified by the user even when the ATA disk geometry is guessed.
hd_geometry_guess():
* Only set the disk translation when translation is AUTO.
* Show the soon-to-be active translation (*ptrans) in the trace rather than what was guessed.
Quoted 4 lines
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/56
Signed-off-by Lev Kujawski <[email protected]>
Thanks, irrespective of my wondering above, the fix looks right, so I've applied it to my block branch.
Kevin