1. 16 6月, 2018 1 次提交
    • E
      qht: require a default comparison function · 61b8cef1
      Emilio G. Cota 提交于
      qht_lookup now uses the default cmp function. qht_lookup_custom is defined
      to retain the old behaviour, that is a cmp function is explicitly provided.
      
      qht_insert will gain use of the default cmp in the next patch.
      
      Note that we move qht_lookup_custom's @func to be the last argument,
      which makes the new qht_lookup as simple as possible.
      Instead of this (i.e. keeping @func 2nd):
      0000000000010750 <qht_lookup>:
         10750:       89 d1                   mov    %edx,%ecx
         10752:       48 89 f2                mov    %rsi,%rdx
         10755:       48 8b 77 08             mov    0x8(%rdi),%rsi
         10759:       e9 22 ff ff ff          jmpq   10680 <qht_lookup_custom>
         1075e:       66 90                   xchg   %ax,%ax
      
      We get:
      0000000000010740 <qht_lookup>:
         10740:       48 8b 4f 08             mov    0x8(%rdi),%rcx
         10744:       e9 37 ff ff ff          jmpq   10680 <qht_lookup_custom>
         10749:       0f 1f 80 00 00 00 00    nopl   0x0(%rax)
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Signed-off-by: NRichard Henderson <richard.henderson@linaro.org>
      61b8cef1
  2. 15 6月, 2018 3 次提交
  3. 01 6月, 2018 1 次提交
  4. 31 5月, 2018 2 次提交
  5. 20 5月, 2018 1 次提交
  6. 15 5月, 2018 1 次提交
  7. 11 5月, 2018 2 次提交
  8. 10 5月, 2018 1 次提交
  9. 11 4月, 2018 1 次提交
    • P
      icount: fix cpu_restore_state_from_tb for non-tb-exit cases · afd46fca
      Pavel Dovgalyuk 提交于
      In icount mode, instructions that access io memory spaces in the middle
      of the translation block invoke TB recompilation.  After recompilation,
      such instructions become last in the TB and are allowed to access io
      memory spaces.
      
      When the code includes instruction like i386 'xchg eax, 0xffffd080'
      which accesses APIC, QEMU goes into an infinite loop of the recompilation.
      
      This instruction includes two memory accesses - one read and one write.
      After the first access, APIC calls cpu_report_tpr_access, which restores
      the CPU state to get the current eip.  But cpu_restore_state_from_tb
      resets the cpu->can_do_io flag which makes the second memory access invalid.
      Therefore the second memory access causes a recompilation of the block.
      Then these operations repeat again and again.
      
      This patch moves resetting cpu->can_do_io flag from
      cpu_restore_state_from_tb to cpu_loop_exit* functions.
      
      It also adds a parameter for cpu_restore_state which controls restoring
      icount.  There is no need to restore icount when we only query CPU state
      without breaking the TB.  Restoring it in such cases leads to the
      incorrect flow of the virtual time.
      
      In most cases new parameter is true (icount should be recalculated).
      But there are two cases in i386 and openrisc when the CPU state is only
      queried without the need to break the TB.  This patch fixes both of
      these cases.
      Signed-off-by: NPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
      Message-Id: <20180409091320.12504.35329.stgit@pasha-VirtualBox>
      [rth: Make can_do_io setting unconditional; move from cpu_exec;
      make cpu_loop_exit_{noexc,restore} call cpu_loop_exit.]
      Signed-off-by: NRichard Henderson <richard.henderson@linaro.org>
      afd46fca
  10. 06 4月, 2018 1 次提交
  11. 26 3月, 2018 1 次提交
    • R
      tcg: Really fix cpu_io_recompile · 87f963be
      Richard Henderson 提交于
      We have confused the number of instructions that have been
      executed in the TB with the number of instructions needed
      to repeat the I/O instruction.
      
      We have used cpu_restore_state_from_tb, which means that
      the guest pc is pointing to the I/O instruction.  The only
      time the answer to the later question is not 1 is when
      MIPS or SH4 need to re-execute the branch for the delay
      slot as well.
      
      We must rely on cpu->cflags_next_tb to generate the next TB,
      as otherwise we have a race condition with other guest cpus
      within the TB cache.
      
      Fixes: 0790f868Signed-off-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20180319031545.29359-1-richard.henderson@linaro.org>
      Tested-by: NPavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      87f963be
  12. 13 3月, 2018 1 次提交
  13. 12 3月, 2018 1 次提交
    • P
      cpu-exec: fix exception_index handling · 5f3bdfd4
      Pavel Dovgalyuk 提交于
      Function cpu_handle_interrupt calls cc->cpu_exec_interrupt to process
      pending hardware interrupts. Under the hood cpu_exec_interrupt uses
      cpu->exception_index to pass information to the internal function which
      is usually common for exception and interrupt processing.
      But this value is not reset after return and may be processed again
      by cpu_handle_exception. This does not happen due to overwriting
      the exception_index at the end of cpu_handle_interrupt.
      But this branch may also overwrite the valid exception_index in some cases.
      Therefore this patch:
       1. resets exception_index just after the call to cpu_exec_interrupt
       2. prevents overwriting the meaningful value of exception_index
      Signed-off-by: NPavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20180227095140.1060.61357.stgit@pasha-VirtualBox>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
      5f3bdfd4
  14. 08 2月, 2018 6 次提交
  15. 06 2月, 2018 1 次提交
  16. 25 1月, 2018 1 次提交
    • L
      accel/tcg: add size paremeter in tlb_fill() · 98670d47
      Laurent Vivier 提交于
      The MC68040 MMU provides the size of the access that
      triggers the page fault.
      
      This size is set in the Special Status Word which
      is written in the stack frame of the access fault
      exception.
      
      So we need the size in m68k_cpu_unassigned_access() and
      m68k_cpu_handle_mmu_fault().
      
      To be able to do that, this patch modifies the prototype of
      handle_mmu_fault handler, tlb_fill() and probe_write().
      do_unassigned_access() already includes a size parameter.
      
      This patch also updates handle_mmu_fault handlers and
      tlb_fill() of all targets (only parameter, no code change).
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      Reviewed-by: NDavid Hildenbrand <david@redhat.com>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20180118193846.24953-2-laurent@vivier.eu>
      98670d47
  17. 23 1月, 2018 2 次提交
    • P
      page_unprotect(): handle calls to pages that are PAGE_WRITE · 9c4bbee9
      Peter Maydell 提交于
      If multiple guest threads in user-mode emulation write to a
      page which QEMU has marked read-only because of cached TCG
      translations, the threads can race in page_unprotect:
      
       * threads A & B both try to do a write to a page with code in it at
         the same time (ie which we've made non-writeable, so SEGV)
       * they race into the signal handler with this faulting address
       * thread A happens to get to page_unprotect() first and takes the
         mmap lock, so thread B sits waiting for it to be done
       * A then finds the page, marks it PAGE_WRITE and mprotect()s it writable
       * A can then continue OK (returns from signal handler to retry the
         memory access)
       * ...but when B gets the mmap lock it finds that the page is already
         PAGE_WRITE, and so it exits page_unprotect() via the "not due to
         protected translation" code path, and wrongly delivers the signal
         to the guest rather than just retrying the access
      
      In particular, this meant that trying to run 'javac' in user-mode
      emulation would fail with a spurious guest SIGSEGV.
      
      Handle this by making page_unprotect() assume that a call for a page
      which is already PAGE_WRITE is due to a race of this sort and return
      a "fault handled" indication.
      
      Since this would cause an infinite loop if we ever called
      page_unprotect() for some other kind of fault than "write failed due
      to bad access permissions", tighten the condition in
      handle_cpu_signal() to check the signal number and si_code, and add a
      comment so that if somebody does ever find themselves debugging an
      infinite loop of faults they have some clue about why.
      
      (The trick for identifying the correct setting for
      current_tb_invalidated for thread B (needed to handle the precise-SMC
      case) is due to Richard Henderson.  Paolo Bonzini suggested just
      relying on si_code rather than trying anything more complicated.)
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-Id: <1511879725-9576-3-git-send-email-peter.maydell@linaro.org>
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      9c4bbee9
    • P
      linux-user: Propagate siginfo_t through to handle_cpu_signal() · a78b1299
      Peter Maydell 提交于
      Currently all the architecture/OS specific cpu_signal_handler()
      functions call handle_cpu_signal() without passing it the
      siginfo_t. We're going to want that so we can look at the si_code
      to determine whether this is a SEGV_ACCERR access violation or
      some other kind of fault, so change the functions to pass through
      the pointer to the siginfo_t rather than just the si_addr value.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <1511879725-9576-2-git-send-email-peter.maydell@linaro.org>
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      a78b1299
  18. 30 12月, 2017 1 次提交
  19. 21 12月, 2017 1 次提交
    • D
      cpu-exec: fix missed CPU kick during interrupt injection · d84be02d
      David Hildenbrand 提交于
      The conditional memory barrier not only looks strange but actually is
      wrong.
      
      On s390x, I can reproduce interrupts via cpu_interrupt() not leading to
      a proper kick out of emulation every now and then. cpu_interrupt() is
      especially used for inter CPU communication via SIGP (esp. external
      calls and emergency interrupts).
      
      With this patch, I was not able to reproduce. (esp. no stalls or hangs
      in the guest).
      
      My setup is s390x MTTCG with 16 VCPUs on 8 CPU host, running make -j16.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20171129191319.11483-1-david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d84be02d
  20. 18 12月, 2017 3 次提交
  21. 21 11月, 2017 1 次提交
    • P
      accel/tcg: Handle atomic accesses to notdirty memory correctly · 34d49937
      Peter Maydell 提交于
      To do a write to memory that is marked as notdirty, we need
      to invalidate any TBs we have cached for that memory, and
      update the cpu physical memory dirty flags for VGA and migration.
      The slowpath code in notdirty_mem_write() does all this correctly,
      but the new atomic handling code in atomic_mmu_lookup() doesn't
      do anything at all, it just clears the dirty bit in the TLB.
      
      The effect of this bug is that if the first write to a notdirty
      page for which we have cached TBs is by a guest atomic access,
      we fail to invalidate the TBs and subsequently will execute
      incorrect code. This can be seen by trying to run 'javac' on AArch64.
      
      Use the new notdirty_call_before() and notdirty_call_after()
      functions to correctly handle the update to notdirty memory
      in the atomic codepath.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-id: 1511201308-23580-3-git-send-email-peter.maydell@linaro.org
      34d49937
  22. 20 11月, 2017 1 次提交
  23. 15 11月, 2017 1 次提交
  24. 14 11月, 2017 2 次提交
  25. 13 11月, 2017 1 次提交
  26. 03 11月, 2017 1 次提交
  27. 25 10月, 2017 1 次提交