Skip to content
Snippets Groups Projects
  1. Feb 28, 2017
    • Peter Maydell's avatar
      cputlb: Don't assume do_unassigned_access() never returns · 44d7ce0e
      Peter Maydell authored
      
      In get_page_addr_code(), if the guest PC doesn't correspond to RAM
      then we currently run the CPU's do_unassigned_access() hook if it has
      one, and otherwise we give up and exit QEMU with a more-or-less
      useful message.  This code assumes that the do_unassigned_access hook
      will never return, because if it does then we'll plough on attempting
      to use a non-RAM TLB entry to get a RAM address and will abort() in
      qemu_ram_addr_from_host_nofail().  Unfortunately some CPU
      implementations of this hook do return: Microblaze, SPARC and the ARM
      v7M.
      
      Change the code to call report_bad_exec() if the hook returns, as
      well as if it didn't have one.  This means we can tidy it up to use
      the cpu_unassigned_access() function which wraps the "get the CPU
      class and call the hook if it has one" work, since we aren't trying
      to distinguish "no hook" from "hook existed and returned" any more.
      
      This brings the handling of this hook into line with the handling
      used for data accesses, where "hook returned" is treated the
      same as "no hook existed" and gets you the default behaviour.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      44d7ce0e
  2. Feb 24, 2017
    • Alex Bennée's avatar
      cputlb: introduce tlb_flush_*_all_cpus[_synced] · c3b9a07a
      Alex Bennée authored
      
      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: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      c3b9a07a
    • Alex Bennée's avatar
      cputlb: atomically update tlb fields used by tlb_reset_dirty · b0706b71
      Alex Bennée authored
      
      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: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      b0706b71
    • Alex Bennée's avatar
      cputlb: add tlb_flush_by_mmuidx async routines · e7218445
      Alex Bennée authored
      
      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: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      e7218445
    • Alex Bennée's avatar
      cputlb and arm/sparc targets: convert mmuidx flushes from varg to bitmap · 0336cbf8
      Alex Bennée authored
      
      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: default avatarAlex Bennée <alex.bennee@linaro.org>
      [AT: SPARC parts only]
      Reviewed-by: default avatarArtyom Tarasenko <atar4qemu@gmail.com>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      [PM: ARM parts only]
      Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      0336cbf8
    • Frederic Konrad's avatar
      cputlb: introduce tlb_flush_* async work. · e3b9ca81
      Frederic Konrad authored
      
      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: default avatarKONRAD Frederic <fred.konrad@greensocs.com>
      [AJB: remove need for g_malloc on defer, make check fixes, tb_lock]
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      e3b9ca81
    • Alex Bennée's avatar
      cputlb: tweak qemu_ram_addr_from_host_nofail reporting · 857baec1
      Alex Bennée authored
      
      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: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      857baec1
    • Alex Bennée's avatar
      cputlb: add assert_cpu_is_self checks · f0aff0f1
      Alex Bennée authored
      
      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: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      f0aff0f1
    • Jan Kiszka's avatar
      tcg: drop global lock during TCG code execution · 8d04fb55
      Jan Kiszka authored
      
      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: default avatarJan 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: default avatarKONRAD Frederic <fred.konrad@greensocs.com>
      [EGC: fixed iothread lock for cpu-exec IRQ handling]
      Signed-off-by: default avatarEmilio G. Cota <cota@braap.org>
      [AJB: -smp single-threaded fix, clean commit msg, BQL fixes]
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Reviewed-by: default avatarPranith Kumar <bobby.prani@gmail.com>
      [PM: target-arm changes]
      Acked-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      8d04fb55
  3. Jan 13, 2017
  4. Oct 28, 2016
  5. Oct 26, 2016
  6. Sep 16, 2016
    • Richard Henderson's avatar
      tcg: Merge GETPC and GETRA · 01ecaf43
      Richard Henderson authored
      
      The return address argument to the softmmu template helpers was
      confused.  In the legacy case, we wanted to indicate that there
      is no return address, and so passed in NULL.  However, we then
      immediately subtracted GETPC_ADJ from NULL, resulting in a non-zero
      value, indicating the presence of an (invalid) return address.
      
      Push the GETPC_ADJ subtraction down to the only point it's required:
      immediately before use within cpu_restore_state_from_tb, after all
      NULL pointer checks have been completed.
      
      This makes GETPC and GETRA identical.  Remove GETRA as the lesser
      used macro, replacing all uses with GETPC.
      
      Signed-off-by: default avatarRichard Henderson <rth@twiddle.net>
      01ecaf43
  7. Jul 08, 2016
  8. Jun 28, 2016
    • Peter Maydell's avatar
      cputlb: don't cpu_abort() if guest tries to execute outside RAM or RAM · d7f30403
      Peter Maydell authored
      
      In get_page_addr_code(), if the guest program counter turns out not to
      be in ROM or RAM, we can't handle executing from it, and we call
      cpu_abort(). This results in the message
        qemu: fatal: Trying to execute code outside RAM or ROM at 0x08000000
      followed by a guest register dump, and then QEMU dumps core.
      
      This situation happens in one of two cases:
       (1) a guest kernel bug, where it jumped off into nowhere
       (2) a user command line mistake, where they tried to run an image for
           board A on a QEMU model of board B, or where they didn't provide
           an image at all, and QEMU executed through a ROM or RAM full of
           NOP instructions and then fell off the end
      
      In either case, a core dump of QEMU itself is entirely useless, and
      only confuses users into thinking that this is a bug in QEMU rather
      than a bug in the guest or a problem with their command line. (This
      is a variation on the general idea that we shouldn't assert() on
      something the user can accidentally provoke.)
      
      Replace the cpu_abort() with something that explains the situation
      a bit better and exits QEMU without dumping core.
      
      (See LP:1062220 for several examples of confused users.)
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Message-id: 1466442425-11885-1-git-send-email-peter.maydell@linaro.org
      d7f30403
  9. May 29, 2016
  10. May 19, 2016
  11. May 13, 2016
  12. Mar 22, 2016
    • Alex Bennée's avatar
      cputlb: modernise the debug support · 8526e1f4
      Alex Bennée authored
      
      To avoid cluttering the code with #ifdef legs we wrap up the print
      statements into a tlb_debug() macro. As access to the virtual TLB can
      get quite heavy defining DEBUG_TLB_LOG will ensure all the logs go to
      the qemu_log target of CPU_LOG_MMU instead of stderr. This remains
      compile time optional as these debug statements haven't been considered
      for usefulness for user visible logging.
      
      I've also removed DEBUG_TLB_CHECK which wasn't used.
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Message-Id: <1458052224-9316-11-git-send-email-alex.bennee@linaro.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8526e1f4
  13. Mar 07, 2016
  14. Jan 29, 2016
  15. Jan 21, 2016
  16. Sep 16, 2015
  17. Sep 11, 2015
  18. Aug 25, 2015
  19. Jun 05, 2015
  20. Apr 26, 2015
  21. Feb 16, 2015
Loading