usb: Fix (another) bug in usb_packet_map() for IOMMU handling

Elements in qemu SGLists can cross IOMMU page boundaries.  So, in commit
39c138c842 "usb: Fix usb_packet_map() in the
presence of IOMMUs", I changed usb_packet_map() to split up each SGList
element on IOMMU page boundaries and each resulting piece of qemu's memory
space separately to the iovec the usb code uses internally.

That was correct in concept, but the patch has a bug.  The 'base' variable
correctly steps through the dma address of each piece, but then we call
the dma_memory_map() function on the base address of the whole SGList
element every time.

This patch fixes at least one problem using XHCI on the pseries guest
machine.  It didn't affect OHCI because that doesn't use usb_packet_map().
In theory it also affects EHCI, but we haven't observed that in practice.
I think the transfers were small enough on EHCI that they never crossed an
IOMMU page boundary in practice.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
David Gibson 2012-11-14 16:23:50 +11:00 committed by Gerd Hoffmann
parent 4ea375bf37
commit 155de06f24
1 changed files with 1 additions and 1 deletions

View File

@ -37,7 +37,7 @@ int usb_packet_map(USBPacket *p, QEMUSGList *sgl)
while (len) {
dma_addr_t xlen = len;
mem = dma_memory_map(sgl->dma, sgl->sg[i].base, &xlen, dir);
mem = dma_memory_map(sgl->dma, base, &xlen, dir);
if (!mem) {
goto err;
}