1. 16 3月, 2017 1 次提交
  2. 01 3月, 2017 1 次提交
    • G
      spapr/pci: populate PCI DT in reverse order · a8eeafda
      Greg Kurz 提交于
      Since commit 1d2d9742 "spapr_pci: enumerate and add PCI device tree", QEMU
      populates the PCI device tree in the opposite order compared to SLOF.
      
      Before 1d2d9742:
      
      Populating /pci@800000020000000
                           00 0000 (D) : 1af4 1000    virtio [ net ]
                           00 0800 (D) : 1af4 1001    virtio [ block ]
                           00 1000 (D) : 1af4 1009    virtio [ network ]
      Populating /pci@800000020000000/unknown-legacy-device@2
      
      7e5294b8 :  /pci@800000020000000
      7e52b998 :  |-- ethernet@0
      7e52c0c8 :  |-- scsi@1
      7e52c7e8 :  +-- unknown-legacy-device@2 ok
      
      Since 1d2d9742:
      
      Populating /pci@800000020000000
                           00 1000 (D) : 1af4 1009    virtio [ network ]
      Populating /pci@800000020000000/unknown-legacy-device@2
                           00 0800 (D) : 1af4 1001    virtio [ block ]
                           00 0000 (D) : 1af4 1000    virtio [ net ]
      
      7e5e8118 :  /pci@800000020000000
      7e5ea6a0 :  |-- unknown-legacy-device@2
      7e5eadb8 :  |-- scsi@1
      7e5eb4d8 :  +-- ethernet@0 ok
      
      This behaviour change is not actually a bug since no assumptions should be
      made on DT ordering. But it has no real justification either, other than
      being the consequence of the way fdt_add_subnode() inserts new elements
      to the front of the FDT rather than adding them to the tail.
      
      This patch reverts to the historical SLOF ordering by walking PCI devices
      in reverse order. This reconciles pseries with x86 machine types behavior.
      It is expected to make things easier when porting existing applications to
      power.
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Tested-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NNikunj A Dadhania <nikunj@linux.vnet.ibm.com>
      (slight update to the changelog)
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      a8eeafda
  3. 01 2月, 2017 1 次提交
  4. 25 1月, 2017 2 次提交
  5. 20 1月, 2017 1 次提交
    • A
      hw/pci: use-after-free in pci_nic_init_nofail when nic device fails to initialize · a023b7ac
      Alex Kompel 提交于
      object_property_set_bool(OBJECT(dev), true, "realized", &err) in
      pci_nic_init_nofail may release the object if device fails to
      initialize which leads to use-after-free in error handling block.
      qdev_init_nofail does the same thing while holding the reference.
      
      (gdb) run -net nic
      qemu-system-x86_64: failed to find romfile "efi-e1000.rom"
      
      Program received signal SIGSEGV, Segmentation fault.
      object_unparent (obj=0x7fffe96a0010) at qom/object.c:440
      440     in qom/object.c
      (gdb) bt
      <nd_table>, rootbus=0x5555567ed990, default_model=<optimized out>,
      default_devaddr=<optimized out>) at hw/pci/pci.c:1812
      pci_bus=0x5555567ed990) at hw/i386/pc.c:1634
      pci_type=0x555555c1a523 "i440FX", host_type=0x555555ba564e
      "i440FX-pcihost") at hw/i386/pc_piix.c:241
      out>, envp=<optimized out>) at vl.c:4481
      Signed-off-by: NAlex Kompel <barbos@gmail.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      a023b7ac
  6. 16 12月, 2016 1 次提交
  7. 29 7月, 2016 1 次提交
    • M
      pcie: fix link active status bit migration · 6b449540
      Michael S. Tsirkin 提交于
      We changed link status register in pci express endpoint capability
      over time. Specifically,
      
      commit b2101eae ("pcie: Set the "link
      active" in the link status register") set data link layer link active
      bit in this register without adding compatibility to old machine types.
      
      When migrating from qemu 2.3 and older this affects xhci devices which
      under machine type 2.0 and older have a pci express endpoint capability
      even if they are on a pci bus.
      
      Add compatibility flags to make this bit value match what it was under
      2.3.
      
      Additionally, to avoid breaking migration from qemu 2.3 and up,
      suppress checking link status during migration: this seems sane
      since hardware can change link status at any time.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1352860Reported-by: NGerd Hoffmann <kraxel@redhat.com>
      Fixes: b2101eae
          ("pcie: Set the "link active" in the link status register")
      Cc: qemu-stable@nongnu.org
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      6b449540
  8. 22 7月, 2016 1 次提交
  9. 04 7月, 2016 3 次提交
  10. 17 6月, 2016 2 次提交
  11. 23 3月, 2016 1 次提交
  12. 25 2月, 2016 2 次提交
  13. 07 2月, 2016 1 次提交
  14. 29 1月, 2016 1 次提交
    • P
      pci: Clean up includes · 97d5408f
      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-23-git-send-email-peter.maydell@linaro.org
      97d5408f
  15. 29 10月, 2015 1 次提交
  16. 18 9月, 2015 1 次提交
    • M
      Fix bad error handling after memory_region_init_ram() · f8ed85ac
      Markus Armbruster 提交于
      Symptom:
      
          $ qemu-system-x86_64 -m 10000000
          Unexpected error in ram_block_add() at /work/armbru/qemu/exec.c:1456:
          upstream-qemu: cannot set up guest memory 'pc.ram': Cannot allocate memory
          Aborted (core dumped)
      
      Root cause: commit ef701d7b screwed up handling of out-of-memory
      conditions.  Before the commit, we report the error and exit(1), in
      one place, ram_block_add().  The commit lifts the error handling up
      the call chain some, to three places.  Fine.  Except it uses
      &error_abort in these places, changing the behavior from exit(1) to
      abort(), and thus undoing the work of commit 39228250 "exec: Don't
      abort when we can't allocate guest memory".
      
      The three places are:
      
      * memory_region_init_ram()
      
        Commit 49946538 (right after commit ef701d7b) lifted the error
        handling further, through memory_region_init_ram(), multiplying the
        incorrect use of &error_abort.  Later on, imitation of existing
        (bad) code may have created more.
      
      * memory_region_init_ram_ptr()
      
        The &error_abort is still there.
      
      * memory_region_init_rom_device()
      
        Doesn't need fixing, because commit 33e0eb52 (soon after commit
        ef701d7b) lifted the error handling further, and in the process
        changed it from &error_abort to passing it up the call chain.
        Correct, because the callers are realize() methods.
      
      Fix the error handling after memory_region_init_ram() with a
      Coccinelle semantic patch:
      
          @r@
          expression mr, owner, name, size, err;
          position p;
          @@
                  memory_region_init_ram(mr, owner, name, size,
          (
          -                              &error_abort
          +                              &error_fatal
          |
                                         err@p
          )
                                        );
          @script:python@
              p << r.p;
          @@
          print "%s:%s:%s" % (p[0].file, p[0].line, p[0].column)
      
      When the last argument is &error_abort, it gets replaced by
      &error_fatal.  This is the fix.
      
      If the last argument is anything else, its position is reported.  This
      lets us check the fix is complete.  Four positions get reported:
      
      * ram_backend_memory_alloc()
      
        Error is passed up the call chain, ultimately through
        user_creatable_complete().  As far as I can tell, it's callers all
        handle the error sanely.
      
      * fsl_imx25_realize(), fsl_imx31_realize(), dp8393x_realize()
      
        DeviceClass.realize() methods, errors handled sanely further up the
        call chain.
      
      We're good.  Test case again behaves:
      
          $ qemu-system-x86_64 -m 10000000
          qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory
          [Exit 1 ]
      
      The next commits will repair the rest of commit ef701d7b's damage.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1441983105-26376-3-git-send-email-armbru@redhat.com>
      Reviewed-by: NPeter Crosthwaite <crosthwaite.peter@gmail.com>
      f8ed85ac
  17. 10 9月, 2015 2 次提交
    • L
      hw/pci: fix pci_update_mappings() trace events · 0f288f85
      Laszlo Ersek 提交于
      The current trace prototypes and (matching) trace calls lead to
      "unorthodox" PCI BDF notation in at least the stderr trace backend. For
      example, the four BARs of a QXL video card at 00:01.0 (bus 0, slot 1,
      function 0) are traced like this (PID and timestamps removed):
      
        pci_update_mappings_add d=0x7f14a73bf890 00:00.1 0,0x84000000+0x4000000
        pci_update_mappings_add d=0x7f14a73bf890 00:00.1 1,0x80000000+0x4000000
        pci_update_mappings_add d=0x7f14a73bf890 00:00.1 2,0x88200000+0x2000
        pci_update_mappings_add d=0x7f14a73bf890 00:00.1 3,0xd060+0x20
      
      The slot and function values are in reverse order.
      
      Stick with the conventional BDF notation.
      
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Don Koch <dkoch@verizon.com>
      Cc: qemu-trivial@nongnu.org
      Fixes: 7828d750Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      0f288f85
    • B
      pci: Fix pci_device_iommu_address_space() bus propagation · 5af2ae23
      Benjamin Herrenschmidt 提交于
      he current code walks up the bus tree for an iommu, however it passes
      to the iommu_fn() callback the bus/devfn of the immediate child of
      the level where the callback was found, rather than the original
      bus/devfn where the search started from.
      
      This prevents iommu's like POWER8 (and in fact also Q35) to properly
      provide an address space for a subset of devices that aren't immediate
      children of the iommu.
      
      PCIe carries the originator bdfn acccross to the iommu on all DMA
      transactions, so we must be able to properly identify devices at all
      levels.
      
      This changes the function pci_device_iommu_address_space() to pass
      the original pointers to the iommu_fn() callback instead.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      
      5af2ae23
  18. 07 9月, 2015 1 次提交
    • P
      hw/pci: Use pow2ceil() rather than hand-calculation · 9bff5d81
      Peter Maydell 提交于
      A couple of places in hw/pci use an inline calculation to round a
      size up to the next largest power of 2. We have a utility routine
      for this, so use it.
      
      (The behaviour of the old code is different if the size value
      is 0 -- it would leave it as 0 rather than rounding up to 1,
      but in both cases we know the size can't be 0.
      In the case where the size value had bit 31 set, the old code
      would invoke undefined behaviour; the new code will give a
      result of 0. Presumably that could never happen either.)
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Message-id: 1437741192-20955-2-git-send-email-peter.maydell@linaro.org
      9bff5d81
  19. 13 8月, 2015 1 次提交
  20. 20 7月, 2015 1 次提交
  21. 24 6月, 2015 1 次提交
  22. 23 6月, 2015 1 次提交
  23. 12 6月, 2015 1 次提交
  24. 04 6月, 2015 6 次提交
  25. 06 5月, 2015 1 次提交
    • E
      qapi: Drop inline nested structs in query-pci · 9fa02cd1
      Eric Blake 提交于
      A future patch will be using a 'name':{dictionary} entry in the
      QAPI schema to specify a default value for an optional argument
      (see previous commit message for more details why); but existing
      use of inline nested structs conflicts with that goal. This patch
      fixes one of only two commands relying on nested types, by
      breaking the nesting into an explicit type; it means that the
      type is now boxed instead of unboxed in C code, but the QMP wire
      format is unaffected by this change.
      
      Prefer the safer g_new0() while making the conversion, and reduce
      some long lines.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9fa02cd1
  26. 28 4月, 2015 1 次提交
  27. 13 4月, 2015 1 次提交
    • T
      pci: Fix crash with illegal "-net nic, model=xxx" option · 4d0ecde4
      Thomas Huth 提交于
      Current QEMU crashes when specifying an illegal model with the
      "-net nic,model=xxx" option, e.g.:
      
       $ qemu-system-x86_64 -net nic,model=n/a
       qemu-system-x86_64: Unsupported NIC model: n/a
      
       Program received signal SIGSEGV, Segmentation fault.
      
      The gdb backtrace looks like this:
      
      0x0000555555965fe0 in error_get_pretty (err=0x0) at util/error.c:152
      152	    return err->msg;
      (gdb) bt
       0  0x0000555555965fe0 in error_get_pretty (err=0x0) at util/error.c:152
       1  0x0000555555965ffd in error_report_err (err=0x0) at util/error.c:157
       2  0x0000555555809c90 in pci_nic_init_nofail (nd=0x555555e49860 <nd_table>, rootbus=0x5555564409b0,
          default_model=0x55555598c37b "e1000", default_devaddr=0x0) at hw/pci/pci.c:1663
       3  0x0000555555691e42 in pc_nic_init (isa_bus=0x555556f71900, pci_bus=0x5555564409b0)
          at hw/i386/pc.c:1506
       4  0x000055555569396b in pc_init1 (machine=0x5555562abbf0, pci_enabled=1, kvmclock_enabled=1)
          at hw/i386/pc_piix.c:248
       5  0x0000555555693d27 in pc_init_pci (machine=0x5555562abbf0) at hw/i386/pc_piix.c:310
       6  0x000055555572ddf5 in main (argc=3, argv=0x7fffffffe018, envp=0x7fffffffe038) at vl.c:4226
      
      The problem is that pci_nic_init_nofail() does not check whether the err
      parameter from pci_nic_init has been set up and thus passes a NULL pointer
      to error_report_err(). Fix it by correctly checking the err parameter.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NJason Wang <jasowang@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      4d0ecde4
  28. 12 3月, 2015 1 次提交
  29. 01 3月, 2015 1 次提交