1. 01 2月, 2017 1 次提交
  2. 25 1月, 2017 1 次提交
    • D
      PCI/migration merge vmstate_pci_device and vmstate_pcie_device · 20daa90a
      Dr. David Alan Gilbert 提交于
      The vmstate_pci_device and vmstate_pcie_devices differ
      just in the size of one buffer; combine the two using a _TEST
      macro.
      
      I think this is safe as long as everywhere which currently
      uses either of these two uses the right type.
      
      One thing that concerns me is that some places use pci_device_load/save
      which does some irq mangling, but others just use the VMSTATE_PCI_DEVICE
      macro - how are they getting the same irq mangling?
      
      This passes a smoke test migrate of:
      ./x86_64-softmmu/qemu-system-x86_64 -M pc,accel=kvm -m 1024
      ./littlefed20.img -device e1000e -device virtio-net -device
      e1000 -device virtio-rng -device megasas -device megasas-gen2 -device
      ioh3420 -device nec-usb-xhci
      
      to an unmodified qemu.
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20161214195829.18241-1-dgilbert@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      20daa90a
  3. 12 10月, 2016 8 次提交
  4. 13 9月, 2016 2 次提交
  5. 20 7月, 2016 1 次提交
  6. 12 7月, 2016 1 次提交
    • Z
      nec-usb-xhci: set the device state to USB_STATE_DEFAULT · a4055d85
      Zhang Shuaiyi 提交于
      This patch is a rough fix to "hw/usb/core.c:401: usb_handle_packet:
       Assertion `dev->state == 3' failed.". Qemu will crash when a usb3
      device redirect to Windows7 VM via nec-usb-xhci.
      
      In extensible-host-controler-interface-usb-xhci.pdf P94(4.6.5
      Address Device):
          • If the Block Set Address Request (BSR) flag = ‘1’
              • If the slot is in the Enabled state:
                  ...
                  • Set the Slot State in the Output Slot Context to Default.
      
      BSR = ‘1’: Enabled state to Default state; BSR = ‘0’: Default state
      to Addressed state. Try to call usb_device_reset to set device state
      to USB_STATE_DEFAULT in xhci_address_slot wether bsr is zero.
      Signed-off-by: NZhang Shuaiyi <zhang_syi@massclouds.com>
      Message-id: 1467258640-11921-1-git-send-email-zhang_syi@massclouds.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      a4055d85
  7. 05 7月, 2016 2 次提交
  8. 11 5月, 2016 1 次提交
    • R
      usb:xhci: no DMA on HC reset · 491d68d9
      Roman Kagan 提交于
      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: NRoman Kagan <rkagan@virtuozzo.com>
      Message-id: 1462384435-1034-1-git-send-email-rkagan@virtuozzo.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      491d68d9
  9. 18 3月, 2016 1 次提交
  10. 29 1月, 2016 1 次提交
    • P
      usb: Clean up includes · e532b2e0
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1453832250-766-20-git-send-email-peter.maydell@linaro.org
      e532b2e0
  11. 06 11月, 2015 1 次提交
  12. 11 9月, 2015 1 次提交
  13. 17 7月, 2015 1 次提交
  14. 08 5月, 2015 4 次提交
  15. 03 3月, 2015 1 次提交
    • L
      xhci: generate a Transfer Event for each Transfer TRB with the IOC bit set · aa685789
      Laszlo Ersek 提交于
      At the moment, when the XHCI driver in edk2
      (MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf) runs on QEMU, with the options
      
        -device nec-usb-xhci -device usb-kbd
      
      it crashes with:
      
        ASSERT MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c(1759):
        TrsRing != ((void*) 0)
      
      The crash hits in the following edk2 call sequence (all files under
      MdeModulePkg/Bus/):
      
      UsbEnumerateNewDev()                         [Usb/UsbBusDxe/UsbEnumer.c]
        UsbBuildDescTable()                        [Usb/UsbBusDxe/UsbDesc.c]
          UsbGetDevDesc()                          [Usb/UsbBusDxe/UsbDesc.c]
            UsbCtrlGetDesc(USB_REQ_GET_DESCRIPTOR) [Usb/UsbBusDxe/UsbDesc.c]
              UsbCtrlRequest()                     [Usb/UsbBusDxe/UsbDesc.c]
                UsbHcControlTransfer()             [Usb/UsbBusDxe/UsbUtility.c]
                  XhcControlTransfer()             [Pci/XhciDxe/Xhci.c]
                    XhcCreateUrb()                 [Pci/XhciDxe/XhciSched.c]
                      XhcCreateTransferTrb()       [Pci/XhciDxe/XhciSched.c]
                    XhcExecTransfer()              [Pci/XhciDxe/XhciSched.c]
                      XhcCheckUrbResult()          [Pci/XhciDxe/XhciSched.c]
                        //
                        // look for TRB_TYPE_DATA_STAGE event [1]
                        //
                    //
                    // Store a copy of the device descriptor, as the hub device
                    // needs this info to configure endpoint. [2]
                    //
        UsbSetConfig()                             [Usb/UsbBusDxe/UsbDesc.c]
          UsbCtrlRequest(USB_REQ_SET_CONFIG)       [Usb/UsbBusDxe/UsbDesc.c]
            UsbHcControlTransfer()                 [Usb/UsbBusDxe/UsbUtility.c]
              XhcControlTransfer()                 [Pci/XhciDxe/Xhci.c]
                XhcSetConfigCmd()                  [Pci/XhciDxe/XhciSched.c]
                  XhcInitializeEndpointContext()   [Pci/XhciDxe/XhciSched.c]
                    //
                    // allocate transfer ring for the endpoint [3]
                    //
      
      USBKeyboardDriverBindingStart()              [Usb/UsbKbDxe/EfiKey.c]
        UsbIoAsyncInterruptTransfer()              [Usb/UsbBusDxe/UsbBus.c]
          UsbHcAsyncInterruptTransfer()            [Usb/UsbBusDxe/UsbUtility.c]
            XhcAsyncInterruptTransfer()            [Pci/XhciDxe/Xhci.c]
              XhcCreateUrb()                       [Pci/XhciDxe/Xhci.c]
                XhcCreateTransferTrb()             [Pci/XhciDxe/XhciSched.c]
                  XhcSyncTrsRing()                 [Pci/XhciDxe/XhciSched.c]
                    ASSERT (TrsRing != NULL) [4]
      
      UsbEnumerateNewDev() in the USB bus driver issues a GET_DESCRIPTOR
      request, in order to determine the number of configurations that the
      endpoint supports. The requests consists of three stages (three TRBs),
      setup, data, and status. The length of the response is determined in [1],
      namely from the transfer event that the host controller generates in
      response to the request's middle stage (ie. the data stage).
      
      If the length of the answer is correct (a full GET_DESCRIPTOR request
      takes 18 bytes), then the XHCI driver that underlies the USB bus driver
      "snoops" (caches) the descriptor data for later [2].
      
      Later, the USB bus driver sends a SET_CONFIG request. The underlying XHCI
      driver allocates a transfer ring for the endpoint, relying on the data
      snooped and cached in step [2].
      
      Finally, the USB keyboard driver submits an asynchronous interrupt
      transfer to manage the keyboard. As part of this it asserts [4] that the
      ring has been allocated in step [3].
      
      And this ASSERT() fires. The root cause can be found in the way QEMU
      handles the initial GET_DESCRIPTOR request.
      
      Again, that request consists of three stages (TRBs, Transfer Request
      Blocks), "setup", "data", and "status". The XhcCreateTransferTrb()
      function sets the IOC ("Interrupt on Completion") flag in each of these
      TRBs.
      
      According to the XHCI specification, the host controller shall generate a
      Transfer Event in response to *each* individual TRB of the request that
      had the IOC flag set. This means that QEMU should queue three events:
      setup, data, and status, for edk2's XHCI driver.
      
      However, QEMU only generates two events:
      - one for the setup (ie. 1st) stage,
      - another for the status (ie. 3rd) stage.
      
      No event is generated for the middle (ie. data) stage. The loop in QEMU's
      xhci_xfer_report() function runs three times, but due to the "reported"
      variable, only the first and the last TRBs elicit events, the middle (data
      stage) results in no event queued.
      
      As a consequence:
      - When handling the GET_DESCRIPTOR request, XhcCheckUrbResult() in [1]
        does not update the response length from zero.
      
      - XhcControlTransfer() thinks that the response is invalid (it has zero
        length payload instead of 18 bytes), hence [2] is not reached; the
        device descriptor is not stashed for later, and the number of possible
        configurations is left at zero.
      
      - When handling the SET_CONFIG request, (NumConfigurations == 0) from
        above prevents the allocation of the endpoint's transfer ring.
      
      - When the keyboard driver tries to use the endpoint, the ASSERT() blows
        up.
      
      The solution is to correct the emulation in QEMU, and to generate a
      transfer event whenever IOC is set in a TRB.
      
      The patch replaces
      
        !reported && (IOC || foo)    == !reported && IOC ||
                                        !reported && foo
      
      with
      
        IOC || (!reported && foo)    == IOC ||
                                        !reported && foo
      
      which only changes how
      
        reported && IOC
      
      is handled. (Namely, it now generates an event.)
      
      Tested with edk2 built for "qemu-system-aarch64 -M virt" (ie.
      "ArmVirtualizationQemu.dsc", aka "AAVMF"), and guest Linux.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      aa685789
  16. 26 2月, 2015 1 次提交
  17. 26 1月, 2015 1 次提交
  18. 11 11月, 2014 1 次提交
  19. 28 10月, 2014 1 次提交
  20. 15 10月, 2014 1 次提交
  21. 23 9月, 2014 1 次提交
  22. 10 9月, 2014 1 次提交
    • D
      xhci PCIe endpoint migration compatibility fix · e6043e92
      Dr. David Alan Gilbert 提交于
      Add back the PCIe config capabilities on XHCI cards in non-PCIe slots,
      but only for machine types before 2.1.
      
      This fixes a migration incompatibility in the XHCI PCI devices
      caused by:
         058fdcf5 - xhci: add endpoint cap on express bus only
      
      Note that in fixing it for compatibility with older QEMUs, it breaks
      compatibility with existing QEMU 2.1's on older machine types.
      
      The status before this patch was (if it used an XHCI adapter):
         machine type | source qemu
           any           pre-2.1     - FAIL
           any           2.1...      - PASS
      
      With this patch:
         machine type | source qemu
           any           pre-2.1    - PASS
           pre-2.1       2.1...     - FAIL
           2.1           2.1...     - PASS
      
      A test to trigger it is to add '-device nec-usb-xhci,id=xhci,addr=0x12'
      to the command line.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      e6043e92
  23. 29 8月, 2014 5 次提交
  24. 23 7月, 2014 1 次提交
    • L
      vmstate_xhci_event: fix unterminated field list · 3afca1d6
      Laszlo Ersek 提交于
      "vmstate_xhci_event" was introduced in commit 37352df3 ("xhci: add live
      migration support"), and first released in v1.6.0. The field list in this
      VMSD is not terminated with the VMSTATE_END_OF_LIST() macro.
      
      During normal use (ie. migration), the issue is practically invisible,
      because the "vmstate_xhci_event" object (with the unterminated field list)
      is only ever referenced -- via "vmstate_xhci_intr" -- if xhci_er_full()
      returns true, for the "ev_buffer" test. Since that field_exists() check
      (apparently) almost always returns false, we almost never traverse
      "vmstate_xhci_event" during migration, which hides the bug.
      
      However, Amit's vmstate checker forces recursion into this VMSD as well,
      and the lack of VMSTATE_END_OF_LIST() breaks the field list terminator
      check (field->name != NULL) in dump_vmstate_vmsd(). The result is
      undefined behavior, which in my case translates to infinite recursion
      (because the loop happens to overflow into "vmstate_xhci_intr", which then
      links back to "vmstate_xhci_event").
      
      Add the missing terminator.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: NAmit Shah <amit.shah@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      3afca1d6