ehci: fix fetch qtd race
commitb7d3a7e1a8830af78e71952e82f186b12b70ff1f
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 26 Nov 2018 10:08:36 +0000 (26 11:08 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 10 Dec 2018 14:30:18 +0000 (10 15:30 +0100)
tree1c85bcb28261739dbc9ae3b16e9dac184ac98aba
parent5621d0453c60ce4fc104a9795791d6402386c3b3
ehci: fix fetch qtd race

The token field contains the (guest-filled) state of the qtd, which
indicates whenever the other fields are valid or not.  So make sure
we read the token first, otherwise we may end up with an stale next
pointer:

  (1) ehci reads next
  (2) guest writes next
  (3) guest writes token
  (4) ehci reads token
  (5) ehci operates with stale next.

Typical effect is that qemu doesn't notice that the guest appends new
qtds to the end of the queue.  Looks like the usb device stopped
responding.  Linux can recover from that, but leaves a message in the
kernel log that it did reset the usb device in question.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20181126100836.8805-1-kraxel@redhat.com
hw/usb/hcd-ehci.c