1. 03 3月, 2017 2 次提交
  2. 28 1月, 2017 1 次提交
    • P
      x86-KVM: Supply TSC and APIC clock rates to guest like VMWare · 9954a158
      Phil Dennis-Jordan 提交于
      This fixes timekeeping of x86-64 Darwin/OS X/macOS guests when using KVM.
      
      Darwin/OS X/macOS for x86-64 uses the TSC for timekeeping; it normally calibrates this by querying various clock frequency scaling MSRs. Details depend on the exact CPU model detected. The local APIC timer frequency is extracted from (EFI) firmware.
      
      This is problematic in the presence of virtualisation, as the MSRs in question are typically not handled by the hypervisor. VMWare (Fusion) advertises TSC and APIC frequency via a custom 0x40000010 CPUID leaf, in the eax and ebx registers respectively. This is documented at https://lwn.net/Articles/301888/ among other places.
      
      Darwin/OS X/macOS looks for the generic 0x40000000 hypervisor leaf, and if this indicates via eax that leaf 0x40000010 might be available, that is in turn queried for the two frequencies.
      
      This adds a CPU option "vmware-cpuid-freq" to enable the same behaviour when running Qemu with KVM acceleration, if the KVM TSC frequency can be determined, and it is stable. (invtsc or user-specified) The virtualised APIC bus cycle is hardcoded to 1GHz in KVM, so ebx of the CPUID leaf is also hardcoded to this value.
      Signed-off-by: NPhil Dennis-Jordan <phil@philjordan.eu>
      Message-Id: <1484921496-11257-2-git-send-email-phil@philjordan.eu>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9954a158
  3. 25 1月, 2017 1 次提交
  4. 24 1月, 2017 2 次提交
  5. 20 1月, 2017 1 次提交
  6. 22 12月, 2016 1 次提交
  7. 21 12月, 2016 1 次提交
    • T
      Move target-* CPU file into a target/ folder · fcf5ef2a
      Thomas Huth 提交于
      We've currently got 18 architectures in QEMU, and thus 18 target-xxx
      folders in the root folder of the QEMU source tree. More architectures
      (e.g. RISC-V, AVR) are likely to be included soon, too, so the main
      folder of the QEMU sources slowly gets quite overcrowded with the
      target-xxx folders.
      To disburden the main folder a little bit, let's move the target-xxx
      folders into a dedicated target/ folder, so that target-xxx/ simply
      becomes target/xxx/ instead.
      
      Acked-by: Laurent Vivier <laurent@vivier.eu> [m68k part]
      Acked-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> [tricore part]
      Acked-by: Michael Walle <michael@walle.cc> [lm32 part]
      Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> [s390x part]
      Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> [s390x part]
      Acked-by: Eduardo Habkost <ehabkost@redhat.com> [i386 part]
      Acked-by: Artyom Tarasenko <atar4qemu@gmail.com> [sparc part]
      Acked-by: Richard Henderson <rth@twiddle.net> [alpha part]
      Acked-by: Max Filippov <jcmvbkbc@gmail.com> [xtensa part]
      Reviewed-by: David Gibson <david@gibson.dropbear.id.au> [ppc part]
      Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> [cris&microblaze part]
      Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn> [unicore32 part]
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      fcf5ef2a
  8. 09 11月, 2016 1 次提交
  9. 31 10月, 2016 1 次提交
  10. 25 10月, 2016 1 次提交
  11. 18 10月, 2016 2 次提交
    • R
      target-i386/kvm: cache the return value of kvm_enable_x2apic() · 2a138ec3
      Radim Krčmář 提交于
      Assume that KVM would have returned the same on subsequent runs.
      Abstract the memoizaiton pattern into macros and call it memorize as
      adding the r makes it less obscure.
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      2a138ec3
    • R
      intel_iommu: reject broken EIM · fb506e70
      Radim Krčmář 提交于
      Cluster x2APIC cannot work without KVM's x2apic API when the maximal
      APIC ID is greater than 8 and only KVM's LAPIC can support x2APIC, so we
      forbid other APICs and also the old KVM case with less than 9, to
      simplify the code.
      
      There is no point in enabling EIM in forbidden APICs, so we keep it
      enabled only for the KVM APIC;  unconditionally, because making the
      option depend on KVM version would be a maintanance burden.
      
      Old QEMUs would enable eim whenever intremap was on, which would trick
      guests into thinking that they can enable cluster x2APIC even if any
      interrupt destination would get clamped to 8 bits.
      Depending on your configuration, QEMU could notice that the destination
      LAPIC is not present and report it with a very non-obvious:
      
        KVM: injection failed, MSI lost (Operation not permitted)
      
      Or the guest could say something about unexpected interrupts, because
      clamping leads to aliasing so interrupts were being delivered to
      incorrect VCPUs.
      
      KVM_X2APIC_API is the feature that allows us to enable EIM for KVM.
      
      QEMU 2.7 allowed EIM whenever interrupt remapping was enabled.  In order
      to keep backward compatibility, we again allow guests to misbehave in
      non-obvious ways, and make it the default for old machine types.
      
      A user can enable the buggy mode it with "x-buggy-eim=on".
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
      Reviewed-by: NPeter Xu <peterx@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      fb506e70
  12. 28 9月, 2016 4 次提交
  13. 27 9月, 2016 1 次提交
    • A
      cpus: pass CPUState to run_on_cpu helpers · e0eeb4a2
      Alex Bennée 提交于
      CPUState is a fairly common pointer to pass to these helpers. This means
      if you need other arguments for the async_run_on_cpu case you end up
      having to do a g_malloc to stuff additional data into the routine. For
      the current users this isn't a massive deal but for MTTCG this gets
      cumbersome when the only other parameter is often an address.
      
      This adds the typedef run_on_cpu_func for helper functions which has an
      explicit CPUState * passed as the first parameter. All the users of
      run_on_cpu and async_run_on_cpu have had their helpers updated to use
      CPUState where available.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      [Sergey Fedorov:
       - eliminate more CPUState in user data;
       - remove unnecessary user data passing;
       - fix target-s390x/kvm.c and target-s390x/misc_helper.c]
      Signed-off-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Acked-by: David Gibson <david@gibson.dropbear.id.au> (ppc parts)
      Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> (s390 parts)
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Message-Id: <1470158864-17651-3-git-send-email-alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e0eeb4a2
  14. 23 9月, 2016 1 次提交
  15. 22 9月, 2016 2 次提交
    • D
      kvm: apic: set APIC base as part of kvm_apic_put · f8d9ccf8
      Dr. David Alan Gilbert 提交于
      The parsing of KVM_SET_LAPIC's input depends on the current value of the
      APIC base MSR---which indeed is stored in APICCommonState---but for historical
      reasons APIC base is set through KVM_SET_SREGS together with cr8 (which is
      really just the APIC TPR) and the actual "special CPU registers".
      
      APIC base must now be set before the actual LAPIC registers, so do that
      in kvm_apic_put.  It will be set again to the same value with KVM_SET_SREGS,
      but that's not a big issue.
      
      This only happens since Linux 4.8, which checks for x2apic mode in
      KVM_SET_LAPIC.  However it's really a QEMU bug; until the recent
      commit 78d6a05d ("x86/lapic: Load LAPIC state at post_load", 2016-09-13)
      QEMU was indeed setting APIC base (via KVM_SET_SREGS) before the other
      LAPIC registers.
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f8d9ccf8
    • P
      target-i386: introduce kvm_put_one_msr · 73e1b8f2
      Paolo Bonzini 提交于
      Avoid further code duplication in the next patch.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      73e1b8f2
  16. 14 9月, 2016 1 次提交
  17. 16 8月, 2016 1 次提交
  18. 08 8月, 2016 1 次提交
  19. 22 7月, 2016 5 次提交
  20. 20 7月, 2016 2 次提交
  21. 08 7月, 2016 3 次提交
  22. 20 6月, 2016 1 次提交
    • E
      coccinelle: Remove unnecessary variables for function return value · 9be38598
      Eduardo Habkost 提交于
      Use Coccinelle script to replace 'ret = E; return ret' with
      'return E'. The script will do the substitution only when the
      function return type and variable type are the same.
      
      Manual fixups:
      
      * audio/audio.c: coding style of "read (...)" and "write (...)"
      * block/qcow2-cluster.c: wrap line to make it shorter
      * block/qcow2-refcount.c: change indentation of wrapped line
      * target-tricore/op_helper.c: fix coding style of
        "remainder|quotient"
      * target-mips/dsp_helper.c: reverted changes because I don't
        want to argue about checkpatch.pl
      * ui/qemu-pixman.c: fix line indentation
      * block/rbd.c: restore blank line between declarations and
        statements
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1465855078-19435-4-git-send-email-ehabkost@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [Unused Coccinelle rule name dropped along with a redundant comment;
      whitespace touched up in block/qcow2-cluster.c; stale commit message
      paragraph deleted]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9be38598
  23. 17 6月, 2016 2 次提交
    • C
      target-i386: kvm: cache KVM_GET_SUPPORTED_CPUID data · 494e95e9
      Chao Peng 提交于
      KVM_GET_SUPPORTED_CPUID ioctl is called frequently when initializing
      CPU. Depends on CPU features and CPU count, the number of calls can be
      extremely high which slows down QEMU booting significantly. In our
      testing, we saw 5922 calls with switches:
      
          -cpu SandyBridge -smp 6,sockets=6,cores=1,threads=1
      
      This ioctl takes more than 100ms, which is almost half of the total
      QEMU startup time.
      
      While for most cases the data returned from two different invocations
      are not changed, that means, we can cache the data to avoid trapping
      into kernel for the second time. To make sure the cache safe one
      assumption is desirable: the ioctl is stateless. This is not true for
      CPUID leaves in general (such as CPUID leaf 0xD, whose value depends
      on guest XCR0 and IA32_XSS) but it is true of KVM_GET_SUPPORTED_CPUID,
      which runs before there is a value for XCR0 and IA32_XSS.
      Signed-off-by: NChao Peng <chao.p.peng@linux.intel.com>
      Message-Id: <1465784487-23482-1-git-send-email-chao.p.peng@linux.intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      494e95e9
    • P
      os-posix: include sys/mman.h · 02d0e095
      Paolo Bonzini 提交于
      qemu/osdep.h checks whether MAP_ANONYMOUS is defined, but this check
      is bogus without a previous inclusion of sys/mman.h.  Include it in
      sysemu/os-posix.h and remove it from everywhere else.
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      02d0e095
  24. 29 5月, 2016 1 次提交
  25. 24 5月, 2016 1 次提交