]> git.ipfire.org Git - thirdparty/qemu.git/commit
usb:xhci: no DMA on HC reset
authorRoman Kagan <rkagan@virtuozzo.com>
Wed, 4 May 2016 17:53:55 +0000 (20:53 +0300)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 4 Aug 2016 21:26:45 +0000 (16:26 -0500)
commit2cf1a1223b915ad6813dfc8da9e866d68a11a575
tree537b61da36f0cb3c30ee250ad961fc5e0283e7d9
parentea819be42bf460519d285cc8336defe247fb3739
usb:xhci: no DMA on HC reset

This patch is a rough fix to a memory corruption we are observing when
running VMs with xhci USB controller and OVMF firmware.

Specifically, on the following call chain

xhci_reset
  xhci_disable_slot
    xhci_disable_ep
      xhci_set_ep_state

QEMU overwrites guest memory using stale guest addresses.

This doesn't happen when the guest (firmware) driver sets up xhci for
the first time as there are no slots configured yet.  However when the
firmware hands over the control to the OS some slots and endpoints are
already set up with their context in the guest RAM.  Now the OS' driver
resets the controller again and xhci_set_ep_state then reads and writes
that memory which is now owned by the OS.

As a quick fix, skip calling xhci_set_ep_state in xhci_disable_ep if the
device context base address array pointer is zero (indicating we're in
the HC reset and no DMA is possible).

Cc: qemu-stable@nongnu.org
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Message-id: 1462384435-1034-1-git-send-email-rkagan@virtuozzo.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 491d68d9382dbb588f2ff5132ee3d87ce2f1b230)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/usb/hcd-xhci.c