1. 26 2月, 2017 6 次提交
    • P
      slirp: Check qemu_socket() return value in udp_listen() · 4577b09a
      Peter Maydell 提交于
      Check the return value from qemu_socket() rather than trying to
      pass it to bind() as an fd argument even if it's negative.
      This wouldn't have caused any negative consequences, because
      it won't be a valid fd number and the bind call will fail;
      but Coverity complains (CID 1005723).
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: NSamuel Thibault <samuel.thibault@ens-lyon.org>
      4577b09a
    • P
      Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging · 6528a4c1
      Peter Maydell 提交于
      # gpg: Signature made Fri 24 Feb 2017 17:45:53 GMT
      # gpg:                using RSA key 0xBDBE7B27C0DE3057
      # gpg: Good signature from "Jeffrey Cody <jcody@redhat.com>"
      # gpg:                 aka "Jeffrey Cody <jeff@codyprime.org>"
      # gpg:                 aka "Jeffrey Cody <codyprime@gmail.com>"
      # Primary key fingerprint: 9957 4B4D 3474 90E7 9D98  D624 BDBE 7B27 C0DE 3057
      
      * remotes/cody/tags/block-pull-request:
        RBD: Add support readv,writev for rbd
        block/nfs: try to avoid the bounce buffer in pwritev
        block/nfs: convert to preadv / pwritev
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      6528a4c1
    • P
      Merge remote-tracking branch 'remotes/yongbok/tags/mips-20170224-2' into staging · 6d3f4c6d
      Peter Maydell 提交于
      MIPS patches 2017-02-24-2
      
      CHanges:
      * Add the Boston board with fixing the make check issue on 32-bit hosts.
      
      # gpg: Signature made Fri 24 Feb 2017 11:43:45 GMT
      # gpg:                using RSA key 0x2238EB86D5F797C2
      # gpg: Good signature from "Yongbok Kim <yongbok.kim@imgtec.com>"
      # gpg: WARNING: This key is not certified with sufficiently trusted signatures!
      # gpg:          It is not certain that the signature belongs to the owner.
      # Primary key fingerprint: 8600 4CF5 3415 A5D9 4CFA  2B5C 2238 EB86 D5F7 97C2
      
      * remotes/yongbok/tags/mips-20170224-2:
        hw/mips: MIPS Boston board support
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      6d3f4c6d
    • P
      Merge remote-tracking branch 'remotes/stsquad/tags/pull-mttcg-240217-1' into staging · 28f997a8
      Peter Maydell 提交于
      This is the MTTCG pull-request as posted yesterday.
      
      # gpg: Signature made Fri 24 Feb 2017 11:17:51 GMT
      # gpg:                using RSA key 0xFBD0DB095A9E2A44
      # gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>"
      # Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44
      
      * remotes/stsquad/tags/pull-mttcg-240217-1: (24 commits)
        tcg: enable MTTCG by default for ARM on x86 hosts
        hw/misc/imx6_src: defer clearing of SRC_SCR reset bits
        target-arm: ensure all cross vCPUs TLB flushes complete
        target-arm: don't generate WFE/YIELD calls for MTTCG
        target-arm/powerctl: defer cpu reset work to CPU context
        cputlb: introduce tlb_flush_*_all_cpus[_synced]
        cputlb: atomically update tlb fields used by tlb_reset_dirty
        cputlb: add tlb_flush_by_mmuidx async routines
        cputlb and arm/sparc targets: convert mmuidx flushes from varg to bitmap
        cputlb: introduce tlb_flush_* async work.
        cputlb: tweak qemu_ram_addr_from_host_nofail reporting
        cputlb: add assert_cpu_is_self checks
        tcg: handle EXCP_ATOMIC exception for system emulation
        tcg: enable thread-per-vCPU
        tcg: enable tb_lock() for SoftMMU
        tcg: remove global exit_request
        tcg: drop global lock during TCG code execution
        tcg: rename tcg_current_cpu to tcg_current_rr_cpu
        tcg: add kick timer for single-threaded vCPU emulation
        tcg: add options for enabling MTTCG
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      28f997a8
    • P
      Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20170224' into staging · 2421f381
      Peter Maydell 提交于
      A selection of s390x patches:
      - cleanups, fixes and improvements
      - program check loop detection (useful with the corresponding kernel
        patch)
      - wire up virtio-crypto for ccw
      - and finally support many virtqueues for virtio-ccw
      
      # gpg: Signature made Fri 24 Feb 2017 09:19:19 GMT
      # gpg:                using RSA key 0xDECF6B93C6F02FAF
      # gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>"
      # gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
      # Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF
      
      * remotes/cohuck/tags/s390x-20170224:
        s390x/css: handle format-0 TIC CCW correctly
        s390x/arch_dump: pass cpuid into notes sections
        s390x/arch_dump: use proper note name and note size
        virtio-ccw: support VIRTIO_QUEUE_MAX virtqueues
        s390x: bump ADAPTER_ROUTES_MAX_GSI
        virtio-ccw: check flic->adapter_routes_max_batch
        s390x: add property adapter_routes_max_batch
        virtio-ccw: Check the number of vqs in CCW_CMD_SET_IND
        virtio-ccw: add virtio-crypto-ccw device
        virtio-ccw: handle virtio 1 only devices
        s390x/flic: fail migration on source already
        s390x/kvm: detect some program check loops
        s390x/s390-virtio: get rid of DPRINTF
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      2421f381
    • P
      Merge remote-tracking branch 'remotes/famz/tags/for-upstream' into staging · f62ab6bb
      Peter Maydell 提交于
      Docker testing and shippable patches
      
      Hi Peter,
      
      These are testing and build automation patches:
      
      - Shippable.com powered CI config
      - Docker cross build
      - Fixes and MAINTAINERS tweaks.
      
      # gpg: Signature made Fri 24 Feb 2017 06:31:10 GMT
      # gpg:                using RSA key 0xCA35624C6A9171C6
      # gpg: Good signature from "Fam Zheng <famz@redhat.com>"
      # gpg: WARNING: This key is not certified with a trusted signature!
      # gpg:          There is no indication that the signature belongs to the owner.
      # Primary key fingerprint: 5003 7CB7 9706 0F76 F021  AD56 CA35 624C 6A91 71C6
      
      * remotes/famz/tags/for-upstream:
        docker: Install python2 explicitly in docker image
        MAINTAINERS: merge Build and test automation with Docker tests
        .shippable.yml: new CI provider
        new: debian docker targets for cross-compiling
        tests/docker: add basic user mapping support
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      f62ab6bb
  2. 25 2月, 2017 5 次提交
    • P
      Merge remote-tracking branch 'remotes/armbru/tags/pull-util-2017-02-23' into staging · d7941f4e
      Peter Maydell 提交于
      option cutils: Fix and clean up number conversions
      
      # gpg: Signature made Thu 23 Feb 2017 19:41:17 GMT
      # gpg:                using RSA key 0x3870B400EB918653
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
      # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653
      
      * remotes/armbru/tags/pull-util-2017-02-23: (24 commits)
        option: Fix checking of sizes for overflow and trailing crap
        util/cutils: Change qemu_strtosz*() from int64_t to uint64_t
        util/cutils: Return qemu_strtosz*() error and value separately
        util/cutils: Let qemu_strtosz*() optionally reject trailing crap
        qemu-img: Wrap cvtnum() around qemu_strtosz()
        test-cutils: Drop suffix from test_qemu_strtosz_simple()
        test-cutils: Use qemu_strtosz() more often
        util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros
        util/cutils: New qemu_strtosz()
        util/cutils: Rename qemu_strtosz() to qemu_strtosz_MiB()
        util/cutils: New qemu_strtosz_metric()
        test-cutils: Cover qemu_strtosz() around range limits
        test-cutils: Cover qemu_strtosz() with trailing crap
        test-cutils: Cover qemu_strtosz() invalid input
        test-cutils: Add missing qemu_strtosz()... endptr checks
        option: Fix to reject invalid and overflowing numbers
        util/cutils: Clean up control flow around qemu_strtol() a bit
        util/cutils: Clean up variable names around qemu_strtol()
        util/cutils: Rename qemu_strtoll(), qemu_strtoull()
        util/cutils: Rewrite documentation of qemu_strtol() & friends
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      d7941f4e
    • T
      RBD: Add support readv,writev for rbd · 1d393bde
      tianqing 提交于
      Rbd can do readv and writev directly, so wo do not need to transform
      iov to buf or vice versa any more.
      Signed-off-by: Ntianqing <tianqing@unitedstack.com>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Signed-off-by: NJeff Cody <jcody@redhat.com>
      1d393bde
    • P
      block/nfs: try to avoid the bounce buffer in pwritev · ef503a84
      Peter Lieven 提交于
      if the passed qiov contains exactly one iov we can
      pass the buffer directly.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Message-id: 1487349541-10201-3-git-send-email-pl@kamp.de
      Signed-off-by: NJeff Cody <jcody@redhat.com>
      ef503a84
    • P
      block/nfs: convert to preadv / pwritev · 69785a22
      Peter Lieven 提交于
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Message-id: 1487349541-10201-2-git-send-email-pl@kamp.de
      Signed-off-by: NJeff Cody <jcody@redhat.com>
      69785a22
    • P
      Merge remote-tracking branch 'remotes/awilliam/tags/vfio-updates-20170223.0' into staging · 6959e452
      Peter Maydell 提交于
      VFIO updates 2017-02-23
      
       - Report qdev_unplug errors (Alex Williamson)
       - Fix ecap ID 0 handling, improve comment (Alex Williamson)
       - Disable IGD stolen memory in UPT mode too (Xiong Zhang)
      
      # gpg: Signature made Thu 23 Feb 2017 19:04:17 GMT
      # gpg:                using RSA key 0x239B9B6E3BB08B22
      # gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>"
      # gpg:                 aka "Alex Williamson <alex@shazbot.org>"
      # gpg:                 aka "Alex Williamson <alwillia@redhat.com>"
      # gpg:                 aka "Alex Williamson <alex.l.williamson@gmail.com>"
      # Primary key fingerprint: 42F6 C04E 540B D1A9 9E7B  8A90 239B 9B6E 3BB0 8B22
      
      * remotes/awilliam/tags/vfio-updates-20170223.0:
        vfio/pci-quirks.c: Disable stolen memory for igd VFIO
        vfio/pci: Improve extended capability comments, skip masked caps
        vfio/pci: Report errors from qdev_unplug() via device request
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      6959e452
  3. 24 2月, 2017 29 次提交
    • P
      Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-02-22' into staging · fe8ee082
      Peter Maydell 提交于
      QAPI patches for 2017-02-22
      
      # gpg: Signature made Wed 22 Feb 2017 19:12:27 GMT
      # gpg:                using RSA key 0x3870B400EB918653
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
      # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653
      
      * remotes/armbru/tags/pull-qapi-2017-02-22:
        block: Don't bother asserting type of output visitor's output
        monitor: Clean up handle_hmp_command() a bit
        tests: Don't check qobject_type() before qobject_to_qbool()
        tests: Don't check qobject_type() before qobject_to_qfloat()
        tests: Don't check qobject_type() before qobject_to_qint()
        tests: Don't check qobject_type() before qobject_to_qstring()
        tests: Don't check qobject_type() before qobject_to_qlist()
        Don't check qobject_type() before qobject_to_qdict()
        test-qmp-event: Simplify and tighten event_test_emit()
        libqtest: Clean up qmp_response() a bit
        check-qjson: Simplify around compare_litqobj_to_qobj()
        check-qdict: Tighten qdict_crumple_test_recursive() some
        check-qdict: Simplify qdict_crumple_test_recursive()
        qdict: Make qdict_get_qlist() safe like qdict_get_qdict()
        net: Flatten simple union NetLegacyOptions
        numa: Flatten simple union NumaOptions
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      fe8ee082
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-cve-2017-2620-20170224-1' into staging · 63f495be
      Peter Maydell 提交于
      cirrus: add blit_is_unsafe call to cirrus_bitblt_cputovideo (CVE-2017-2620)
      
      # gpg: Signature made Fri 24 Feb 2017 13:42:39 GMT
      # 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-cve-2017-2620-20170224-1:
        cirrus: add blit_is_unsafe call to cirrus_bitblt_cputovideo (CVE-2017-2620)
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      63f495be
    • G
      cirrus: add blit_is_unsafe call to cirrus_bitblt_cputovideo (CVE-2017-2620) · 92f2b88c
      Gerd Hoffmann 提交于
      CIRRUS_BLTMODE_MEMSYSSRC blits do NOT check blit destination
      and blit width, at all.  Oops.  Fix it.
      
      Security impact: high.
      
      The missing blit destination check allows to write to host memory.
      Basically same as CVE-2014-8106 for the other blit variants.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      92f2b88c
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20170223-1' into staging · 5842b55f
      Peter Maydell 提交于
      usb: ohci bugfix, switch core to unrealize, xhci property cleanup
      
      # gpg: Signature made Thu 23 Feb 2017 15:37:57 GMT
      # 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-usb-20170223-1:
        xhci: properties cleanup
        usb: ohci: fix error return code in servicing td
        usb: replace handle_destroy with unrealize
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      5842b55f
    • P
      hw/mips: MIPS Boston board support · df1d8a1f
      Paul Burton 提交于
      Introduce support for emulating the MIPS Boston development board. The
      Boston board is built around an FPGA & 3 PCIe controllers, one of which
      is connected to an Intel EG20T Platform Controller Hub. It is used
      during the development & debug of new CPUs and the software intended to
      run on them, and is essentially the successor to the older MIPS Malta
      board.
      
      This patch does not implement the EG20T, instead connecting an already
      supported ICH-9 AHCI controller. Whilst this isn't accurate it's enough
      for typical stock Boston software (eg. Linux kernels) to work with hard
      disks given that both the ICH-9 & EG20T implement the AHCI
      specification.
      
      Boston boards typically boot kernels in the FIT image format, and this
      patch will treat kernels provided to QEMU as such. When loading a kernel
      directly, the board code will generate minimal firmware much as the
      Malta board code does. This firmware will set up the CM, CPC & GIC
      register base addresses then set argument registers & jump to the kernel
      entry point. Alternatively, bootloader code may be loaded using the bios
      argument in which case no firmware will be generated & execution will
      proceed from the start of the boot code at the default MIPS boot
      exception vector (offset 0x1fc00000 into (c)kseg1).
      
      Currently real Boston boards are always used with FPGA bitfiles that
      include a Global Interrupt Controller (GIC), so the interrupt
      configuration is only defined for such cases. Therefore the board will
      only allow use of CPUs which implement the CPS components, including the
      GIC, and will otherwise exit with a message.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reviewed-by: NYongbok Kim <yongbok.kim@imgtec.com>
      [yongbok.kim@imgtec.com:
        isolated boston machine support for mips64el.
        updated for recent Chardev changes.
        ignore missing bios/kernel for qtest.
        added default -drive to if=ide explicitly.
        changed default memory size into 1G due to make check failure
        on 32-bit hosts]
      Signed-off-by: NYongbok Kim <yongbok.kim@imgtec.com>
      df1d8a1f
    • A
      tcg: enable MTTCG by default for ARM on x86 hosts · ca759f9e
      Alex Bennée 提交于
      This enables the multi-threaded system emulation by default for ARMv7
      and ARMv8 guests using the x86_64 TCG backend. This is because on the
      guest side:
      
        - The ARM translate.c/translate-64.c have been converted to
          - use MTTCG safe atomic primitives
          - emit the appropriate barrier ops
        - The ARM machine has been updated to
          - hold the BQL when modifying shared cross-vCPU state
          - defer powerctl changes to async safe work
      
      All the host backends support the barrier and atomic primitives but
      need to provide same-or-better support for normal load/store
      operations.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Acked-by: NPeter Maydell <peter.maydell@linaro.org>
      Tested-by: NPranith Kumar <bobby.prani@gmail.com>
      Reviewed-by: NPranith Kumar <bobby.prani@gmail.com>
      ca759f9e
    • A
      hw/misc/imx6_src: defer clearing of SRC_SCR reset bits · 4881658a
      Alex Bennée 提交于
      The arm_reset_cpu/set_cpu_on/set_cpu_off() functions do their work
      asynchronously in the target vCPUs context. As a result we need to
      ensure the SRC_SCR reset bits correctly report the reset status at the
      right time. To do this we defer the clearing of the bit with an async
      job which will run after the work queued by ARM powerctl functions.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      4881658a
    • A
      target-arm: ensure all cross vCPUs TLB flushes complete · a67cf277
      Alex Bennée 提交于
      Previously flushes on other vCPUs would only get serviced when they
      exited their TranslationBlocks. While this isn't overly problematic it
      violates the semantics of TLB flush from the point of view of source
      vCPU.
      
      To solve this we call the cputlb *_all_cpus_synced() functions to do
      the flushes which ensures all flushes are completed by the time the
      vCPU next schedules its own work. As the TLB instructions are modelled
      as CP writes the TB ends at this point meaning cpu->exit_request will
      be checked before the next instruction is executed.
      
      Deferring the work until the architectural sync point is a possible
      future optimisation.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      a67cf277
    • A
      target-arm: don't generate WFE/YIELD calls for MTTCG · c22edfeb
      Alex Bennée 提交于
      The WFE and YIELD instructions are really only hints and in TCG's case
      they were useful to move the scheduling on from one vCPU to the next. In
      the parallel context (MTTCG) this just causes an unnecessary cpu_exit
      and contention of the BQL.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      c22edfeb
    • A
      target-arm/powerctl: defer cpu reset work to CPU context · 062ba099
      Alex Bennée 提交于
      When switching a new vCPU on we want to complete a bunch of the setup
      work before we start scheduling the vCPU thread. To do this cleanly we
      defer vCPU setup to async work which will run the vCPUs execution
      context as the thread is woken up. The scheduling of the work will kick
      the vCPU awake.
      
      This avoids potential races in MTTCG system emulation.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      062ba099
    • A
      cputlb: introduce tlb_flush_*_all_cpus[_synced] · c3b9a07a
      Alex Bennée 提交于
      This introduces support to the cputlb API for flushing all CPUs TLBs
      with one call. This avoids the need for target helpers to iterate
      through the vCPUs themselves.
      
      An additional variant of the API (_synced) will cause the source vCPUs
      work to be scheduled as "safe work". The result will be all the flush
      operations will be complete by the time the originating vCPU executes
      its safe work. The calling implementation can either end the TB
      straight away (which will then pick up the cpu->exit_request on
      entering the next block) or defer the exit until the architectural
      sync point (usually a barrier instruction).
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      c3b9a07a
    • A
      cputlb: atomically update tlb fields used by tlb_reset_dirty · b0706b71
      Alex Bennée 提交于
      The main use case for tlb_reset_dirty is to set the TLB_NOTDIRTY flags
      in TLB entries to force the slow-path on writes. This is used to mark
      page ranges containing code which has been translated so it can be
      invalidated if written to. To do this safely we need to ensure the TLB
      entries in question for all vCPUs are updated before we attempt to run
      the code otherwise a race could be introduced.
      
      To achieve this we atomically set the flag in tlb_reset_dirty_range and
      take care when setting it when the TLB entry is filled.
      
      On 32 bit systems attempting to emulate 64 bit guests we don't even
      bother as we might not have the atomic primitives available. MTTCG is
      disabled in this case and can't be forced on. The copy_tlb_helper
      function helps keep the atomic semantics in one place to avoid
      confusion.
      
      The dirty helper function is made static as it isn't used outside of
      cputlb.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      b0706b71
    • A
      cputlb: add tlb_flush_by_mmuidx async routines · e7218445
      Alex Bennée 提交于
      This converts the remaining TLB flush routines to use async work when
      detecting a cross-vCPU flush. The only minor complication is having to
      serialise the var_list of MMU indexes into a form that can be punted
      to an asynchronous job.
      
      The pending_tlb_flush field on QOM's CPU structure also becomes a
      bitfield rather than a boolean.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      e7218445
    • A
      cputlb and arm/sparc targets: convert mmuidx flushes from varg to bitmap · 0336cbf8
      Alex Bennée 提交于
      While the vargs approach was flexible the original MTTCG ended up
      having munge the bits to a bitmap so the data could be used in
      deferred work helpers. Instead of hiding that in cputlb we push the
      change to the API to make it take a bitmap of MMU indexes instead.
      
      For ARM some the resulting flushes end up being quite long so to aid
      readability I've tended to move the index shifting to a new line so
      all the bits being or-ed together line up nicely, for example:
      
          tlb_flush_page_by_mmuidx(other_cs, pageaddr,
                                   (1 << ARMMMUIdx_S1SE1) |
                                   (1 << ARMMMUIdx_S1SE0));
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      [AT: SPARC parts only]
      Reviewed-by: NArtyom Tarasenko <atar4qemu@gmail.com>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      [PM: ARM parts only]
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      0336cbf8
    • K
      cputlb: introduce tlb_flush_* async work. · e3b9ca81
      KONRAD Frederic 提交于
      Some architectures allow to flush the tlb of other VCPUs. This is not a problem
      when we have only one thread for all VCPUs but it definitely needs to be an
      asynchronous work when we are in true multithreaded work.
      
      We take the tb_lock() when doing this to avoid racing with other threads
      which may be invalidating TB's at the same time. The alternative would
      be to use proper atomic primitives to clear the tlb entries en-mass.
      
      This patch doesn't do anything to protect other cputlb function being
      called in MTTCG mode making cross vCPU changes.
      Signed-off-by: NKONRAD Frederic <fred.konrad@greensocs.com>
      [AJB: remove need for g_malloc on defer, make check fixes, tb_lock]
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      e3b9ca81
    • A
      cputlb: tweak qemu_ram_addr_from_host_nofail reporting · 857baec1
      Alex Bennée 提交于
      This moves the helper function closer to where it is called and updates
      the error message to report via error_report instead of the deprecated
      fprintf.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      857baec1
    • A
      cputlb: add assert_cpu_is_self checks · f0aff0f1
      Alex Bennée 提交于
      For SoftMMU the TLB flushes are an example of a task that can be
      triggered on one vCPU by another. To deal with this properly we need to
      use safe work to ensure these changes are done safely. The new assert
      can be enabled while debugging to catch these cases.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      f0aff0f1
    • P
      tcg: handle EXCP_ATOMIC exception for system emulation · 08e73c48
      Pranith Kumar 提交于
      The patch enables handling atomic code in the guest. This should be
      preferably done in cpu_handle_exception(), but the current assumptions
      regarding when we can execute atomic sections cause a deadlock.
      
      The current mechanism discards the flags which were set in atomic
      execution. We ensure they are properly saved by calling the
      cc->cpu_exec_enter/leave() functions around the loop.
      
      As we are running cpu_exec_step_atomic() from the outermost loop we
      need to avoid an abort() when single stepping over atomic code since
      debug exception longjmp will point to the the setlongjmp in
      cpu_exec(). We do this by setting a new jmp_env so that it jumps back
      here on an exception.
      Signed-off-by: NPranith Kumar <bobby.prani@gmail.com>
      [AJB: tweak title, merge with new patches, add mmap_lock]
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      08e73c48
    • A
      tcg: enable thread-per-vCPU · 37257942
      Alex Bennée 提交于
      There are a couple of changes that occur at the same time here:
      
        - introduce a single vCPU qemu_tcg_cpu_thread_fn
      
        One of these is spawned per vCPU with its own Thread and Condition
        variables. qemu_tcg_rr_cpu_thread_fn is the new name for the old
        single threaded function.
      
        - the TLS current_cpu variable is now live for the lifetime of MTTCG
          vCPU threads. This is for future work where async jobs need to know
          the vCPU context they are operating in.
      
      The user to switch on multi-thread behaviour and spawn a thread
      per-vCPU. For a simple test kvm-unit-test like:
      
        ./arm/run ./arm/locking-test.flat -smp 4 -accel tcg,thread=multi
      
      Will now use 4 vCPU threads and have an expected FAIL (instead of the
      unexpected PASS) as the default mode of the test has no protection when
      incrementing a shared variable.
      
      We enable the parallel_cpus flag to ensure we generate correct barrier
      and atomic code if supported by the front and backends. This doesn't
      automatically enable MTTCG until default_mttcg_enabled() is updated to
      check the configuration is supported.
      Signed-off-by: NKONRAD Frederic <fred.konrad@greensocs.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      [AJB: Some fixes, conditionally, commit rewording]
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      37257942
    • A
      tcg: enable tb_lock() for SoftMMU · 2f169606
      Alex Bennée 提交于
      tb_lock() has long been used for linux-user mode to protect code
      generation. By enabling it now we prepare for MTTCG and ensure all code
      generation is serialised by this lock. The other major structure that
      needs protecting is the l1_map and its PageDesc structures. For the
      SoftMMU case we also use tb_lock() to protect these structures instead
      of linux-user mmap_lock() which as the name suggests serialises updates
      to the structure as a result of guest mmap operations.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      2f169606
    • A
      tcg: remove global exit_request · e5143e30
      Alex Bennée 提交于
      There are now only two uses of the global exit_request left.
      
      The first ensures we exit the run_loop when we first start to process
      pending work and in the kick handler. This is just as easily done by
      setting the first_cpu->exit_request flag.
      
      The second use is in the round robin kick routine. The global
      exit_request ensured every vCPU would set its local exit_request and
      cause a full exit of the loop. Now the iothread isn't being held while
      running we can just rely on the kick handler to push us out as intended.
      
      We lightly re-factor the main vCPU thread to ensure cpu->exit_requests
      cause us to exit the main loop and process any IO requests that might
      come along. As an cpu->exit_request may legitimately get squashed
      while processing the EXCP_INTERRUPT exception we also check
      cpu->queued_work_first to ensure queued work is expedited as soon as
      possible.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      e5143e30
    • J
      tcg: drop global lock during TCG code execution · 8d04fb55
      Jan Kiszka 提交于
      This finally allows TCG to benefit from the iothread introduction: Drop
      the global mutex while running pure TCG CPU code. Reacquire the lock
      when entering MMIO or PIO emulation, or when leaving the TCG loop.
      
      We have to revert a few optimization for the current TCG threading
      model, namely kicking the TCG thread in qemu_mutex_lock_iothread and not
      kicking it in qemu_cpu_kick. We also need to disable RAM block
      reordering until we have a more efficient locking mechanism at hand.
      
      Still, a Linux x86 UP guest and my Musicpal ARM model boot fine here.
      These numbers demonstrate where we gain something:
      
      20338 jan       20   0  331m  75m 6904 R   99  0.9   0:50.95 qemu-system-arm
      20337 jan       20   0  331m  75m 6904 S   20  0.9   0:26.50 qemu-system-arm
      
      The guest CPU was fully loaded, but the iothread could still run mostly
      independent on a second core. Without the patch we don't get beyond
      
      32206 jan       20   0  330m  73m 7036 R   82  0.9   1:06.00 qemu-system-arm
      32204 jan       20   0  330m  73m 7036 S   21  0.9   0:17.03 qemu-system-arm
      
      We don't benefit significantly, though, when the guest is not fully
      loading a host CPU.
      Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
      Message-Id: <1439220437-23957-10-git-send-email-fred.konrad@greensocs.com>
      [FK: Rebase, fix qemu_devices_reset deadlock, rm address_space_* mutex]
      Signed-off-by: NKONRAD Frederic <fred.konrad@greensocs.com>
      [EGC: fixed iothread lock for cpu-exec IRQ handling]
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      [AJB: -smp single-threaded fix, clean commit msg, BQL fixes]
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NPranith Kumar <bobby.prani@gmail.com>
      [PM: target-arm changes]
      Acked-by: NPeter Maydell <peter.maydell@linaro.org>
      8d04fb55
    • A
      tcg: rename tcg_current_cpu to tcg_current_rr_cpu · 791158d9
      Alex Bennée 提交于
      ..and make the definition local to cpus. In preparation for MTTCG the
      concept of a global tcg_current_cpu will no longer make sense. However
      we still need to keep track of it in the single-threaded case to be able
      to exit quickly when required.
      
      qemu_cpu_kick_no_halt() moves and becomes qemu_cpu_kick_rr_cpu() to
      emphasise its use-case. qemu_cpu_kick now kicks the relevant cpu as
      well as qemu_kick_rr_cpu() which will become a no-op in MTTCG.
      
      For the time being the setting of the global exit_request remains.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NPranith Kumar <bobby.prani@gmail.com>
      791158d9
    • A
      tcg: add kick timer for single-threaded vCPU emulation · 6546706d
      Alex Bennée 提交于
      Currently we rely on the side effect of the main loop grabbing the
      iothread_mutex to give any long running basic block chains a kick to
      ensure the next vCPU is scheduled. As this code is being re-factored and
      rationalised we now do it explicitly here.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NPranith Kumar <bobby.prani@gmail.com>
      6546706d
    • K
      tcg: add options for enabling MTTCG · 8d4e9146
      KONRAD Frederic 提交于
      We know there will be cases where MTTCG won't work until additional work
      is done in the front/back ends to support. It will however be useful to
      be able to turn it on.
      
      As a result MTTCG will default to off unless the combination is
      supported. However the user can turn it on for the sake of testing.
      Signed-off-by: NKONRAD Frederic <fred.konrad@greensocs.com>
      [AJB: move to -accel tcg,thread=multi|single, defaults]
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      8d4e9146
    • A
      tcg: move TCG_MO/BAR types into own file · 20937143
      Alex Bennée 提交于
      We'll be using the memory ordering definitions to define values for
      both the host and guest. To avoid fighting with circular header
      dependencies just move these types into their own minimal header.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      20937143
    • P
      mttcg: Add missing tb_lock/unlock() in cpu_exec_step() · 4ec66704
      Pranith Kumar 提交于
      The recent patch enabling lock assertions uncovered the missing lock
      acquisition in cpu_exec_step(). This patch adds them.
      Signed-off-by: NPranith Kumar <bobby.prani@gmail.com>
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      4ec66704
    • P
      mttcg: translate-all: Enable locking debug in a debug build · 6ac3d7e8
      Pranith Kumar 提交于
      Enable tcg lock debug asserts in a debug build by default instead of
      relying on DEBUG_LOCKING. None of the other DEBUG_* macros have
      asserts, so this patch removes DEBUG_LOCKING and enable these asserts
      in a debug build.
      
      CC: Richard Henderson <rth@twiddle.net>
      Signed-off-by: NPranith Kumar <bobby.prani@gmail.com>
      [AJB: tweak ifdefs so can be early in series]
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      6ac3d7e8
    • A
      docs: new design document multi-thread-tcg.txt · c6489dd9
      Alex Bennée 提交于
      This documents the current design for upgrading TCG emulation to take
      advantage of modern CPUs by running a thread-per-CPU. The document goes
      through the various areas of the code affected by such a change and
      proposes design requirements for each part of the solution.
      
      The text marked with (Current solution[s]) to document what the current
      approaches being used are.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      c6489dd9