summaryrefslogtreecommitdiff
path: root/target-i386/kvm.c
AgeCommit message (Collapse)AuthorFilesLines
2012-12-17pci: update all users to look in pci/Michael S. Tsirkin1-1/+1
update all users so we can remove the makefile hack. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-12-14target-i386: Enabling IA32_TSC_ADJUST for QEMU KVM guest VMsWill Auld1-0/+14
CPUID.7.0.EBX[1]=1 indicates IA32_TSC_ADJUST MSR 0x3b is supported Basic design is to emulate the MSR by allowing reads and writes to the hypervisor vcpu specific locations to store the value of the emulated MSRs. In this way the IA32_TSC_ADJUST value will be included in all reads to the TSC MSR whether through rdmsr or rdtsc. As this is a new MSR that the guest may access and modify its value needs to be migrated along with the other MRSs. The changes here are specifically for recognizing when IA32_TSC_ADJUST is enabled in CPUID and code added for migrating its value. Signed-off-by: Will Auld <will.auld@intel.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-11-10kvm: avoid using cpu_single_envBlue Swirl1-10/+11
Pass around CPUArchState instead of using global cpu_single_env. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Reviewed-by: Andreas Färber <afaerber@suse.de>
2012-11-01Merge remote-tracking branch 'qemu-kvm/uq/master' into stagingAnthony Liguori1-62/+91
* qemu-kvm/uq/master: (28 commits) update-linux-headers.sh: Handle new kernel uapi/ directories target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID target-i386: cpu: make -cpu host/check/enforce code KVM-specific target-i386: make cpu_x86_fill_host() void Emulate qemu-kvms -no-kvm option Issue warning when deprecated -tdf option is used Issue warning when deprecated drive parameter boot=on|off is used Use global properties to emulate -no-kvm-pit-reinjection Issue warning when deprecated -no-kvm-pit is used Use machine options to emulate -no-kvm-irqchip cirrus_vga: allow configurable vram size target-i386: Add missing kvm cpuid feature name i386: cpu: add missing CPUID[EAX=7,ECX=0] flag names i386: kvm: filter CPUID leaf 7 based on GET_SUPPORTED_CPUID, too i386: kvm: reformat filter_features_for_kvm() code i386: kvm: filter CPUID feature words earlier, on cpu.c i386: kvm: mask cpuid_ext4_features bits earlier i386: kvm: mask cpuid_kvm_features earlier i386: kvm: x2apic is not supported without in-kernel irqchip i386: kvm: set CPUID_EXT_TSC_DEADLINE_TIMER on kvm_arch_get_supported_cpuid() ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-10-31target-i386: Pass X86CPU to kvm_handle_halt()Andreas Färber1-2/+5
Needed for moving interrupt_request and halted fields to CPUState. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-10-31target-i386: Pass X86CPU to kvm_get_mp_state()Andreas Färber1-4/+5
Needed for moving halted field to CPUState. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-10-31target-i386: Pass X86CPU to cpu_x86_inject_mce()Andreas Färber1-1/+1
Needed for changing run_on_cpu() argument to CPUState. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-10-31target-i386: Pass X86CPU to kvm_mce_inject()Andreas Färber1-3/+5
Needed for changing cpu_x86_inject_mce() argument to X86CPU. Signed-off-by: Andreas Färber <afaerber@suse.de> [AF: Rebased onto hwaddr]
2012-10-30i386: kvm: filter CPUID feature words earlier, on cpu.cEduardo Habkost1-18/+0
cpu.c contains the code that will check if all requested CPU features are available, so the filtering of KVM features must be there, so we can implement "check" and "enforce" properly. The only point where kvm_arch_init_vcpu() is called on i386 is: - cpu_x86_init() - x86_cpu_realize() (after cpu_x86_register() is called) - qemu_init_vcpu() - qemu_kvm_start_vcpu() - qemu_kvm_thread_fn() (on a new thread) - kvm_init_vcpu() - kvm_arch_init_vcpu() With this patch, the filtering will be done earlier, at: - cpu_x86_init() - cpu_x86_register() (before x86_cpu_realize() is called) Also, the KVM CPUID filtering will now be done at the same place where the TCG CPUID feature filtering is done. Later, the code can be changed to use the same filtering code for the "check" and "enforce" modes, as now the cpu.c code knows exactly which CPU features are going to be exposed to the guest (and much earlier). One thing I was worrying about when doing this is that kvm_arch_get_supported_cpuid() depends on kvm_irqchip_in_kernel(), and maybe the 'kvm_kernel_irqchip' global variable wasn't initialized yet at CPU creation time. But kvm_kernel_irqchip is initialized during kvm_init(), that is called very early (much earlier than the machine init function), and kvm_init() is already a requirement to run the GET_SUPPORTED_CPUID ioctl() (as kvm_init() initializes the kvm_state global variable). Side note: it would be nice to keep KVM-specific code inside kvm.c. The problem is that properly implementing -cpu check/enforce code (that's inside cpu.c) depends directly on the feature bit filtering done using kvm_arch_get_supported_cpuid(). Currently -cpu check/enforce is broken because it simply uses the host CPU feature bits instead of GET_SUPPORTED_CPUID, and we need to fix that. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: mask cpuid_ext4_features bits earlierEduardo Habkost1-2/+3
This way all the filtering by GET_SUPPORTED_CPUID is being done at the same place in the code. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: mask cpuid_kvm_features earlierEduardo Habkost1-2/+4
Instead of masking the KVM feature bits very late (while building the KVM_SET_CPUID2 data), mask it out on env->cpuid_kvm_features, at the same point where the other feature words are masked out. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: x2apic is not supported without in-kernel irqchipEduardo Habkost1-0/+7
This is necessary so that x2apic is not improperly enabled when the in-kernel irqchip is disabled. This won't generate a warning with "-cpu ...,check" because the current check/enforce code is broken (it checks the host CPU data directly, instead of using kvm_arch_get_supported_cpuid()), but it will be eventually fixed to properly report the missing x2apic flag. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: set CPUID_EXT_TSC_DEADLINE_TIMER on kvm_arch_get_supported_cpuid()Eduardo Habkost1-5/+8
This moves the CPUID_EXT_TSC_DEADLINE_TIMER CPUID flag hacking from kvm_arch_init_vcpu() to kvm_arch_get_supported_cpuid(). Full git grep for kvm_arch_get_supported_cpuid: kvm.h:uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, target-i386/cpu.c: x86_cpu_def->cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX); target-i386/cpu.c: *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX); target-i386/cpu.c: *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX); target-i386/cpu.c: *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX); target-i386/cpu.c: *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX); target-i386/cpu.c: *eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX); target-i386/cpu.c: *ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX); target-i386/cpu.c: *ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX); target-i386/cpu.c: *edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX); target-i386/kvm.c:uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, target-i386/kvm.c: cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); target-i386/kvm.c: env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); * target-i386/kvm.c: env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX); target-i386/kvm.c: env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001, target-i386/kvm.c: env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001, target-i386/kvm.c: env->cpuid_svm_features &= kvm_arch_get_supported_cpuid(s, 0x8000000A, target-i386/kvm.c: kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX); target-i386/kvm.c: kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX); Note that there is only one call for CPUID[1].ECX above (*), and it is the one that gets hacked to include CPUID_EXT_TSC_DEADLINE_TIMER, so we can simply make kvm_arch_get_supported_cpuid() set it, to let the rest of the code know the flag can be safely set by QEMU. One thing I was worrying about when doing this is that now kvm_arch_get_supported_cpuid() depends on kvm_irqchip_in_kernel(). But the 'kvm_kernel_irqchip' global variable is initialized during kvm_init(), that is called very early, and kvm_init() is already a requirement to run the GET_SUPPORTED_CPUID ioctl() (as kvm_init() is the function that initializes the 'kvm_state' global variable). Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: set CPUID_EXT_HYPERVISOR on kvm_arch_get_supported_cpuid()Eduardo Habkost1-2/+5
Full grep for kvm_arch_get_supported_cpuid: kvm.h:uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, target-i386/cpu.c: x86_cpu_def->cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX); target-i386/cpu.c: *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX); target-i386/cpu.c: *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX); target-i386/cpu.c: *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX); target-i386/cpu.c: *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX); target-i386/cpu.c: *eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX); target-i386/cpu.c: *ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX); target-i386/cpu.c: *ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX); target-i386/cpu.c: *edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX); target-i386/kvm.c:uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, target-i386/kvm.c: cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); target-i386/kvm.c: env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); * target-i386/kvm.c: env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX); target-i386/kvm.c: env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001, target-i386/kvm.c: env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001, target-i386/kvm.c: env->cpuid_svm_features &= kvm_arch_get_supported_cpuid(s, 0x8000000A, target-i386/kvm.c: kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX); target-i386/kvm.c: kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX); Note that there is only one call for CPUID[1].ECX above (*), and it is the one that gets hacked to include CPUID_EXT_HYPERVISOR, so we can simply make kvm_arch_get_supported_cpuid() set it, to let the rest of the code automatically know that the flag can be safely set by QEMU. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: kvm_arch_get_supported_cpuid: replace if+switch with single 'if'Eduardo Habkost1-14/+9
Additional fixups will be added, and making them a single 'if/else if' chain makes it clearer than two nested switch statements. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: extract try_get_cpuid() loop to get_supported_cpuid() functionEduardo Habkost1-5/+14
No behavior change, just code movement. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: extract CPUID entry lookup to cpuid_find_entry() functionEduardo Habkost1-8/+22
No behavior change, just code movement. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: extract register switch to cpuid_entry_get_reg() functionEduardo Habkost1-14/+23
No behavior change: just code movement. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: kvm_arch_get_supported_cpuid: use 'entry' variableEduardo Habkost1-4/+5
The reg switch will be moved to a separate function, so store the entry pointer in a variable. No behavior change, just code movement. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: kvm_arch_get_supported_cpuid: clean up has_kvm_features checkEduardo Habkost1-5/+3
Instead of a function-specific has_kvm_features variable, simply use a "found" variable that will be checked in case we have to use the legacy get_para_features() interface. No behavior change, just code cleanup. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-30i386: kvm: kvm_arch_get_supported_cpuid: move R_EDX hack outside of for loopEduardo Habkost1-13/+18
The for loop will become a separate function, so clean it up so it can become independent from the bit hacking for R_EDX. No behavior change[1], just code movement. [1] Well, only if the kernel returned CPUID leafs 1 or 0x80000001 as unsupported, but there's no kernel version that does that. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-31cpus: Pass CPUState to cpu_is_stopped()Andreas Färber1-2/+2
CPUArchState is no longer needed there. Also change the return type to bool. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-10-31cpus: Pass CPUState to qemu_cpu_is_self()Andreas Färber1-2/+4
Change return type to bool, move to include/qemu/cpu.h and add documentation. Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Igor Mammedov <imammedo@redhat.com> [AF: Updated new caller qemu_in_vcpu_thread()]
2012-10-23Rename target_phys_addr_t to hwaddrAvi Kivity1-3/+3
target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-30i386: kvm: use a #define for the set of alias feature bitsEduardo Habkost1-1/+1
Instea of using a hardcoded hex constant, define CPUID_EXT2_AMD_ALIASES as the set of CPUID[8000_0001].EDX bits that on AMD are the same as the bits of CPUID[1].EDX. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-By: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Don Slutz <Don@CloudSwitch.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-30i386: kvm: bit 10 of CPUID[8000_0001].EDX is reservedEduardo Habkost1-1/+1
Bit 10 of CPUID[8000_0001].EDX is not defined as an alias of CPUID[1].EDX[10], so do not duplicate it on kvm_arch_get_supported_cpuid(). Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-By: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Don Slutz <Don@CloudSwitch.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-10kvm: i386: Add services required for PCI device assignmentJan Kiszka1-0/+141
These helpers abstract the interaction of upcoming pci-assign with the KVM kernel services. Put them under i386 only as other archs will implement device pass-through via VFIO and not this classic interface. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-08-29kvm: get/set PV EOI MSRMichael S. Tsirkin1-0/+13
Support get/set of new PV EOI MSR, for migration. Add an optional section for MSR value - send it out in case MSR was changed from the default value (0). Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-09kvm: Decouple 'GSI routing' from 'kernel irqchip'Peter Maydell1-1/+2
Don't assume having an in-kernel irqchip means that GSI routing is enabled. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-08-09kvm: Decouple 'MSI routing via irqfds' from 'kernel irqchip'Peter Maydell1-1/+3
Decouple another x86-specific assumption about what irqchips imply. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-08-09kvm: Decouple 'irqfds usable' from 'kernel irqchip'Peter Maydell1-0/+4
Instead of assuming that we can use irqfds if and only if kvm_irqchip_in_kernel(), add a bool to the KVMState which indicates this, and is set only on x86 and only if the irqchip is in the kernel. The kernel documentation implies that the only thing you need to use KVM_IRQFD is that KVM_CAP_IRQFD is advertised, but this seems to be untrue. In particular the kernel does not (alas) return a sensible error if you try to set up an irqfd when you haven't created an irqchip. If it did we could remove all this nonsense and let the kernel return the error code. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-08-09kvm: Move kvm_allows_irq0_override() to target-i386, fix return typePeter Maydell1-0/+6
kvm_allows_irq0_override() is a totally x86 specific concept: move it to the target-specific source file where it belongs. This means we need a new header file for the prototype: kvm_i386.h, in line with the existing kvm_ppc.h. While we are moving it, fix the return type to be 'bool' rather than 'int'. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-08-01target-i386: move cpu halted decision into x86_cpu_resetIgor Mammedov1-1/+3
MP initialization protocol differs between cpu families, and for P6 and onward models it is up to CPU to decide if it will be BSP using this protocol, so try to model this. However there is no point in implementing MP initialization protocol in qemu. Thus first CPU is always marked as BSP. This patch: - moves decision to designate BSP from board into cpu, making cpu self-sufficient in this regard. Later it will allow to cleanup hw/pc.c and remove cpu_reset and wrappers from there. - stores flag that CPU is BSP in IA32_APIC_BASE to model behavior described in Inted SDM vol 3a part 1 chapter 8.4.1 - uses MSR_IA32_APICBASE_BSP flag in apic_base for checking if cpu is BSP patch is based on Jan Kiszka's proposal: http://thread.gmane.org/gmane.comp.emulators.qemu/100806 Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-07-10apic: Defer interrupt updates to VCPU threadJan Kiszka1-0/+4
KVM performs TPR raising asynchronously to QEMU, specifically outside QEMU's global lock. When an interrupt is injected into the APIC and TPR is checked to decide if this can be delivered, a stale TPR value may be used, causing spurious interrupts in the end. Fix this by deferring apic_update_irq to the context of the target VCPU. We introduce a new interrupt flag for this, CPU_INTERRUPT_POLL. When it is set, the VCPU calls apic_poll_irq before checking for further pending interrupts. To avoid special-casing KVM, we also implement this logic for TCG mode. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-07-03kvm: expose tsc deadline timer feature to guestLiu, Jinsong1-0/+5
This patch exposes tsc deadline timer feature to guest if 1). in-kernel irqchip is used, and 2). kvm has emulated tsc deadline timer, and 3). user authorize the feature exposing via -cpu or +/- tsc-deadline Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-06-04target-i386: Pass X86CPU to do_cpu_{init,sipi}()Andreas Färber1-2/+4
Allows to use cpu_reset() in place of cpu_state_reset(). Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
2012-03-14target-i386: Don't overuse CPUStateAndreas Färber1-38/+38
Scripted conversion: sed -i "s/CPUState/CPUX86State/g" target-i386/*.[hc] sed -i "s/#define CPUX86State/#define CPUState/" target-i386/cpu.h Signed-off-by: Andreas Färber <afaerber@suse.de> Acked-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-07kvm: fill in padding to help valgrindMichael S. Tsirkin1-0/+6
valgrind warns about padding fields which are passed to vcpu ioctls uninitialized. This is not an error in practice because kvm ignored padding. Since the ioctls in question are off data path and the cost is zero anyway, initialize padding to 0 to suppress these errors. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-02-18target-i386: Add infrastructure for reporting TPR MMIO accessesJan Kiszka1-2/+23
This will allow the APIC core to file a TPR access report. Depending on the accelerator and kernel irqchip mode, it will either be delivered right away or queued for later reporting. In TCG mode, we can restart the triggering instruction and can therefore forward the event directly. KVM does not allows us to restart, so we postpone the delivery of events recording in the user space APIC until the current instruction is completed. Note that KVM without in-kernel irqchip will report the address after the instruction that triggered the access. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-02-16kvm: Synchronize cpu state in kvm_arch_stop_on_emulation_error()Gleb Natapov1-0/+1
Call to kvm_cpu_synchronize_state() is missing. kvm_arch_stop_on_emulation_error may look at outdated registers here. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-02-08kvm: Implement kvm_irqchip_in_kernel like kvm_enabledJan Kiszka1-2/+2
To both avoid that kvm_irqchip_in_kernel always has to be paired with kvm_enabled and that the former ends up in a function call, implement it like the latter. This means keeping the state in a global variable and defining kvm_irqchip_in_kernel as a preprocessor macro. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-02-08kvm: Allow to set shadow MMU sizeJan Kiszka1-0/+13
Introduce the KVM-specific machine option kvm_shadow_mem. It allows to set a custom shadow MMU size for the virtual machine. This is useful for stress testing e.g. Only x86 supports this for now, but it is in principle a generic concept for all targets with shadow MMUs. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-01-19kvm: x86: Add user space part for in-kernel APICJan Kiszka1-0/+38
This introduces the alternative APIC device which makes use of KVM's in-kernel device model. External NMI injection via LINT1 is emulated by checking the current state of the in-kernel APIC, only injecting a NMI into the VCPU if LINT1 is unmasked and configured to DM_NMI. MSI is not yet supported, so we disable this when the in-kernel model is in use. CC: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-01-19kvm: Introduce core services for in-kernel irqchip supportJan Kiszka1-0/+11
Add the basic infrastructure to active in-kernel irqchip support, inject interrupts into these models, and maintain IRQ routes. Routing is optional and depends on the host arch supporting KVM_CAP_IRQ_ROUTING. When it's not available on x86, we looe the HPET as we can't route GSI0 to IOAPIC pin 2. In-kernel irqchip support will once be controlled by the machine property 'kernel_irqchip', but this is not yet wired up. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-01-19hyper-v: initialize Hyper-V CPUID leaves.Vadim Rozenfeld1-2/+63
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-01-03Merge remote-tracking branch 'qemu-kvm/memory/page_desc' into stagingAnthony Liguori1-4/+3
* qemu-kvm/memory/page_desc: (22 commits) Remove cpu_get_physical_page_desc() sparc: avoid cpu_get_physical_page_desc() virtio-balloon: avoid cpu_get_physical_page_desc() vhost: avoid cpu_get_physical_page_desc() kvm: avoid cpu_get_physical_page_desc() memory: remove CPUPhysMemoryClient xen: convert to MemoryListener API memory: temporarily add memory_region_get_ram_addr() xen, vga: add API for registering the framebuffer vhost: convert to MemoryListener API kvm: convert to MemoryListener API kvm: switch kvm slots to use host virtual address instead of ram_addr_t memory: add API for observing updates to the physical memory map memory: replace cpu_physical_sync_dirty_bitmap() with a memory API framebuffer: drop use of cpu_physical_sync_dirty_bitmap() loader: remove calls to cpu_get_physical_page_desc() framebuffer: drop use of cpu_get_physical_page_desc() memory: introduce memory_region_find() memory: add memory_region_is_logging() memory: add memory_region_is_rom() ...
2011-12-22kvm: x86: Drop redundant apic base and tpr update from kvm_get_sregsJan Kiszka1-3/+2
The latter was already commented out, the former is redundant as well. We always get the latest changes after return from the guest via kvm_arch_post_run. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-12-22kvm: x86: Avoid runtime allocation of xsave bufferJan Kiszka1-8/+7
Keep a per-VCPU xsave buffer for kvm_put/get_xsave instead of continuously allocating and freeing it on state sync. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-12-22kvm: x86: Use symbols for all xsave fieldJan Kiszka1-6/+8
Field 0 (FCW+FSW) and 1 (FTW+FOP) were hard-coded so far. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-12-20kvm: switch kvm slots to use host virtual address instead of ram_addr_tAvi Kivity1-4/+3
This simplifies a later switch to the memory API in slot management. Signed-off-by: Avi Kivity <avi@redhat.com>