1. 01 7月, 2019 3 次提交
    • M
      pcie: work around for racy guest init · 110c477c
      Michael S. Tsirkin 提交于
      During boot, linux guests tend to clear all bits in pcie slot status
      register which is used for hotplug.
      If they clear bits that weren't set this is racy and will lose events:
      not a big problem for manual hotplug on bare-metal, but a problem for us.
      
      For example, the following is broken ATM:
      
      /x86_64-softmmu/qemu-system-x86_64 -enable-kvm -S -machine q35  \
          -device pcie-root-port,id=pcie_root_port_0,slot=2,chassis=2,addr=0x2,bus=pcie.0 \
          -device virtio-balloon-pci,id=balloon,bus=pcie_root_port_0 \
          -monitor stdio disk.qcow2
      (qemu)device_del balloon
      (qemu)cont
      
      Balloon isn't deleted as it should.
      
      As a work-around, detect this attempt to clear slot status and revert
      status to what it was before the write.
      
      Note: in theory this can be detected as a duplicate button press
      which cancels the previous press. Does not seem to happen in
      practice as guests seem to only have this bug during init.
      
      Note2: the right thing to do is probably to fix Linux to
      read status before clearing it, and act on the bits that are set.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Tested-by: NIgor Mammedov <imammedo@redhat.com>
      110c477c
    • M
      pcie: check that slt ctrl changed before deleting · 2841ab43
      Michael S. Tsirkin 提交于
      During boot, linux would sometimes overwrites control of a powered off
      slot before powering it on. Unfortunately QEMU interprets that as a
      power off request and ejects the device.
      
      For example:
      
      /x86_64-softmmu/qemu-system-x86_64 -enable-kvm -S -machine q35  \
          -device pcie-root-port,id=pcie_root_port_0,slot=2,chassis=2,addr=0x2,bus=pcie.0 \
          -monitor stdio disk.qcow2
      (qemu)device_add virtio-balloon-pci,id=balloon,bus=pcie_root_port_0
      (qemu)cont
      
      Balloon is deleted during guest boot.
      
      To fix, save control beforehand and check that power
      or led state actually change before ejecting.
      
      Note: this is more a hack than a solution, ideally we'd
      find a better way to detect ejects, or move away
      from ejects completely and instead monitor whether
      it's safe to delete device due to e.g. its power state.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Tested-by: NIgor Mammedov <imammedo@redhat.com>
      2841ab43
    • M
      pcie: don't skip multi-mask events · 861dc735
      Michael S. Tsirkin 提交于
      If we are trying to set multiple bits at once, testing that just one of
      them is already set gives a false positive. As a result we won't
      interrupt guest if e.g. presence detection change and attention button
      press are both set. This happens with multi-function device removal.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      861dc735
  2. 12 6月, 2019 2 次提交
    • M
      Include qemu-common.h exactly where needed · a8d25326
      Markus Armbruster 提交于
      No header includes qemu-common.h after this commit, as prescribed by
      qemu-common.h's file comment.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-5-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
      block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
      target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
      target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
      target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
      target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
      net/tap-bsd.c fixed up]
      a8d25326
    • M
      Include qemu/module.h where needed, drop it from qemu-common.h · 0b8fa32f
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-4-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      hw/usb/dev-hub.c hw/misc/exynos4210_rng.c hw/misc/bcm2835_rng.c
      hw/misc/aspeed_scu.c hw/display/virtio-vga.c hw/arm/stm32f205_soc.c;
      ui/cocoa.m fixed up]
      0b8fa32f
  3. 06 6月, 2019 1 次提交
  4. 30 5月, 2019 2 次提交
    • D
      pci: Fold pci_get_bus_devfn() into its sole caller · 2ad778b8
      David Gibson 提交于
      The only remaining caller of pci_get_bus_devfn() is pci_nic_init_nofail(),
      itself an old compatibility function.  Fold the two together to avoid
      re-using the stale interface.
      
      While we're there replace the explicit fprintf()s with error_report().
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20190513061939.3464-6-david@gibson.dropbear.id.au>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      2ad778b8
    • D
      pcie: Simplify pci_adjust_config_limit() · 2f57db8a
      David Gibson 提交于
      Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
      pci_adjust_config_limit() has been used in the config space read and write
      paths to only permit access to extended config space on buses which permit
      it.  Specifically it prevents access on devices below a vanilla-PCI bus via
      some combination of bridges, even if both the host bridge and the device
      itself are PCI-E.
      
      It accomplishes this with a somewhat complex call up the chain of bridges
      to see if any of them prohibit extended config space access.  This is
      overly complex, since we can always know if the bus will support such
      access at the point it is constructed.
      
      This patch simplifies the test by using a flag in the PCIBus instance
      indicating whether extended configuration space is accessible.  It is
      false for vanilla PCI buses.  For PCI-E buses, it is true for root
      buses and equal to the parent bus's's capability otherwise.
      
      For the special case of sPAPR's paravirtualized PCI root bus, which
      acts mostly like vanilla PCI, but does allow extended config space
      access, we override the default value of the flag from the host bridge
      code.
      
      This should cause no behavioural change.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Message-Id: <20190513061939.3464-4-david@gibson.dropbear.id.au>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      2f57db8a
  5. 22 5月, 2019 1 次提交
  6. 21 5月, 2019 2 次提交
  7. 13 5月, 2019 1 次提交
  8. 26 4月, 2019 1 次提交
    • G
      spapr: Drop duplicate PCI swizzle code · e8ec4adf
      Greg Kurz 提交于
      LSI mapping in spapr currently open-codes standard PCI swizzling. It thus
      duplicates the code of pci_swizzle_map_irq_fn().
      
      Expose the swizzling formula so that it can be used with a slot number
      when building the device tree. Simply drop pci_spapr_map_irq() and call
      pci_swizzle_map_irq_fn() instead.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Message-Id: <155448184841.8446.13959787238854054119.stgit@bahia.lan>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      e8ec4adf
  9. 18 4月, 2019 1 次提交
  10. 09 4月, 2019 1 次提交
  11. 23 3月, 2019 1 次提交
  12. 18 3月, 2019 1 次提交
    • P
      kconfig: add CONFIG_MSI_NONBROKEN · ca9b7e29
      Paolo Bonzini 提交于
      Not all interrupt controllers have a working implementation of
      message-signalled interrupts; in some cases, the guest may expect
      MSI to work but it won't due to the buggy or lacking emulation.
      
      In QEMU this is represented by the "msi_nonbroken" variable.  This
      patch adds a new configuration symbol enabled whenever the binary
      contains an interrupt controller that will set "msi_nonbroken".  We
      can then use it to remove devices that cannot be possibly added
      to the machine, because they require MSI.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      ca9b7e29
  13. 13 3月, 2019 1 次提交
  14. 08 3月, 2019 3 次提交
  15. 06 3月, 2019 1 次提交
    • D
      qdev: Let the hotplug_handler_unplug() caller delete the device · 07578b0a
      David Hildenbrand 提交于
      When unplugging a device, at one point the device will be destroyed
      via object_unparent(). This will, one the one hand, unrealize the
      removed device hierarchy, and on the other hand, destroy/free the
      device hierarchy.
      
      When chaining hotplug handlers, we want to overwrite a bus hotplug
      handler by the machine hotplug handler, to be able to perform
      some part of the plug/unplug and to forward the calls to the bus hotplug
      handler.
      
      For now, the bus hotplug handler would trigger an object_unparent(), not
      allowing us to perform some unplug action on a device after we forwarded
      the call to the bus hotplug handler. The device would be gone at that
      point.
      
      machine_unplug_handler(dev)
          /* eventually do unplug stuff */
          bus_unplug_handler(dev)
          /* dev is gone, we can't do more unplug stuff */
      
      So move the object_unparent() to the original caller of the unplug. For
      now, keep the unrealize() at the original places of the
      object_unparent(). For implicitly chained hotplug handlers (e.g. pc
      code calling acpi hotplug handlers), the object_unparent() has to be
      done by the outermost caller. So when calling hotplug_handler_unplug()
      from inside an unplug handler, nothing is to be done.
      
      hotplug_handler_unplug(dev) -> calls machine_unplug_handler()
          machine_unplug_handler(dev) {
              /* eventually do unplug stuff */
              bus_unplug_handler(dev) -> calls unrealize(dev)
              /* we can do more unplug stuff but device already unrealized */
          }
      object_unparent(dev)
      
      In the long run, every unplug action should be factored out of the
      unrealize() function into the unplug handler (especially for PCI). Then
      we can get rid of the additonal unrealize() calls and object_unparent()
      will properly unrealize the device hierarchy after the device has been
      unplugged.
      
      hotplug_handler_unplug(dev) -> calls machine_unplug_handler()
          machine_unplug_handler(dev) {
              /* eventually do unplug stuff */
              bus_unplug_handler(dev) -> only unplugs, does not unrealize
              /* we can do more unplug stuff */
          }
      object_unparent(dev) -> will unrealize
      
      The original approach was suggested by Igor Mammedov for the PCI
      part, but I extended it to all hotplug handlers. I consider this one
      step into the right direction.
      
      To summarize:
      - object_unparent() on synchronous unplugs is done by common code
      -- "Caller of hotplug_handler_unplug"
      - object_unparent() on asynchronous unplugs ("unplug requests") has to
        be done manually
      -- "Caller of hotplug_handler_unplug"
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Acked-by: NCornelia Huck <cohuck@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20190228122849.4296-2-david@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      07578b0a
  16. 22 2月, 2019 1 次提交
    • A
      pci: Sanity test minimum downstream LNKSTA · 88c86919
      Alex Williamson 提交于
      The entire link status register for SR-IOV VFs is defined as RsvdZ,
      reads simply return zero.  Usually this is nothing more than lspci
      reporting inconsequentially broken values:
      
          LnkSta: Speed unknown, Width x0, ...
      
      However, now that we're using the downstream endpoint link status to
      fill in the value at the parent downstream port, invalid values become
      a problem.  In particular, the PCIe hotplug driver in Linux looks for
      a valid negotiated link width and will fail to enumerate hot-added
      downstream endpoints without non-zero value here, ex:
      
          pciehp 0000:00:02.0:pcie004: Slot(0): Attention button pressed
          pciehp 0000:00:02.0:pcie004: Slot(0) Powering on due to button press
          pciehp 0000:00:02.0:pcie004: Slot(0): Card present
          pciehp 0000:00:02.0:pcie004: Slot(0): Link Up
          pciehp 0000:00:02.0:pcie004: link training error: status 0x2000
          pciehp 0000:00:02.0:pcie004: Failed to check link status
      
      Resolve by using minimum width and speed values for the downstream
      port link status when the endpoint fails to provide valid values.
      Long term, we may want to implement emulation in the vfio-pci host
      driver to suppliment this field with the PF value as the SR-IOV spec
      seems to allow, but the solution here is compatible should that be
      implemented later.
      
      Fixes: 727b4866 ("pci: Sync PCIe downstream port LNKSTA on read")
      Reported-by: NJens Freimann <jfreimann@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Message-Id: <155060310248.19547.14979269067689441201.stgit@gimli.home>
      Tested-by: NJens Freimann <jfreimann@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      88c86919
  17. 17 2月, 2019 1 次提交
  18. 05 2月, 2019 1 次提交
  19. 15 1月, 2019 2 次提交
  20. 11 1月, 2019 1 次提交
    • P
      avoid TABs in files that only contain a few · 7d37435b
      Paolo Bonzini 提交于
      Most files that have TABs only contain a handful of them.  Change
      them to spaces so that we don't confuse people.
      
      disas, standard-headers, linux-headers and libdecnumber are imported
      from other projects and probably should be exempted from the check.
      Outside those, after this patch the following files still contain both
      8-space and TAB sequences at the beginning of the line.  Many of them
      have a majority of TABs, or were initially committed with all tabs.
      
          bsd-user/i386/target_syscall.h
          bsd-user/x86_64/target_syscall.h
          crypto/aes.c
          hw/audio/fmopl.c
          hw/audio/fmopl.h
          hw/block/tc58128.c
          hw/display/cirrus_vga.c
          hw/display/xenfb.c
          hw/dma/etraxfs_dma.c
          hw/intc/sh_intc.c
          hw/misc/mst_fpga.c
          hw/net/pcnet.c
          hw/sh4/sh7750.c
          hw/timer/m48t59.c
          hw/timer/sh_timer.c
          include/crypto/aes.h
          include/disas/bfd.h
          include/hw/sh4/sh.h
          libdecnumber/decNumber.c
          linux-headers/asm-generic/unistd.h
          linux-headers/linux/kvm.h
          linux-user/alpha/target_syscall.h
          linux-user/arm/nwfpe/double_cpdo.c
          linux-user/arm/nwfpe/fpa11_cpdt.c
          linux-user/arm/nwfpe/fpa11_cprt.c
          linux-user/arm/nwfpe/fpa11.h
          linux-user/flat.h
          linux-user/flatload.c
          linux-user/i386/target_syscall.h
          linux-user/ppc/target_syscall.h
          linux-user/sparc/target_syscall.h
          linux-user/syscall.c
          linux-user/syscall_defs.h
          linux-user/x86_64/target_syscall.h
          slirp/cksum.c
          slirp/if.c
          slirp/ip.h
          slirp/ip_icmp.c
          slirp/ip_icmp.h
          slirp/ip_input.c
          slirp/ip_output.c
          slirp/mbuf.c
          slirp/misc.c
          slirp/sbuf.c
          slirp/socket.c
          slirp/socket.h
          slirp/tcp_input.c
          slirp/tcpip.h
          slirp/tcp_output.c
          slirp/tcp_subr.c
          slirp/tcp_timer.c
          slirp/tftp.c
          slirp/udp.c
          slirp/udp.h
          target/cris/cpu.h
          target/cris/mmu.c
          target/cris/op_helper.c
          target/sh4/helper.c
          target/sh4/op_helper.c
          target/sh4/translate.c
          tcg/sparc/tcg-target.inc.c
          tests/tcg/cris/check_addo.c
          tests/tcg/cris/check_moveq.c
          tests/tcg/cris/check_swap.c
          tests/tcg/multiarch/test-mmap.c
          ui/vnc-enc-hextile-template.h
          ui/vnc-enc-zywrle.h
          util/envlist.c
          util/readline.c
      
      The following have only TABs:
      
          bsd-user/i386/target_signal.h
          bsd-user/sparc64/target_signal.h
          bsd-user/sparc64/target_syscall.h
          bsd-user/sparc/target_signal.h
          bsd-user/sparc/target_syscall.h
          bsd-user/x86_64/target_signal.h
          crypto/desrfb.c
          hw/audio/intel-hda-defs.h
          hw/core/uboot_image.h
          hw/sh4/sh7750_regnames.c
          hw/sh4/sh7750_regs.h
          include/hw/cris/etraxfs_dma.h
          linux-user/alpha/termbits.h
          linux-user/arm/nwfpe/fpopcode.h
          linux-user/arm/nwfpe/fpsr.h
          linux-user/arm/syscall_nr.h
          linux-user/arm/target_signal.h
          linux-user/cris/target_signal.h
          linux-user/i386/target_signal.h
          linux-user/linux_loop.h
          linux-user/m68k/target_signal.h
          linux-user/microblaze/target_signal.h
          linux-user/mips64/target_signal.h
          linux-user/mips/target_signal.h
          linux-user/mips/target_syscall.h
          linux-user/mips/termbits.h
          linux-user/ppc/target_signal.h
          linux-user/sh4/target_signal.h
          linux-user/sh4/termbits.h
          linux-user/sparc64/target_syscall.h
          linux-user/sparc/target_signal.h
          linux-user/x86_64/target_signal.h
          linux-user/x86_64/termbits.h
          pc-bios/optionrom/optionrom.h
          slirp/mbuf.h
          slirp/misc.h
          slirp/sbuf.h
          slirp/tcp.h
          slirp/tcp_timer.h
          slirp/tcp_var.h
          target/i386/svm.h
          target/sparc/asi.h
          target/xtensa/core-dc232b/xtensa-modules.inc.c
          target/xtensa/core-dc233c/xtensa-modules.inc.c
          target/xtensa/core-de212/core-isa.h
          target/xtensa/core-de212/xtensa-modules.inc.c
          target/xtensa/core-fsf/xtensa-modules.inc.c
          target/xtensa/core-sample_controller/core-isa.h
          target/xtensa/core-sample_controller/xtensa-modules.inc.c
          target/xtensa/core-test_kc705_be/core-isa.h
          target/xtensa/core-test_kc705_be/xtensa-modules.inc.c
          tests/tcg/cris/check_abs.c
          tests/tcg/cris/check_addc.c
          tests/tcg/cris/check_addcm.c
          tests/tcg/cris/check_addoq.c
          tests/tcg/cris/check_bound.c
          tests/tcg/cris/check_ftag.c
          tests/tcg/cris/check_int64.c
          tests/tcg/cris/check_lz.c
          tests/tcg/cris/check_openpf5.c
          tests/tcg/cris/check_sigalrm.c
          tests/tcg/cris/crisutils.h
          tests/tcg/cris/sys.c
          tests/tcg/i386/test-i386-ssse3.c
          ui/vgafont.h
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20181213223737.11793-3-pbonzini@redhat.com>
      Reviewed-by: NAleksandar Markovic <amarkovic@wavecomp.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NWainer dos Santos Moschetta <wainersm@redhat.com>
      Acked-by: NRichard Henderson <richard.henderson@linaro.org>
      Acked-by: NEric Blake <eblake@redhat.com>
      Acked-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NStefan Markovic <smarkovic@wavecomp.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7d37435b
  21. 09 1月, 2019 1 次提交
    • M
      pci: allow cleanup/unregistration of PCI root buses · c13ee169
      Michael Roth 提交于
      This adds cleanup counterparts to pci_register_root_bus(),
      pci_root_bus_new(), and pci_bus_irqs().
      
      These cleanup routines are needed in the case of hotpluggable
      PCIHostBridge implementations. Currently we can rely on the
      object_unparent()'ing of the PCIHostState recursively unparenting
      and cleaning up it's child buses, but we need explicit calls
      to also:
      
        1) remove the PCIHostState from pci_host_bridges global list.
           otherwise, we risk accessing freed memory when we access
           the list later
        2) clean up memory allocated in pci_bus_irqs()
      
      Both are handled outside the context of any particular bus or
      host bridge's init/realize functions, making it difficult to
      avoid the need for explicit cleanup functions without remodeling
      how PCIHostBridges are created. So keep it simple and just add
      them for now.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      c13ee169
  22. 21 12月, 2018 5 次提交
  23. 20 12月, 2018 5 次提交
    • A
      pcie: Fill PCIESlot link fields to support higher speeds and widths · 3d67447f
      Alex Williamson 提交于
      Make use of the PCIESlot speed and width fields to update link
      information beyond those configured in pcie_cap_v1_fill().  This is
      only called for devices supporting a version 2 capability and
      automatically skips any non-PCIESlot devices.  Only devices with
      increased link values generate any visible config space differences.
      
      Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Tested-by: NGeoffrey McRae <geoff@hostfission.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      3d67447f
    • A
      pci: Sync PCIe downstream port LNKSTA on read · 727b4866
      Alex Williamson 提交于
      The PCIe link speed and width between a downstream device and its
      upstream port is negotiated on real hardware and susceptible to
      dynamic changes due to signal issues and power management.  In the
      emulated device case there is no real hardware link, but we still
      might wish to have some consistency between endpoint and downstream
      port via a virtual negotiation.  There is of course a real link for
      assigned devices and this same virtual negotiation allows the
      downstream port to match the endpoint, synchronizing on every read
      to support underlying physical hardware dynamically adjusting the
      link.
      
      This negotiation is intentionally unidirectional for compatibility.
      If the endpoint exceeds the capabilities of the downstream port or
      there is no endpoint device, the downstream port reports negotiation
      to its maximum speed and width, matching the previous case where
      negotiation was absent.  De-tuning the endpoint to match a virtual
      link doesn't seem to benefit anyone and is a condition we've thus
      far reported without functional issues.
      
      Note that PCI_EXP_LNKSTA is already ignored for migration
      compatibility via pcie_cap_v1_fill().
      
      Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Tested-by: NGeoffrey McRae <geoff@hostfission.com>
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      727b4866
    • A
      pcie: Create enums for link speed and width · d96a0ac7
      Alex Williamson 提交于
      In preparation for reporting higher virtual link speeds and widths,
      create enums and macros to help us manage them.
      
      Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Tested-by: NGeoffrey McRae <geoff@hostfission.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      d96a0ac7
    • M
      hw/pci-bridge: Fix invalid free() · e7176cdb
      Matthias Weckbecker 提交于
      When loadvm'ing a *running* snapshot qemu crashes due to an invalid
      free. It's fortunately caught early by glibc heap memory corruption
      protection and qemu gets killed with SIGABRT.
      
      Steps to reproduce:
      
      1) Create VM (e.g w/ virsh define)
      2) Start the VM and take a snapshot while it's running and having a
         PCI bridge attached
      3) Destroy the VM and revert the running snapshot.
      
      This commit fixes the issue.
      Signed-off-by: NMatthias Weckbecker <matthias@weckbecker.name>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      e7176cdb
    • Z
      pcie: set link state inactive/active after hot unplug/plug · 2f2b18f6
      Zheng Xiang 提交于
      When VM boots from the latest version of linux kernel, after
      hot-unpluging virtio-blk disks which are hotplugged into
      pcie-root-port, the VM's dmesg log shows:
      
      [  151.046242] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0001 from Slot Status
      [  151.046365] pciehp 0000:00:05.0:pcie004: Slot(0-3): Attention button pressed
      [  151.046369] pciehp 0000:00:05.0:pcie004: Slot(0-3): Powering off due to button press
      [  151.046420] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  151.046425] pciehp 0000:00:05.0:pcie004: pciehp_green_led_blink: SLOTCTRL a8 write cmd 200
      [  151.046464] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  151.046468] pciehp 0000:00:05.0:pcie004: pciehp_set_attention_status: SLOTCTRL a8 write cmd c0
      [  156.163421] pciehp 0000:00:05.0:pcie004: pciehp_get_power_status: SLOTCTRL a8 value read 2f1
      [  156.163427] pciehp 0000:00:05.0:pcie004: pciehp_unconfigure_device: domain:bus:dev = 0000:06:00
      [  156.198736] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  156.198772] pciehp 0000:00:05.0:pcie004: pciehp_power_off_slot: SLOTCTRL a8 write cmd 400
      [  157.224124] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0018 from Slot Status
      [  157.224194] pciehp 0000:00:05.0:pcie004: pciehp_green_led_off: SLOTCTRL a8 write cmd 300
      [  157.224220] pciehp 0000:00:05.0:pcie004: pciehp_check_link_active: lnk_status = 2011
      [  157.224223] pciehp 0000:00:05.0:pcie004: Slot(0-3): Link Up
      [  157.224233] pciehp 0000:00:05.0:pcie004: pciehp_get_power_status: SLOTCTRL a8 value read 7f1
      [  157.224281] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  157.224285] pciehp 0000:00:05.0:pcie004: pciehp_power_on_slot: SLOTCTRL a8 write cmd 0
      [  157.224300] pciehp 0000:00:05.0:pcie004: __pciehp_link_set: lnk_ctrl = 0
      [  157.224336] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  157.224339] pciehp 0000:00:05.0:pcie004: pciehp_green_led_blink: SLOTCTRL a8 write cmd 200
      [  159.739294] pci 0000:06:00.0 id reading try 50 times with interval 20 ms to get ffffffff
      [  159.739315] pciehp 0000:00:05.0:pcie004: pciehp_check_link_status: lnk_status = 2011
      [  159.739318] pciehp 0000:00:05.0:pcie004: Failed to check link status
      [  159.739371] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  159.739394] pciehp 0000:00:05.0:pcie004: pciehp_power_off_slot: SLOTCTRL a8 write cmd 400
      [  160.771426] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  160.771452] pciehp 0000:00:05.0:pcie004: pciehp_green_led_off: SLOTCTRL a8 write cmd 300
      [  160.771495] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  160.771499] pciehp 0000:00:05.0:pcie004: pciehp_set_attention_status: SLOTCTRL a8 write cmd 40
      [  160.771535] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
      [  160.771539] pciehp 0000:00:05.0:pcie004: pciehp_green_led_off: SLOTCTRL a8 write cmd 300
      
      After analyzing the log information, it seems that qemu doesn't
      change the Link Status from active to inactive after hot-unplug.
      This results in the abnormal log after the linux kernel commit
      d331710ea78fea merged.
      
      Furthermore, If I hotplug the same virtio-blk disk after hot-unplug,
      the virtio-blk would turn on and then back off.
      
      So this patch set the Link Status inactive after hot-unplug and
      active after hot-plug.
      Signed-off-by: NZheng Xiang <zhengxiang9@huawei.com>
      Signed-off-by: NZheng Xiang <xiang.zheng@linaro.org>
      Cc: Wang Haibin <wanghaibin.wang@huawei.com>
      Cc: qemu-stable@nongnu.org
      Reviewed-by: NMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      2f2b18f6
  24. 14 12月, 2018 1 次提交