kvm: x86: Swallow KVM_EXIT_SET_TPR
This exit only triggers activity in the common exit path, but we shouldaccept it in order to be able to detect unknown exit types.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: Stop on all fatal exit reasons
Ensure that we stop the guest whenever we face a fatal or unknown exitreason. If we stop, we also have to enforce a cpu loop exit.
Clean up cpu_inject_x86_mce()
Clean up cpu_inject_x86_mce() for later patch.
Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Add "broadcast" option for mce command
When the following test case is injected with mce command, maybe user could notget the expected result. DATA command cpu bank status mcg_status addr misc (qemu) mce 1 1 0xbd00000000000000 0x05 0x1234 0x8c...
Add function for checking mca broadcast of CPU
Add function for checking whether current CPU support mca broadcast.
kvm: introduce kvm_mce_in_progress
Share same error handing, and rename this function afterMCIP (Machine Check In Progress) flag.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>...
kvm: kvm_mce_inj_* subroutines for templated error injections
Refactor codes for maintainability.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: introduce kvm_inject_x86_mce_on
Pass a table instead of multiple args.
Note:
kvm_inject_x86_mce(env, bank, status, mcg_status, addr, misc, abort_on_error);
is equal to:
struct kvm_x86_mce mce = { .bank = bank,...
kvm: x86: Fix DPL write back of segment registers
The DPL is stored in the flags and not in the selector. In fact, the RPLmay differ from the DPL at some point in time, and so we were corruptingthe guest state so far.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: x86: Remove obsolete SS.RPL/DPL aligment
This seems to date back to the days KVM didn't support real mode. Thecheck is no longer needed and, even worse, is corrupting the guest statein case SS.RPL != DPL.
kvm: x86: Prevent sign extension of DR7 in guest debugging mode
This unbreaks guest debugging when the 4th hardware breakpoint used forguest debugging is a watchpoint of 4 or 8 byte lenght. The 31st bit ofDR7 is set in that case and used to cause a sign extension to the high...
kvm: x86: Fix a few coding style violations
No functional changes.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: Enable user space NMI injection for kvm guest
Make use of the new KVM_NMI IOCTL to send NMIs into the KVM guest if theuser space raised them. (example: qemu monitor's "nmi" command)
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>Acked-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: convert kvm_ioctl(KVM_CHECK_EXTENSION) to kvm_check_extension()
simple cleanup and use existing helper: kvm_check_extension().
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
target-i386: Use deposit operation.
Use this for assignment to the low byte or low word of a register.
Acked-by: Aurelien Jarno <aurelien@aurel32.net>Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
x86: Filter out garbage from segment flags dump
Only bits 8..23 of the segment flags contain valid data, so only dumpthose when printing the CPU state.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
target-i386: Fix accidental use of SoftFloat uint64 type
softfloat.h's uint64 type has least-width semantics.Use uint64_t instead since that is used in helpers.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>...
Add support for async page fault to qemu
Add save/restore of MSR for migration and cpuid bit.
Signed-off-by: Gleb Natapov <gleb@redhat.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
target-xxx: Use fprintf_function (format checking)
fprintf_function uses format checking with GCC_FMT_ATTR.
Cc: Blue Swirl <blauwirbel@gmail.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
kvm: save/restore x86-64 MSRs on x86-64 kernels
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: writeback SMP TSCs on migration only
commit 6389c45441269baa2873e6feafebd17105ddeaf6Author: Jan Kiszka <jan.kiszka@siemens.com>Date: Mon Mar 1 18:17:26 2010 +0100
qemu-kvm: Cleanup/fix TSC and PV clock writeback
kvm: factor out kvm_has_msr_star
And add kvm_has_msr_hsave_pa(), to avoid warnings on olderkernels without support.
kvm: add save/restore of MSR_VM_HSAVE_PA
commit 2bba4446746add456ceeb0e8359a43032a2ea333Author: Alexander Graf <agraf@suse.de>Date: Thu Dec 18 15:38:32 2008 +0100
Enable nested SVM support in userspace
Fix build on !KVM_CAP_MCE
This patch removes following warnings:
target-i386/kvm.c: In function 'kvm_put_msrs':target-i386/kvm.c:782: error: unused variable 'i'target-i386/kvm.c: In function 'kvm_get_msrs':target-i386/kvm.c:1083: error: label at end of compound statement...
x86, mce: broadcast mce depending on the cpu version
There is no reason why SRAO event received by the main threadis the only one that being broadcasted.
According to the x86 ASDM vol.3A 15.10.4.1,MCE signal is broadcast on processor version 06H_EH or later....
x86, mce: ignore SRAO only when MCG_SER_P is available
And restruct this block to call kvm_mce_in_exception() only when it isrequired.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Set cpuid definition to 0 before initializing it
This patch cleans the (stack-allocated) cpuid definition to0 before actually initializing it.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>Signed-off-by: Avi Kivity <avi@redhat.com>
Add svm cpuid features
This patch adds the svm cpuid feature flags to the qemuintialization path. It also adds the svm features availableon phenom to its cpu-definition and extends the host cputype to support all svm features KVM can provide.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>...
kvm: x86: add mce support
Port qemu-kvm's MCE support
commit c68b2374c9048812f488e00ffb95db66c0bc07a7Author: Huang Ying <ying.huang@intel.com>Date: Mon Jul 20 10:00:53 2009 +0800
Add MCE simulation support to qemu/kvm
KVM ioctls are used to initialize MCE simulation and inject MCE. The...
MCE: Relay UCR MCE to guest
Port qemu-kvm's
commit 4b62fff1101a7ad77553147717a8bd3bf79df7efAuthor: Huang Ying <ying.huang@intel.com>Date: Mon Sep 21 10:43:25 2009 +0800
UCR (uncorrected recovery) MCE is supported in recent Intel CPUs,...
Add savevm/loadvm support for MCE
commit 1bab5d11545d8de5facf46c28630085a2f9651aeAuthor: Huang Ying <ying.huang@intel.com>Date: Wed Mar 3 16:52:46 2010 +0800
MCE registers are saved/load into/from CPUState in...
Fix memory leak in register save load due to xsave support
From: Avi Kivity <avi@redhat.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
i386: avoid a write only variable
Compiling with GCC 4.6.0 20100925 produced warnings:/src/qemu/target-i386/op_helper.c: In function 'switch_tss':/src/qemu/target-i386/op_helper.c:283:53: error: variable 'new_trap' set but not used [-Werror=unused-but-set-variable]...
QemuOpts: make most qemu_*_opts static
Switch tree to lookup-by-name using qemu_find_opts().Also hook up virtfs options so qemu_find_opts works for them too.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
target-i386: svm: Fix MSRPM check
Correct the calculation of the offset in the msrpmfor the MSR range 0 - 0x1fff.
Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Use ARRAY_SIZE macro
Replace array size calculations with ARRAY_SIZE macro.
Implemented with this Coccinelle semantic patch, adapted fromLinux kernel:@type T;T[] E;@
@type T;T[] E;
- (sizeof(E)/sizeof(*E))+ ARRAY_SIZE(E)
@type T;T[] E;@
- (sizeof(E)/sizeof(E[...]))...
target-i386: use gen_update_cc_op()
This patch simplifies target-i386/translate.c a bit by replacing somecode with gen_update_cc_op()
Signed-off-by: Jun Koi <junkoi2004@gmail.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
use symbol for DisasContext->is_jmp
This patch replaces constant value assigned for (DisasContext*)->is_jmp with DISAS_TB_JUMP.
Signed-off-by: Jun Koi <junkoi2004@gmail.com>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
remove exec-all.h inclusion from cpu.h
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
move cpu_pc_from_tb to target-*/exec.h
remove unused stuff from */exec.h
Don't declare XSAVE as supported
i386 cpuid.c currently claims XSAVE is supported in the CPUID filter,but that's not true: Only FXSAVE is supported. Remove that bitfrom the filter.
Signed-off-by: Andi Kleen <ak@linux.intel.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Add more boundary checking to sse3/4 parsing
ssse3 uses tables with only two entries per op, but it is indexedwith b1 which can contain variables upto 3. This happens when ssse3or sse4 are used with REP* prefixes.
Add boundary checking for this case....
target-i386: fix xchg rax,r8
We were ignoring REX_B while special-casing NOP, i.e. xchg eax,eax.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
x86: svm: Always clear event_inj on vmexit
We currently only clear SVM_EVTINJ_VALID after successful interruptdelivery. This apparently does not match real hardware which clears thewhole event_inj field on every vmexit, including unsuccessful interrupt...
fix CPUID vendor override
the meaning of vendor_override is actually the opposite of how itis currently used :-(Fix it to allow KVM to export the non-native CPUID vendor ifexplicitly requested by the user.
The intended behavior is:With TCG: - always inject the configured vendor (either hard-coded, in config...
kvm: Extend kvm_arch_get_supported_cpuid() to support index
Would use it later for XSAVE related CPUID.
Signed-off-by: Sheng Yang <sheng@linux.intel.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Enable XSAVE related CPUID
We can support it in KVM now. The 0xd leaf is queried from KVM.
kvm: Enable XSAVE live migration support
kvm: init mp_state
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: Fix cpu_is_bsp() compilation warning
Signed-off-by: Sheng Yang <sheng@linux.intel.com>Signed-off-by: Avi Kivity <avi@redhat.com>
x86: Fix INIT processing
This fixes a regression of 0e26b7b892: Reset halted also on INIT.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
apic: qdev conversion cleanup
Make APICState completely private to apic.c by using DeviceStatein external APIs.
Move apic_init() to pc.c.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
apic: avoid using CPUState internals
Move the actual CPUState contents handling to cpu.h and cpuid.c.
Handle CPU reset and set env->halted in pc.c.
Add a function to get the local APIC state of the currentCPU for the MMIO.
apic: avoid passing CPUState from CPU code
Pass only APICState when accessing APIC from CPU code.
tcg: Optionally sign-extend 32-bit arguments for 64-bit hosts.
Some hosts (amd64, ia64) have an ABI that ignores the high bitsof the 64-bit register when passing 32-bit arguments. Othersrequire the value to be properly sign-extended for the type.I.e. "int32_t" must be sign-extended and "uint32_t" must be...
target-i386: fix decoding of negative 4-byte displacements
Negative four byte displacements need to be sign-extended afterc086b783eb7a578993d6d2ab62c4c2666800b63d. Do so.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Acked-by: Richard Henderson <rth@twiddle.net>...
resent: x86/cpuid: Add kvm32 CPU model
Create a kvm32 CPU model that describes a least common denominatorfor KVM capable guest CPUs. Useful for migration purposes.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: fix 80000001.EDX supported bit filtering
On AMD some bits from 1.EDX are reported in 80000001.EDX. The mask usedto copy bits from 1.EDX to 80000001.EDX is incorrect resulting inunsupported features passed into a guest.
Signed-off-by: Gleb Natapov <gleb@redhat.com>...
Do not stop VM if emulation failed in userspace.
Continue vcpu execution in case emulation failure happened while vcpuwas in userspace. In this case #UD will be injected into the guestallowing guest OS to kill offending process and continue.
kvm: validate context for kvm cpu get/put operations
Validate that KVM vcpu state is only read/written from cpu thread itselfor that cpu is stopped.
kvm: enable smp > 1
Process INIT/SIPI requests and enable -smp > 1.
target-i386: Remove duplicate CPU log.
The proper logging for -d cpu is done in generic code.
KVM: x86: Add debug register saving and restoring
Make use of the new KVM_GET/SET_DEBUGREGS to save/restore the x86 debugregisters.
target-i386: print EFER in cpu_dump_state
kvm: allow qemu to set EPT identity mapping address
If we use larger BIOS image than current 256KB, we would need move reservedTSS and EPT identity mapping pages. Currently TSS support this, but notEPT.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>...
x86: remove dead assignments, spotted by clang analyzer
Value stored is never read.
kvm: avoid collision with dprintf macro in stdio.h, spotted by clang
Fixes clang errors: CC i386-softmmu/kvm.o/src/qemu/target-i386/kvm.c:40:9: error: 'dprintf' macro redefinedIn file included from /src/qemu/target-i386/kvm.c:21:In file included from /src/qemu/qemu-common.h:27:...
target-i386: Fix variable in (disabled) debugging code
Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
target-i386: Fix compiler warning
With argument checking for cpu_fprintf, gcc throws this warning:
CC i386-softmmu/helper.occ1: warnings being treated as errors/qemu/ar7/target-i386/helper.c: In function ‘cpu_x86_dump_seg_cache’:/qemu/ar7/target-i386/helper.c:220: error: format not a string literal and no format arguments...
remove TARGET_* defines from translate-all.c
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Large page TLB flush
QEMU uses a fixed page size for the CPU TLB. If the guest uses largepages then we effectively split these into multiple smaller pages, andpopulate the corresponding TLB entries on demand.
When the guest invalidates the TLB by virtual address we must invalidate...
x86/cpuid: move CPUID functions into separate file
about half of target-i386/helper.c consist of CPUID related functions.Only one of them is a real TCG helper function. So move the wholeCPUID stuff out of this into a separate file to get bettermaintainable parts....
x86/cpuid: replace magic number with named constant
CPUID leaf Fn8000_0001.EDX contains a copy of many Fn0000_0001.EDX bits.Define a name for this mask to improve readability and avoid typos.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
x86/cpuid: fix missing feature set bits
This one was accidently removed with commitbb0300dc57c10b3721451b0ff566a03f9276cc77
x86/cpuid: moved host_cpuid function and remove prototype
the host_cpuid function was located at the end of the file and hada prototype before it's first use. Move it up and remove theprototype.
x86/cpuid: add missing CPUID feature flag names
Some CPUID feature flags had no string value, so they could not beswitched on or off from the command line.Add names for the missing ones mentioned in the current public CPUIDspecification from both Intel and AMD. Those only mentioned in the...
x86/cpuid: add "host" to the list of supported CPU models
x86/cpuid: remove unnecessary kvm_trim function
Correct me if I am wrong, but kvm_trim looks like a really bloatedimplementation of a bitwise AND. So remove this function and replaceit with the real stuff(TM).
Signed-off-by: Andre Przywara <andre.przywara@amd.com>...
x86/cpuid: add TCG feature bit trimming
In KVM we trim the user provided CPUID bits to match the host CPU'sone. Introduce a similar feature to QEMU/TCG. Create a mask of TCG'scapabilities and apply it to the user bits.This allows to let the CPU models reflect their native archetypes....
x86/cpuid: Always expose 32 and 64-bit CPUs
Since 64-bit capability is just another CPUID bit we now properlymask, there is no reason anymore to hide the 64-bit capable CPUmodels from a 32-bit only QEMU. All 64-bit CPUs can be usedperfectly in 32-bit legacy mode anyway, so these models also make...
x86/cpuid: fix CPUID levels
Bump up the xlevel number for qemu32 to allow parsing of the processorname string for this model.Similiarly the 486 processor should have at least the feature bitleaf enabled.
x86/cpuid: Enable all features of real CPU
Enable all features of real CPU, unsupported features will betrimmed depending on TCG or KVM capabilities.
Move the list of unsupported TCG features near the TCG capabilitiesmasks.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
x86/cpuid: fix indentation
target-i386: fix commit c22549204a6edc431e8e4358e61bd56386ff6957
The commit c22549204a6edc431e8e4358e61bd56386ff6957 led movntps &movntdq to be translated incorrectly.
Signed-off-by: TeLeMan <geleman@gmail.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Remove cpu_get_phys_page_debug from userspace emulation
cpu_get_phys_page_debug makes no sense for userspace emulation, so remove it.
Signed-off-by: Paul Brook <paul@codesourcery.com>
Move TARGET_PHYS_ADDR_SPACE_BITS to target-*/cpu.h.
Removes a set of ifdefs from exec.c.
Introduce TARGET_VIRT_ADDR_SPACE_BITS for all targets otherthan Alpha. This will be used for page_find_alloc, which issupposed to be using virtual addresses in the first place....
target-i386: fix SIB decoding with index = 4
A SIB byte with an index of 4 means "no scaled index", even if the scalevalue is not 0. In 64-bit mode, if REX.X is used, an index of 4 selects%r12. This is correctly handled by the computation of the index variable,...
target-i386: Fix long jumps/calls in long mode with REX.W set
Signed-off-by: malc <av1474@comtv.ru>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
target-i386: fix lddqu SSE instruction
This instruction load data from memory to register and not the reverse.
KVM: x86: Restrict writeback of VCPU state
Do not write nmi_pending, sipi_vector, and mpstate unless we at least gothrough a reset. And TSC as well as KVM wallclocks should only bewritten on full sync, otherwise we risk to drop some time on stateread-modify-write....
KVM: Rework VCPU state writeback API
This grand cleanup drops all reset and vmsave/load relatedsynchronization points in favor of four(!) generic hooks:
- cpu_synchronize_all_states in qemu_savevm_state_complete (initial sync from kernel before vmsave)...
KVM: Rework of guest debug state writing
So far we synchronized any dirty VCPU state back into the kernel beforeupdating the guest debug state. This was a tribute to a deficite in x86kernels before 2.6.33. But as this is an arch-dependent issue, it isbetter handle in the x86 part of KVM and remove the writeback point for...
Move ioport.h out of cpu-all.h
Only include ioport.h where it is actually needed.
target-i386: fix crash on x86 32bit linux host with hw breakpoint exceptions
If you make use of hw breakpoints on a 32bit x86 linux host, qemuwill segmentation fault when processing the exception.
The problem is that the value of env is stored in $ebp in the op_helper...
Fix OpenBSD linker warning
helper.o(.text+0x11e0): In function `listflags':/src/qemu/target-i386/helper.c:661: warning: sprintf() is often misused, please use snprintf()
Fix i386-bsd-user build
Merge remote branch 'qemu-kvm/uq/master' into staging
Add cpu model configuration support..
This is a reimplementation of prior versions which addsthe ability to define cpu models for contemporary processors.The added models are likewise selected via -cpu <name>,and are intended to displace the existing convention...
kvm: Kill CR3_CACHE feature references
Remove all references to KVM_CR3_CACHE as it was never implemented.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Avi Kivity <avi@redhat.com>