qemu-patch-raspberry4/hw/ide
John Snow a718978ed5 ide: add limit to .prepare_buf()
prepare_buf should not always grab as many descriptors
as it can, sometimes it should self-limit.

For example, an NCQ transfer of 1 sector with a PRDT that
describes 4GiB of data should not copy 4GiB of data, it
should just transfer that first 512 bytes.

PIO is not affected, because the dma_buf_rw dma helpers
already have a byte limit built-in to them, but DMA/NCQ
will exhaust the entire list regardless of requested size.

AHCI 1.3 specifies in section 6.1.6 Command List Underflow that
NCQ is not required to detect underflow conditions. Non-NCQ
pathways signal underflow by writing to the PRDBC field, which
will already occur by writing the actual transferred byte count
to the PRDBC, signaling the underflow.

Our NCQ pathways aren't required to detect underflow, but since our DMA
backend uses the size of the PRDT to determine the size of the transer,
if our PRDT is bigger than the transaction (the underflow condition) it
doesn't cost us anything to detect it and truncate the PRDT.

This is a recoverable error and is not signaled to the guest, in either
NCQ or normal DMA cases.

For BMDMA, the existing pathways should see no guest-visible difference,
but any bytes described in the overage will no longer be transferred
before indicating to the guest that there was an underflow.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1435767578-32743-2-git-send-email-jsnow@redhat.com
2015-07-04 02:06:04 -04:00
..
ahci.c ide: add limit to .prepare_buf() 2015-07-04 02:06:04 -04:00
ahci.h ahci: separate prdtl from opts 2015-07-04 02:06:03 -04:00
atapi.c ide: commonize io_buffer_index initialization 2015-03-10 14:02:22 +01:00
cmd646.c Block patches for 2.3 2015-03-10 14:01:22 +00:00
core.c ide: add limit to .prepare_buf() 2015-07-04 02:06:04 -04:00
ich.c ich9/ahci: Enable Migration 2015-05-22 15:58:22 -04:00
internal.h ide: add limit to .prepare_buf() 2015-07-04 02:06:04 -04:00
isa.c ide: support PIO restart for the ISA controller 2015-03-10 14:02:23 +01:00
macio.c ide: add limit to .prepare_buf() 2015-07-04 02:06:04 -04:00
Makefile.objs hw: make all of hw/ide/ configurable via default-configs/ 2013-04-08 18:13:12 +02:00
microdrive.c hmp: Remove "info pcmcia" 2014-10-24 12:19:11 +01:00
mmio.c hw: Convert from BlockDriverState to BlockBackend, mostly 2014-10-20 14:02:25 +02:00
pci.c ide: add limit to .prepare_buf() 2015-07-04 02:06:04 -04:00
pci.h ide: place initial state of the current request to IDEBus 2015-03-10 14:02:22 +01:00
piix.c Block patches for 2.3 2015-03-10 14:01:22 +00:00
qdev.c BlockConf: Call backend functions to detect geometry and blocksizes 2015-03-10 14:02:22 +01:00
via.c Block patches for 2.3 2015-03-10 14:01:22 +00:00