From 9caa19be0e534c687081fbdfcd301406e728c98c Mon Sep 17 00:00:00 2001 From: Sam Eiderman Date: Wed, 12 Jun 2019 12:37:04 +0300 Subject: geometry: Apply LCHS values for boot devices Boot devices which use overriden LCHS values are: * ata * ahci * scsi * esp * lsi * megasas * mpt * pvscsi * virtio * virtio-blk We use these values in get_translation() and setup_translation() by introducing a new translation type: "TRANSLATION_MACHINE". We treat this translation as TRANSLATION_NONE in fill_ata_edd(), although this does not really matter since now the translation between physical and logical geometry does not exist. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Message-Id: <20190612093704.47175-6-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann --- src/block.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/block.c') diff --git a/src/block.c b/src/block.c index f73ec18c..ca23a83a 100644 --- a/src/block.c +++ b/src/block.c @@ -69,9 +69,17 @@ int create_bounce_buf(void) * Disk geometry translation ****************************************************************/ +static int +overriden_lchs_supplied(struct drive_s *drive) +{ + return drive->lchs.cylinder || drive->lchs.head || drive->lchs.sector; +} + static u8 get_translation(struct drive_s *drive) { + if (overriden_lchs_supplied(drive)) + return TRANSLATION_MACHINE; u8 type = drive->type; if (CONFIG_QEMU && type == DTYPE_ATA) { // Emulators pass in the translation info via nvram. @@ -159,6 +167,16 @@ setup_translation(struct drive_s *drive) break; } break; + case TRANSLATION_MACHINE: + desc = "overriden"; + cylinders = drive->lchs.cylinder; + heads = drive->lchs.head; + if (heads > 255) + heads = 255; + spt = drive->lchs.sector; + if (spt > 63) + spt = 63; + break; } // clip to 1024 cylinders in lchs if (cylinders > 1024) @@ -423,7 +441,8 @@ fill_ata_edd(struct segoff_s edd, struct drive_s *drive_gf) u16 options = 0; if (GET_GLOBALFLAT(drive_gf->type) == DTYPE_ATA) { u8 translation = GET_GLOBALFLAT(drive_gf->translation); - if (translation != TRANSLATION_NONE) { + if ((translation != TRANSLATION_NONE) && + (translation != TRANSLATION_MACHINE)) { options |= 1<<3; // CHS translation if (translation == TRANSLATION_LBA) options |= 1<<9; -- cgit