qemu/hw/ide
Alexander Popov ed78352a59 ide: Fix incorrect handling of some PRDTs in ide_dma_cb()
The commit a718978ed5 from July 2015 introduced the assertion which
implies that the size of successful DMA transfers handled in ide_dma_cb()
should be multiple of 512 (the size of a sector). But guest systems can
initiate DMA transfers that don't fit this requirement.

For fixing that let's check the number of bytes prepared for the transfer
by the prepare_buf() handler. The code in ide_dma_cb() must behave
according to the Programming Interface for Bus Master IDE Controller
(Revision 1.0 5/16/94):
1. If PRDs specified a smaller size than the IDE transfer
   size, then the Interrupt and Active bits in the Controller
   status register are not set (Error Condition).
2. If the size of the physical memory regions was equal to
   the IDE device transfer size, the Interrupt bit in the
   Controller status register is set to 1, Active bit is set to 0.
3. If PRDs specified a larger size than the IDE transfer size,
   the Interrupt and Active bits in the Controller status register
   are both set to 1.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20191223175117.508990-2-alex.popov@linux.com
Signed-off-by: John Snow <jsnow@redhat.com>
2020-01-27 17:07:31 -05:00
..
ahci_internal.h ide: Include hw/ide/internal a bit less outside hw/ide/ 2019-08-16 13:31:52 +02:00
ahci-allwinner.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
ahci.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
atapi.c hw/ide/atapi: Use the ldst API 2019-08-16 19:14:04 -04:00
cmd646.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
core.c ide: Fix incorrect handling of some PRDTs in ide_dma_cb() 2020-01-27 17:07:31 -05:00
ich.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
ioport.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
isa.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
Kconfig hw/ide/ahci: Add a Kconfig switch for the AHCI-ICH9 device 2019-05-13 09:36:31 +02:00
macio.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
Makefile.objs hw/ide/ahci: Add a Kconfig switch for the AHCI-ICH9 device 2019-05-13 09:36:31 +02:00
microdrive.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
mmio.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
pci.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
piix.c vmstate: replace DeviceState with VMStateIf 2020-01-06 18:41:32 +04:00
qdev.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
sii3112.c hw/ide/sii3112: Convert reset handler to DeviceReset 2019-10-15 18:18:08 -03:00
trace-events trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
via.c vmstate: replace DeviceState with VMStateIf 2020-01-06 18:41:32 +04:00