1. 28 10月, 2016 40 次提交
    • P
      Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.8-20161028' into staging · 66a77ea6
      Peter Maydell 提交于
      ppc patch queue 2016-10-28
      
      This pull request supersedes and extends the one from 2016-10-26
      (which had a build bug).
      
      Highlights:
        * SLOF (pseries guest firmware) update
        * Enable a number of extra testcases on ppc / pseries
        * Added the 'powernv' machine type
          - Almost enough to be minimally usable
          - But still missing necessary interrupt controller updates
        * Cleanup and consolidation of NVRAM handling on several platforms
          with related firmware
        * Substantial cleanup to device tree construction
        * Some more POWER9 instruction emulation
        * Cleanup to handling of pseries option vectors and CAS reboot
          handling (host/guest feature negotiation mechanism)
        * Significant cleanups to handling of PCI devices in test cases
        * New hotplug event infrastructure
        * Memory hot unplug support for pseries
        * Several bug fixes
      
      The NVRAM cleanup affects some Sun sparc platforms as well as ppc
      ones, but have been tested by the sparc maintainer (Mark Cave-Ayland).
      
      The test additions also include substantial general changes to the
      test framework that aren't strictly ppc related.  They don't seem to
      break tests on other platforms, they're for the benefit of enabling
      tests on ppc and there isn't a specific maintainer for them, so
      they're included in this tree.
      
      # gpg: Signature made Fri 28 Oct 2016 02:37:19 BST
      # gpg:                using RSA key 0x6C38CACA20D9B392
      # gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>"
      # gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>"
      # gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>"
      # gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>"
      # Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392
      
      * remotes/dgibson/tags/ppc-for-2.8-20161028: (73 commits)
        ppc: allow certain HV interrupts to be delivered to guests
        spapr: Memory hot-unplug support
        spapr: use count+index for memory hotplug
        spapr: Add DRC count indexed hotplug identifier type
        spapr: add hotplug interrupt machine options
        spapr_events: add support for dedicated hotplug event source
        spapr: update spapr hotplug documentation
        target-ppc: Add xvcmpnesp, xvcmpnedp instructions
        target-ppc: add xscmp[eq,gt,ge,ne]dp instructions
        tests: Add pseries machine to the prom-env-test, too
        spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter
        libqos: Change PCI accessors to take opaque BAR handle
        tests: Don't assume structure of PCI IO base in ahci-test
        tests: Use qpci_mem{read,write} in ivshmem-test
        libqos: Add 64-bit PCI IO accessors
        tests: Clean up IO handling in ide-test
        libqos: Implement mmio accessors in terms of mem{read,write}
        libqos: Add streaming accessors for PCI MMIO
        tests: Adjust tco-test to use qpci_legacy_iomap()
        libqos: Better handling of PCI legacy IO
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      66a77ea6
    • P
      Merge remote-tracking branch 'remotes/berrange/tags/pull-qio-2016-10-27-1' into staging · 01b601f0
      Peter Maydell 提交于
      Merge qio 2016/10/27 v1
      
      # gpg: Signature made Thu 27 Oct 2016 13:54:03 BST
      # gpg:                using RSA key 0xBE86EBB415104FDF
      # gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
      # gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"
      # Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF
      
      * remotes/berrange/tags/pull-qio-2016-10-27-1:
        main: set names for main loop sources created
        vnc: set name for all I/O channels created
        migration: set name for all I/O channels created
        char: set name for all I/O channels created
        nbd: set name for all I/O channels created
        io: add ability to set a name for IO channels
        io: Add a QIOChannelSocket cleanup test
        io: set LISTEN flag explicitly for listen sockets
        io: Introduce a qio_channel_set_feature() helper
        io: Use qio_channel_has_feature() where applicable
        io: Fix double shift usages on QIOChannel features
      
      Conflicts:
      	qemu-char.c
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      01b601f0
    • P
      Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging · fd209e4a
      Peter Maydell 提交于
      # gpg: Signature made Thu 27 Oct 2016 22:15:57 BST
      # gpg:                using RSA key 0x7DEF8106AAFC390E
      # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"
      # Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
      #      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E
      
      * remotes/jnsnow/tags/ide-pull-request:
        qemu-iotests: Test creating floppy drives
        fdc: Move qdev properties to FloppyDrive
        fdc: Add a floppy drive qdev
        fdc: Add a floppy qbus
        macio: switch over to new byte-aligned DMA helpers
        dma-helpers: explicitly pass alignment into DMA helpers
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      fd209e4a
    • P
      Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging · 9879b758
      Peter Maydell 提交于
      Block layer patches
      
      # gpg: Signature made Thu 27 Oct 2016 18:15:47 BST
      # gpg:                using RSA key 0x7F09B272C88F2FD6
      # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
      # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6
      
      * remotes/kevin/tags/for-upstream: (23 commits)
        iotests: Add test for NBD's blockdev-add interface
        iotests: Add assert_json_filename_equal() method
        socket_scm_helper: Accept fd directly
        iotests.py: Allow concurrent qemu instances
        iotests.py: Add qemu_nbd function
        qapi: Allow blockdev-add for NBD
        block/nbd: Use SocketAddress options
        block/nbd: Accept SocketAddress
        block/nbd: Add nbd_has_filename_options_conflict()
        block/nbd: Use qdict_put()
        block/nbd: Default port in nbd_refresh_filename()
        block/nbd: Reject port parameter without host
        block/nbd: Drop trailing "." in error messages
        qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX
        block: Remove bdrv_aio_ioctl()
        raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl
        block: Introduce .bdrv_co_ioctl() driver callback
        block: Remove bdrv_ioctl()
        raw-posix: Don't use bdrv_ioctl()
        block: Use blk_co_ioctl() for all BB level ioctls
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      9879b758
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-seabios-20161027-2' into staging · 86398328
      Peter Maydell 提交于
      seabios: update to 1.10.0 release.
      
      # gpg: Signature made Thu 27 Oct 2016 15:50:54 BST
      # gpg:                using RSA key 0x4CB6D8EED3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      # Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138
      
      * remotes/kraxel/tags/pull-seabios-20161027-2:
        seabios: update to 1.10.0 release.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      86398328
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20161027-1' into staging · b67d87f9
      Peter Maydell 提交于
      virtio-gpu: fix memory leak in virtio_gpu_resource_create_2d
      
      # gpg: Signature made Thu 27 Oct 2016 15:32:38 BST
      # gpg:                using RSA key 0x4CB6D8EED3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      # Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138
      
      * remotes/kraxel/tags/pull-vga-20161027-1:
        virtio-gpu: fix memory leak in virtio_gpu_resource_create_2d
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      b67d87f9
    • N
      ppc: allow certain HV interrupts to be delivered to guests · 10c21b5c
      Nicholas Piggin 提交于
      ppc hypervisors have delivered system reset and machine check exception
      interrupts to guests in some situations (e.g., see FWNMI feature of LoPAPR,
      or NMI injection in QEMU).
      
      These exceptions are architected to set the HV bit in hardware, however
      when injected into a guest, the HV bit should be cleared. Current code
      masks off the HV bit before setting the new MSR, however this happens after
      the interrupt delivery model has calculated delivery mode for the exception.
      This can result in the guest's MSR LE bit being lost.
      
      Account for this in the exception handler and don't set HV bit for guest
      delivery.
      
      Also add another sanity check to ensure similar bugs get caught.
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      10c21b5c
    • B
      spapr: Memory hot-unplug support · cf632463
      Bharata B Rao 提交于
      Add support to hot remove pc-dimm memory devices.
      
      Since we're introducing a machine-level unplug_request hook, we also
      had handling for CPU unplug there as well to ensure CPU unplug
      continues to work as it did before.
      Signed-off-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      * add hooks to CAS/cmdline enablement of hotplug ACR support
      * add hook for CPU unplug
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      cf632463
    • M
      spapr: use count+index for memory hotplug · 79b78a6b
      Michael Roth 提交于
      Commit 0a417869:
      
          spapr: Move memory hotplug to RTAS_LOG_V6_HP_ID_DRC_COUNT type
      
      dropped per-DRC/per-LMB hotplugs event in favor of a bulk add via a
      single LMB count value. This was to avoid overrunning the guest EPOW
      event queue with hotplug events. This works fine, but relies on the
      guest exhaustively scanning for pluggable LMBs to satisfy the
      requested count by issuing rtas-get-sensor(DR_ENTITY_SENSE, ...) calls
      until all the LMBs associated with the DIMM are identified.
      
      With newer support for dedicated hotplug event source, this queue
      exhaustion is no longer as much of an issue due to implementation
      details on the guest side, but we still try to avoid excessive hotplug
      events by now supporting both a count and a starting index to avoid
      unecessary work. This patch makes use of that approach when the
      capability is available.
      
      Cc: bharata@linux.vnet.ibm.com
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      79b78a6b
    • B
      spapr: Add DRC count indexed hotplug identifier type · afdbd403
      Bharata B Rao 提交于
      Add support for DRC count indexed hotplug ID type which is primarily
      needed for memory hot unplug. This type allows for specifying the
      number of DRs that should be plugged/unplugged starting from a given
      DRC index.
      Signed-off-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      * updated rtas_event_log_v6_hp to reflect count/index field ordering
        used in PAPR hotplug ACR
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      afdbd403
    • M
      spapr: add hotplug interrupt machine options · f6229214
      Michael Roth 提交于
      This adds machine options of the form:
      
        -machine pseries,modern-hotplug-events=true
        -machine pseries,modern-hotplug-events=false
      
      If false, QEMU will force the use of "legacy" style hotplug events,
      which are surfaced through EPOW events instead of a dedicated
      hot plug event source, and lack certain features necessary, mainly,
      for memory unplug support.
      
      If true, QEMU will enable support for "modern" dedicated hot plug
      event source. Note that we will still default to "legacy" style unless
      the guest advertises support for the "modern" hotplug events via
      ibm,client-architecture-support hcall during early boot.
      
      For pseries-2.7 and earlier we default to false, for newer machine
      types we default to true.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f6229214
    • M
      spapr_events: add support for dedicated hotplug event source · ffbb1705
      Michael Roth 提交于
      Hotplug events were previously delivered using an EPOW interrupt
      and were queued by linux guests into a circular buffer. For traditional
      EPOW events like shutdown/resets, this isn't an issue, but for hotplug
      events there are cases where this buffer can be exhausted, resulting
      in the loss of hotplug events, resets, etc.
      
      Newer-style hotplug event are delivered using a dedicated event source.
      We enable this in supported guests by adding standard an additional
      event source in the guest device-tree via /event-sources, and, if
      the guest advertises support for the newer-style hotplug events,
      using the corresponding interrupt to signal the available of
      hotplug/unplug events.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      ffbb1705
    • M
      spapr: update spapr hotplug documentation · 9f992cca
      Michael Roth 提交于
      This updates the existing documentation to reflect recent updates to
      the hotplug event structure, which are in draft form but slated
      for inclusion in PAPR/LoPAPR.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      9f992cca
    • S
      target-ppc: Add xvcmpnesp, xvcmpnedp instructions · 6db246f9
      Swapnil Bokade 提交于
      xvcmpnedp[.]: VSX Vector Compare Not Equal Double-Precision
      xvcmpnesp[.]: VSX Vector Compare Not Equal Single-Precision
      Signed-off-by: NSwapnil Bokade <bokadeswapnil@gmail.com>
      Signed-off-by: NNikunj A Dadhania <nikunj@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      6db246f9
    • S
      target-ppc: add xscmp[eq,gt,ge,ne]dp instructions · 6d1ff9a7
      Sandipan Das 提交于
      xscmpeqdp: VSX Scalar Compare Equal Double-Precision
      xscmpgedp: VSX Scalar Compare Greater Than or Equal Double-Precision
      xscmpgtdp: VSX Scalar Compare Greater Than Double-Precision
      xscmpnedp: VSX Scalar Compare Not Equal Double-Precision
      Signed-off-by: NSandipan Das <sandipandas1990@gmail.com>
      Signed-off-by: NNikunj A Dadhania <nikunj@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      6d1ff9a7
    • D
      tests: Add pseries machine to the prom-env-test, too · 53687348
      David Gibson 提交于
      Now that we also support the "-prom-env" parameter for the pseries
      machine, we can enable this test for this machine, too. Since booting
      with TCG is rather slow with the pseries machine, we also enable
      the "-nodefaults" parameter for this test now, so that SLOF does not
      have to check that much devices during boot and thus runs a little
      bit faster.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      [dwg: Don't add -nodefaults to the command line, it causes extra warnings
       for the sparc testcases]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      53687348
    • T
      spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter · 61f20b9d
      Thomas Huth 提交于
      In case we do not load the NVRAM contents from a file and the user
      specified the "-prom-env" parameter, use the new CHRP NVRAM helper
      functions to pre-initialize the NVRAM partitions, so that the SLOF
      firmware now can pick up the environment variables from the -prom-env
      parameter, too.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      61f20b9d
    • D
      libqos: Change PCI accessors to take opaque BAR handle · b4ba67d9
      David Gibson 提交于
      The usual use model for the libqos PCI functions is to map a specific PCI
      BAR using qpci_iomap() then pass the returned token into IO accessor
      functions.  This, and the fact that iomap() returns a (void *) which
      actually contains a PCI space address, kind of suggests that the return
      value from iomap is supposed to be an opaque token.
      
      ..except that the callers expect to be able to add offsets to it.  Which
      also assumes the compiler will support pointer arithmetic on a (void *),
      and treat it as working with byte offsets.
      
      To clarify this situation change iomap() and the IO accessors to take
      a definitely opaque BAR handle (enforced with a wrapper struct) along with
      an offset within the BAR.  This changes both the functions and all the
      callers.
      
      There were a number of places that checked if iomap() returned non-NULL,
      and or initialized it to NULL before hand.  Since iomap() already assert()s
      if it fails to map the BAR, these tests were mostly pointless and are
      removed.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      b4ba67d9
    • D
      tests: Don't assume structure of PCI IO base in ahci-test · e7c8526b
      David Gibson 提交于
      In a couple of places ahci-test makes assumptions about how the tokens
      returned from qpci_iomap() are formatted in ways it probably shouldn't.
      
      First in verify_state() it uses a non-NULL token to indicate that the AHCI
      device has been enabled (part of enabling is to iomap()).  This changes it
      to use an explicit 'enabled' flag instead.
      
      Second, it uses the fact that the token contains a PCI address, stored when
      the BAR is mapped during initialization to check that the BAR has the same
      value after a migration.  This changes it to explicitly read the BAR
      register before and after the migration and compare.
      
      Together, these changes will  make the test more robust against changes to
      the internals of the libqos PCI layer.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      e7c8526b
    • D
      tests: Use qpci_mem{read,write} in ivshmem-test · 204e54b8
      David Gibson 提交于
      ivshmem implements a block of shared memory in a PCI BAR.  Currently our
      test case accesses this using qtest_mem{read,write}.  However, deducing
      the correct addresses for these requires making assumptions about the
      internel format returned by qpci_iomap(), along with some ugly casts.
      
      This patch changes the test to use the new qpci_mem{read,write} interfaces
      which is neater.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      204e54b8
    • D
      libqos: Add 64-bit PCI IO accessors · f775f45a
      David Gibson 提交于
      Currently the libqos PCI layer includes accessor helpers for 8, 16 and 32
      bit reads and writes.  It's likely that we'll want 64-bit accesses in the
      future (plenty of modern peripherals will have 64-bit reigsters).  This
      adds them.
      
      For PIO (not MMIO) accesses on the PC backend, this is implemented as two
      32-bit ins or outs.  That's not ideal but AFAICT x86 doesn't have 64-bit
      versions of in and out.
      
      This patch also converts the single current user of 64-bit accesses -
      virtio-pci.c to use the new mechanism, rather than a sequence of 8 byte
      reads.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      f775f45a
    • D
      tests: Clean up IO handling in ide-test · 9c268f8a
      David Gibson 提交于
      ide-test uses many explicit inb() / outb() operations for its IO, which
      means it's not portable to non-x86 platforms.  This cleans it up to use
      the libqos PCI accessors instead.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      9c268f8a
    • D
      libqos: Implement mmio accessors in terms of mem{read,write} · 352d664c
      David Gibson 提交于
      In the libqos PCI code we now have accessors both for registers (byte
      significance preserving) and for streaming data (byte address order
      preserving).  These exist in both the interface for qtest drivers and in
      the machine specific backends.
      
      However, the register-style accessors aren't actually necessary in the
      backend.  They can be implemented in terms of the byte address order
      preserving accessors by the libqos wrappers.  This works because PCI is
      always little endian.
      
      This does assume that the back end byte address order preserving accessors
      will perform the equivalent of a single bus transaction for short lengths.
      This is the case, and in fact they currently end up using the same
      cpu_physical_memory_rw() implementation within the qtest accelerator.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      352d664c
    • D
      libqos: Add streaming accessors for PCI MMIO · 9a84f889
      David Gibson 提交于
      Currently PCI memory (aka MMIO) space is accessed via a set of readb/writeb
      style accessors.  This is what we want for accessing discrete registers of
      a certain size.  However, there are a few cases where we instead need a
      "bag of bytes" style streaming interface to PCI MMIO space.  This can be
      either for streaming data style registers or when there's actual memory
      rather than registers in PCI space, for example frame buffers or ivshmem.
      
      This patch adds backend callbacks, and libqos wrappers for this type of
      byte address order preserving accesses.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      9a84f889
    • D
      tests: Adjust tco-test to use qpci_legacy_iomap() · 9ff50be2
      David Gibson 提交于
      Avoid tco-test making assumptions about the internal format of the address
      tokens passed to PCI IO accessors, by using the new qpci_legacy_iomap()
      function.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      9ff50be2
    • D
      libqos: Better handling of PCI legacy IO · a7b85b60
      David Gibson 提交于
      The usual model for PCI IO with libqos is to use qpci_iomap() to map a
      specific BAR for a PCI device, then perform IOs within that BAR using
      qpci_io_{read,write}*().
      
      However, certain devices also have legacy PCI IO.  In this case, instead of
      (or as well as) being accessed via PCI BARs, the device can be accessed
      via certain well-known, fixed addresses in PCI IO space.
      
      Two existing tests use legacy PCI IO, and take different flawed approaches
      to it:
          * tco-test manually constructs a tco_io_base value instead of calling
            qpci_iomap(), which assumes internal knowledge of the structure of
            the value it shouldn't have
          * ide-test uses direct in*() and out*() calls instead of using
            qpci_io_*() accessors, meaning it's not portable to non-x86 machine
            types.
      
      This patch implements a new qpci_iomap_legacy() interface which gets a
      handle in the same format as qpci_iomap() but refers to a region in
      the legacy PIO space.  For a device which has the same registers
      available both in a BAR and in legacy space (quite common), this
      allows the same test code to test both options with just a different
      iomap() at the beginning.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      a7b85b60
    • D
      libqos: Move BAR assignment to common code · b8cc4d02
      David Gibson 提交于
      The PCI backends in libqos each supply an iomap() and iounmap() function
      which is used to set up a specified PCI BAR.  But PCI BAR allocation takes
      place entirely within PCI space, so doesn't really need per-backend
      versions.  For example, Linux includes generic BAR allocation code used on
      platforms where that isn't done by firmware.
      
      This patch merges the BAR allocation from the two existing backends into a
      single simplified copy.  The back ends just need to set up some parameters
      describing the window of PCI IO and PCI memory addresses which are
      available for allocation.  Like both the existing versions the new one uses
      a simple bump allocator.
      
      Note that (again like the existing versions) this doesn't really handle
      64-bit memory BARs properly.  It is actually used for such a BAR by the
      ivshmem test, and apparently the 32-bit MMIO BAR logic is close enough to
      work, as long as the BAR isn't too big.  Fixing that to properly handle
      64-bit BAR allocation is a problem for another time.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      b8cc4d02
    • D
      libqos: Handle PCI IO de-multiplexing in common code · a795fc08
      David Gibson 提交于
      The PCI IO space (aka PIO, aka legacy IO) and PCI memory space (aka MMIO)
      are distinct address spaces by the PCI spec (although parts of one might be
      aliased to parts of the other in some cases).
      
      However, qpci_io_read*() and qpci_io_write*() can perform accesses to
      either space depending on parameter.  That's convenient for test case
      drivers, since there are a fair few devices which can be controlled via
      either a PIO or MMIO BAR but with an otherwise identical driver.
      
      This is implemented by having addresses below 64kiB treated as PIO, and
      those above treated as MMIO.  This works because low addresses in memory
      space are generally reserved for DMA rather than MMIO.
      
      At the moment, this demultiplexing must be handled by each PCI backend
      (pc and spapr, so far).  There's no real reason for this - the current
      encoding is likely to work for all platforms, and even if it doesn't we
      can still use a more complex common encoding since the value returned from
      iomap are semi-opaque.
      
      This patch moves the demultiplexing into the common part of the libqos PCI
      code, with the backends having simpler, separate accessors for PIO and
      MMIO space.  This also means we have a way of explicitly accessing either
      space if it's necessary for some special case.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      a795fc08
    • D
      libqos: Give qvirtio_config_read*() consistent semantics · 246fc0fb
      David Gibson 提交于
      The 'addr' parameter to qvirtio_config_read*() doesn't have a consistent
      meaning: when using the virtio-pci versions, it's a full PCI space address,
      but for virtio-mmio, it's an offset from the device's base mmio address.
      
      This means that the callers need to do different things to calculate the
      addresses in the two cases, which rather defeats the purpose of function
      pointer backends.
      
      All the current users of these functions are using them to retrieve
      variables from the device specific portion of the virtio config space.
      So, this patch alters the semantics to always be an offset into that
      device specific config area.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      246fc0fb
    • H
      adb: change handler only when recognized · a37eb9fc
      Hervé Poussineau 提交于
      ADB devices must take new handler into account only when they recognize it.
      This lets operating systems probe for valid/invalid handles, to know device capabilities.
      
      Add a FIXME in keyboard handler, which should use a different translation
      table depending of the selected handler.
      Signed-off-by: NHervé Poussineau <hpoussin@reactos.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      a37eb9fc
    • M
      spapr: improve ibm,architecture-vec-5 property handling · 417ece33
      Michael Roth 提交于
      ibm,architecture-vec-5 is supposed to encode all option vector 5 bits
      negotiated between platform/guest. Currently we hardcode this property
      in the boot-time device tree to advertise a single negotiated
      capability, "Form 1" NUMA Affinity, regardless of whether or not CAS
      has been invoked or that capability has actually been negotiated.
      
      Improve this by generating ibm,architecture-vec-5 based on the full
      set of option vector 5 capabilities negotiated via CAS.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      417ece33
    • M
      spapr: add option vector handling in CAS-generated resets · 6787d27b
      Michael Roth 提交于
      In some cases, ibm,client-architecture-support calls can fail. This
      could happen in the current code for situations where the modified
      device tree segment exceeds the buffer size provided by the guest
      via the call parameters. In these cases, QEMU will reset, allowing
      an opportunity to regenerate the device tree from scratch via
      boot-time handling. There are potentially other scenarios as well,
      not currently reachable in the current code, but possible in theory,
      such as cases where device-tree properties or nodes need to be removed.
      
      We currently don't handle either of these properly for option vector
      capabilities however. Instead of carrying the negotiated capability
      beyond the reset and creating the boot-time device tree accordingly,
      we start from scratch, generating the same boot-time device tree as we
      did prior to the CAS-generated and the same device tree updates as we
      did before. This could (in theory) cause us to get stuck in a reset
      loop. This hasn't been observed, but depending on the extensiveness
      of CAS-induced device tree updates in the future, could eventually
      become an issue.
      
      Address this by pulling capability-related device tree
      updates resulting from CAS calls into a common routine,
      spapr_dt_cas_updates(), and adding an sPAPROptionVector*
      parameter that allows us to test for newly-negotiated capabilities.
      We invoke it as follows:
      
      1) When ibm,client-architecture-support gets called, we
         call spapr_dt_cas_updates() with the set of capabilities
         added since the previous call to ibm,client-architecture-support.
         For the initial boot, or a system reset generated by something
         other than the CAS call itself, this set will consist of *all*
         options supported both the platform and the guest. For calls
         to ibm,client-architecture-support immediately after a CAS-induced
         reset, we call spapr_dt_cas_updates() with only the set
         of capabilities added since the previous call, since the other
         capabilities will have already been addressed by the boot-time
         device-tree this time around. In the unlikely event that
         capabilities are *removed* since the previous CAS, we will
         generate a CAS-induced reset. In the unlikely event that we
         cannot fit the device-tree updates into the buffer provided
         by the guest, well generate a CAS-induced reset.
      
      2) When a CAS update results in the need to reset the machine and
         include the updates in the boot-time device tree, we call the
         spapr_dt_cas_updates() using the full set of negotiated
         capabilities as part of the reset path. At initial boot, or after
         a reset generated by something other than the CAS call itself,
         this set will be empty, resulting in what should be the same
         boot-time device-tree as we generated prior to this patch. For
         CAS-induced reset, this routine will be called with the full set of
         capabilities negotiated by the platform/guest in the previous
         CAS call, which should result in CAS updates from previous call
         being accounted for in the initial boot-time device tree.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      [dwg: Changed an int -> bool conversion to be more explicit]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      6787d27b
    • M
      spapr_hcall: use spapr_ovec_* interfaces for CAS options · facdb8b6
      Michael Roth 提交于
      Currently we access individual bytes of an option vector via
      ldub_phys() to test for the presence of a particular capability
      within that byte. Currently this is only done for the "dynamic
      reconfiguration memory" capability bit. If that bit is present,
      we pass a boolean value to spapr_h_cas_compose_response()
      to generate a modified device tree segment with the additional
      properties required to enable this functionality.
      
      As more capability bits are added, will would need to modify the
      code to add additional option vector accesses and extend the
      param list for spapr_h_cas_compose_response() to include similar
      boolean values for these parameters.
      
      Avoid this by switching to spapr_ovec_* helpers so we can do all
      the parsing in one shot and then test for these additional bits
      within spapr_h_cas_compose_response() directly.
      
      Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      facdb8b6
    • M
      spapr_ovec: initial implementation of option vector helpers · b20b7b7a
      Michael Roth 提交于
      PAPR guests advertise their capabilities to the platform by passing
      an ibm,architecture-vec structure via an
      ibm,client-architecture-support hcall as described by LoPAPR v11,
      B.6.2.3. during early boot.
      
      Using this information, the platform enables the capabilities it
      supports, then encodes a subset of those enabled capabilities (the
      5th option vector of the ibm,architecture-vec structure passed to
      ibm,client-architecture-support) into the guest device tree via
      "/chosen/ibm,architecture-vec-5".
      
      The logical format of these these option vectors is a bit-vector,
      where individual bits are addressed/documented based on the byte-wise
      offset from the beginning of the bit-vector, followed by the bit-wise
      index starting from the byte-wise offset. Thus the bits of each of
      these bytes are stored in reverse order. Additionally, the first
      byte of each option vector is encodes the length of the option vector,
      so byte offsets begin at 1, and bit offset at 0.
      
      This is not very intuitive for the purposes of mapping these bits to
      a particular documented capability, so this patch introduces a set
      of abstractions that encapsulate the work of parsing/encoding these
      options vectors and testing for individual capabilities.
      
      Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      [dwg: Tweaked double-include protection to not trigger a checkpatch
       false positive]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      b20b7b7a
    • D
      pseries: Remove spapr_create_fdt_skel() · 398a0bd5
      David Gibson 提交于
      For historical reasons construction of the guest device tree in spapr is
      divided between spapr_create_fdt_skel() which is called at init time, and
      spapr_build_fdt() which runs at reset time.  Over time, more and more
      things have needed to be moved to reset time.
      
      Previous cleanups mean the only things left in spapr_create_fdt_skel() are
      the properties of the root node itself.  Finish consolidating these two
      parts of device tree construction, by moving this to the start of
      spapr_build_fdt(), and removing spapr_create_fdt_skel() entirely.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      398a0bd5
    • D
      pseries: Consolidate construction of /vdevice device tree node · bf5a6696
      David Gibson 提交于
      Construction of the /vdevice node (and its children) is divided between
      spapr_create_fdt_skel() (at init time), which creates the base node, and
      spapr_populate_vdevice() (at reset time) which creates the nodes for each
      individual virtual device.
      
      This consolidates both into a single function called from
      spapr_build_fdt().
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      bf5a6696
    • D
      pseries: Move /hypervisor node construction to fdt_build_fdt() · fca5f2dc
      David Gibson 提交于
      Currently the /hypervisor device tree node is constructed in
      spapr_create_fdt_skel().  As part of consolidating device tree construction
      to reset time, move it to a function called from spapr_build_fdt().
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      fca5f2dc
    • D
      pseries: Move /event-sources construction to spapr_build_fdt() · ffb1e275
      David Gibson 提交于
      The /event-sources device tree node is built from spapr_create_fdt_skel().
      As part of consolidating device tree construction to reset time, this moves
      it to spapr_build_fdt().
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      ffb1e275
    • D
      pseries: Consolidate construction of /rtas device tree node · 3f5dabce
      David Gibson 提交于
      For historical reasons construction of the /rtas node in the device
      tree (amongst others) is split into several places.  In particular
      it's split between spapr_create_fdt_skel(), spapr_build_fdt() and
      spapr_rtas_device_tree_setup().
      
      In fact, as well as adding the actual RTAS tokens to the device tree,
      spapr_rtas_device_tree_setup() just adds the ibm,lrdr-capacity
      property, which despite going in the /rtas node, doesn't have a lot to
      do with RTAS.
      
      This patch consolidates the code constructing /rtas together into a new
      spapr_dt_rtas() function.  spapr_rtas_device_tree_setup() is renamed to
      spapr_dt_rtas_tokens() and now only adds the token properties.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      3f5dabce
    • D
      pseries: Consolidate construction of /chosen device tree node · 7c866c6a
      David Gibson 提交于
      For historical reasons, building the /chosen node in the guest device tree
      is split across several places and includes both parts which write the DT
      sequentially and others which use random access functions.
      
      This patch consolidates construction of the node into one place, using
      random access functions throughout.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      7c866c6a