[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/18] ahci: Fix non-NCQ accesses for LBA > 16bits
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 18/18] ahci: Fix non-NCQ accesses for LBA > 16bits |
Date: |
Thu, 19 May 2011 14:33:32 +0200 |
From: Alexander Graf <address@hidden>
AHCI provides two ways of reading/writing data:
1) NCQ
2) ATA commands with the LBA in the command FIS
In the second code path, we didn't handle any LBAs that were bigger than
16 bits, so whenever a guest that used high LBA numbers wanted to access
data, the LBA got truncated down to 16 bits, giving the guest garbage.
This patch adds support for LBAs higher than 16 bits. I've tested that it
works just fine with SeaBIOS and Linux guests. This patch also unbreaks
the often reported grub errors people have seen with AHCI.
Signed-off-by: Alexander Graf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/ide/ahci.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 744d19d..1f008a3 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -884,8 +884,31 @@ static int handle_cmd(AHCIState *s, int port, int slot)
}
if (ide_state->drive_kind != IDE_CD) {
- ide_set_sector(ide_state, (cmd_fis[6] << 16) | (cmd_fis[5] << 8) |
- cmd_fis[4]);
+ /*
+ * We set the sector depending on the sector defined in the FIS.
+ * Unfortunately, the spec isn't exactly obvious on this one.
+ *
+ * Apparently LBA48 commands set fis bytes 10,9,8,6,5,4 to the
+ * 48 bit sector number. ATA_CMD_READ_DMA_EXT is an example for
+ * such a command.
+ *
+ * Non-LBA48 commands however use 7[lower 4 bits],6,5,4 to define a
+ * 28-bit sector number. ATA_CMD_READ_DMA is an example for such
+ * a command.
+ *
+ * Since the spec doesn't explicitly state what each field should
+ * do, I simply assume non-used fields as reserved and OR
everything
+ * together, independent of the command.
+ */
+ ide_set_sector(ide_state, ((uint64_t)cmd_fis[10] << 40)
+ | ((uint64_t)cmd_fis[9] << 32)
+ /* This is used for LBA48 commands */
+ | ((uint64_t)cmd_fis[8] << 24)
+ /* This is used for non-LBA48 commands */
+ | ((uint64_t)(cmd_fis[7] & 0xf) << 24)
+ | ((uint64_t)cmd_fis[6] << 16)
+ | ((uint64_t)cmd_fis[5] << 8)
+ | cmd_fis[4]);
}
/* Copy the ACMD field (ATAPI packet, if any) from the AHCI command
--
1.7.2.3
- [Qemu-devel] [PATCH 07/18] ahci: Fix crashes on duplicate BH registration, (continued)
- [Qemu-devel] [PATCH 07/18] ahci: Fix crashes on duplicate BH registration, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 09/18] qed: Periodically flush and clear need check bit, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 11/18] qed: support for growing images, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 12/18] ide: Split qdev "ide-drive" into "ide-hd" and "ide-cd", Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 10/18] qemu_img: is_not_zero() optimization, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 14/18] defaults: ide-cd, ide-hd and scsi-cd devices suppress default CD-ROM, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 13/18] scsi: Split qdev "scsi-disk" into "scsi-hd" and "scsi-cd", Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 15/18] block QMP: Deprecate query-block's "type", drop info block's "type=", Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 16/18] blockdev: Store -drive option media in DriveInfo, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 17/18] block: Remove type hint, it's guest matter, doesn't belong here, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 18/18] ahci: Fix non-NCQ accesses for LBA > 16bits,
Kevin Wolf <=
- Re: [Qemu-devel] [PULL 00/18] Block patches, Anthony Liguori, 2011/05/19