History | View | Annotate | Download (31.9 kB)
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.
Signed-off-by: Gleb Natapov <gleb@redhat.com>...
kvm: synchronize state from cpu context
It is not safe to retrieve the KVM internal state of a given cpuwhile its potentially modifying it.
Queue the request to run on cpu context, similarly to qemu-kvm.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>...
kvm: enable smp > 1
Process INIT/SIPI requests and enable -smp > 1.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: set cpu_single_env around KVM_RUN ioctl
Zero cpu_single_env before leaving global lock protection, andrestore on return.
kvm: port qemu-kvm's bitmap scanning
Which is significantly faster.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
KVM: x86: Add debug register saving and restoring
Make use of the new KVM_GET/SET_DEBUGREGS to save/restore the x86 debugregisters.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: handle internal error
Port qemu-kvm's KVM_EXIT_INTERNAL_ERROR handling to upstream.
provide a stub version of kvm-all.c if !CONFIG_KVM
This allows limited use of kvm functions (which will return ENOSYS)even in once-compiled modules. The patch also improves a bit the errormessages for KVM initialization.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
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:...
S390: Tell user why VM creation failed
The KVM kernel module on S390 refuses to create a VM when the switch_amodekernel parameter is not used.
Since that is not exactly obvious, let's give the user a nice warning.
Signed-off-by: Alexander Graf <agraf@suse.de>...
kvm: add API to set ioeventfd
Comment on kvm usage: rather than require users to do if (kvm_enabled())and/or ifdefs, this patch adds an API that, internally, is defined tostub function on non-kvm build, and checks kvm_enabled for non-kvmrun.
While rest of qemu code still uses if (kvm_enabled()), I think this...
Move KVM and Xen global flags to vl.c
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
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...
kvm-all.c: define smp_wmb and use it for coalesced mmio
Acked-by: "Michael S. Tsirkin" <mst@redhat.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: consume internal signal with sigtimedwait
Change the way the internal qemu signal, used for communication betweeniothread and vcpus, is handled.
Block and consume it with sigtimedwait on the outer vcpu loop, whichallows more precise timing control....
kvm: remove pre-entry exit_request check with iothread enabled
With SIG_IPI blocked vcpu loop exit notification happens via -EAGAINfrom KVM_RUN.
kvm: reduce code duplication in config_iothread
We have some duplicated code in the CONFIG_IOTHREAD #ifdef and #elsecases. Fix that.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: move kvm_set_phys_mem around
move kvm_set_phys_mem so that it willbe later available earlier in the file.needed for next patch using memory notifiers.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Acked-by: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: move kvm to use memory notifiers
remove direct kvm calls from exec.c, makekvm use memory notifiers framework instead.
KVM: Move and rename regs_modified
Touching the user space representation of KVM's VCPU state is -naturally - a per-VCPU thing. So move the dirty flag into KVM_CPU_COMMONand rename it at this chance to reflect its true meaning.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
kvm: Flush coalesced MMIO buffer periodly
The default action of coalesced MMIO is, cache the writing in buffer, until:1. The buffer is full.2. Or the exit to QEmu due to other reasons.
But this would result in a very late writing in some condition.1. The each time write to MMIO content is small....
kvm: x86: Add support for VCPU event states
This patch extends the qemu-kvm state sync logic with support forKVM_GET/SET_VCPU_EVENTS, giving access to yet missing exception,interrupt and NMI states.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Don't leak file descriptors
We're leaking file descriptors to child processes. Set FD_CLOEXEC on filedescriptors that don't need to be passed to children to stop this misbehaviour.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: Add arch reset handler
Will be required by succeeding changes.
kvm: Move KVM mp_state accessors to i386-specific code
Unbreaks PowerPC and S390 KVM builds.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
unlock iothread mutex before running kvm ioctl
Without this, kvm will hold the mutex while it issues its run ioctl,and never be able to step out of it, causing a deadlock.
Patchworks-ID: 35359Signed-off-by: Glauber Costa <glommer@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: Fix guest single-stepping
Hopefully the last regression of 4c0960c0: KVM_SET_GUEST_DEBUG requiresproperly synchronized guest registers (on x86: eflags) on entry.
temporary fix for on_vcpu
Recent changes made on_vcpu hit the abort() path, even with the IO threaddisabled. This is because cpu_single_env is no longer set when we call thisfunction. Although the correct fix is a little bit more complicated that that,...
Revert "Get rid of _t suffix"
In the very least, a change like this requires discussion on the list.
The naming convention is goofy and it causes a massive merge problem. Somethinglike this must be presented on the list first so people can provide input...
Get rid of _t suffix
Some not so obvious bits, slirp and Xen were left alone for the timebeing.
Signed-off-by: malc <av1474@comtv.ru>
ioports: remove unused env parameter and compile only once
The CPU state parameter is not used, remove it and adjust callers. Now wecan compile ioport.c once for all targets.
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
kvm: Simplify cpu_synchronize_state()
cpu_synchronize_state() is a little unreadable since the 'modified'argument isn't self-explanatory. Simplify it by making it alwayssynchronize the kernel state into qemu, and automatically flush theregisters back to the kernel if they've been synchronized on this...
Revert "Fake dirty loggin when it's not there"
This reverts commit bd8367761236cd5c435598aeb2f1b8240c09b059.
PPC should just implement dirty logging so we can avoid all the fall-out fromthis changeset.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Fix broken build
The only caller of on_vcpu() is protected by ifdefKVM_CAP_SET_GUEST_DEBUG, so protect on_vcpu() too otherwise QEMUmay not to build.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Use 64bit pointer for dirty log
Dirty logs currently get written with native "long" size. On little endianit doesn't matter if we use uint64_t instead though, because we'd still endup using the right bytes.
On big endian, this does become a bigger problem, so we need to ensure that...
Use Little Endian for Dirty Log
We currently use host endian long types to store informationin the dirty bitmap.
This works reasonably well on Little Endian targets, because theu32 after the first contains the next 32 bits. On Big Endian thisbreaks completely though, forcing us to be inventive here....
introduce on_vcpu
on_vcpu is a qemu-kvm function that will make sure that a specificpiece of code will run on a requested cpu. We don't need that becausewe're restricted to -smp 1 right now, but those days are likely to end soon.
So for the benefit of having qemu-kvm share more code with us, I'm...
provide tests for pit in kernel and irqchip in kernel
KVM can have an in-kernel pit or irqchip. While we don't implement ityet, having a way for test for it (that always returns zero) will allow usto reuse code in qemu-kvm that tests for it.
Signed-off-by: Glauber Costa <glommer@redhat.com>...
Fix warning in kvm-all.c
This fixes a warning I stumbled across while compiling qemu on PPC64.
Signed-off-by: Alexander Graf <agraf@suse.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Fake dirty loggin when it's not there
Some KVM platforms don't support dirty logging yet, like IA64 and PPC,so in order to still have screen updates on those, we need to fake it.
This patch just tells the getter function for dirty bitmaps, that allpages within a slot are dirty when the slot has dirty logging enabled....
Revert "Introduce reset notifier order"
This reverts commit 8217606e6edb49591b4a6fd5a0d1229cebe470a9 (andupdates later added users of qemu_register_reset), we solved theproblem it originally addressed less invasively.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: Rework VCPU synchronization
During startup and after reset we have to synchronize user space to thein-kernel KVM state. Namely, we need to transfer the VCPU registers whenthey change due to VCPU as well as APIC reset.
This patch refactors the required hooks so that kvm_init_vcpu registers...
kvm: Fix IRQ injection into full queue
User space may only inject interrupts during kvm_arch_pre_run ifready_for_interrupt_injection is set in kvm_run. But that field isupdated on exit from KVM_RUN, so we must ensure that we enter thekernel after potentially queuing an interrupt, otherwise we risk to...
kvm: Improve upgrade notes when facing unsupported kernels
Users complained that it is not obvious what to do when kvm refuses tobuild or run due to an unsupported host kernel, so let's improve thehints.
kvm: Rework VCPU reset
Use standard callback with highest order to synchronize VCPU on resetafter all device callbacks were execute. This allows to remove thespecial kvm hook in qemu_system_reset.
kvm: x86: Save/restore KVM-specific CPU states
Save and restore all so far neglected KVM-specific CPU states. Handlingthe TSC stabilizes migration in KVM mode. The interrupt_bitmap andmp_state are currently unused, but will become relevant for in-kernel...
kvm: Introduce kvm_set_migration_log
Introduce a global dirty logging flag that enforces logging for allslots. This can be used by the live migration code to enable/disableglobal logging withouth destroying the per-slot setting.
kvm: Fix dirty log temporary buffer size
The buffer passed to KVM_GET_DIRTY_LOG requires one bit per page. Fixthe size calculation in kvm_physical_sync_dirty_bitmap accordingly,avoiding allocation of extremly oversized buffers.
kvm: Rework dirty bitmap synchronization
Extend kvm_physical_sync_dirty_bitmap() so that is can sync acrossmultiple slots. Useful for updating the whole dirty log duringmigration. Moreover, properly pass down errors the whole call chain.
kvm: Conditionally apply workaround for KVM slot handling bug
Only apply the workaround for broken slot joining in KVM when thecapability was not found that signals the corresponding fix existence.
kvm: add error message for when SMP is requested
Right now, if you try e.g. '-smp 2' you just get 'failed toinitialize KVM'.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Introduce kvm_check_extension to check if KVM extensions are supported
kvm: Avoid COW if KVM MMU is asynchronous
Avi Kivity wrote:
Suggest wrapping in a function and hiding it deep inside kvm-all.c.
Done in v2:
---------->
If the KVM MMU is asynchronous (kernel does not support MMU_NOTIFIER),we have to avoid COW for the guest memory. Otherwise we risk serious...
kvm: Relax aligment check of kvm_set_phys_mem
There is no need to reject an unaligned memory region registration ifthe region will be I/O memory and it will not split an existing KVMslot. This fixes KVM support on PPC.
kvm: improve handling of overlapping slots (Jan Kiszka)
This reworks the slot management to handle more patterns ofcpu_register_physical_memory*, finally allowing to reset KVM guests (sofar address remapping on reset broke the slot management).
We could actually handle all possible ones without failing, but a KVM...
kvm: Add sanity checks to slot management (Jan Kiszka)
Fail loudly if we run out of memory slot.
Make sure that dirty log start/stop works with consistent memory regionsby reporting invalid parameters. This reveals several inconsistencies inthe vga code, patch to fix them follows later in this series....
kvm: Cleanup unmap condition in kvm_set_phys_mem (Jan Kiszka)
Testing for TLB_MMIO on unmap makes no sense as A) that flag belongs toCPUTLBEntry and not to io_memory slots or physical addresses and B) wealready use a different condition before mapping. So make this test...
Remove code phys_ram_base uses.
Signed-off-by: Paul Brook <paul@codesourcery.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7085 c046a42c-6fe2-441c-8c8c-71466251a162
Guest debugging support for KVM (Jan Kiszka)
This is a backport of the guest debugging support for the KVMaccelerator that is now part of the KVM tree. It implements the reworkedKVM kernel API for guest debugging (KVM_CAP_SET_GUEST_DEBUG) which isnot yet part of any mainline kernel but will probably be 2.6.30 stuff....
Fix race condition on access to env->interrupt_request
env->interrupt_request is accessed as the bit level from both main codeand signal handler, making a race condition possible even on CISC CPU.This causes freeze of QEMU under high load when running the dyntick...
toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)
Signed-off-by: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6531 c046a42c-6fe2-441c-8c8c-71466251a162
KVM: Silence unused s warning
Move s under #ifdef to avoid compiler warning.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6086 c046a42c-6fe2-441c-8c8c-71466251a162
kvm: sync vcpu state during initialization (Hollis Blanchard)
Currently on x86, qemu initializes CPUState but KVM ignores it and does itsown vcpu initialization. However, PowerPC KVM needs to be able to set theinitial register state to support the -kernel and -append options....
KVM: Coalesced MMIO support
MMIO exits are more expensive in KVM or Xen than in QEMU because theyinvolve, at least, privilege transitions. However, MMIO writeoperations can be effectively batched if those writes do not have sideeffects.
Good examples of this include VGA pixel operations when in a planar...
Disable KVM support if the kernel modules have broken memory slot handling
Prior to kvm-80, memory slot deletion was broken in the KVM kernelmodules. In kvm-81, a new capability is introduced to signify that thisproblem has been fixed.
Since we rely on being able to delete memory slots, refuse to work with...
Add virtio-balloon support
This adds a VirtIO based balloon driver. It uses madvise() to actually balloonthe memory when possible.
Until 2.6.27, KVM forced memory pinning so we must disable ballooning unless thekernel actually supports it when using KVM. It's always safe when using TCG....
kvm: Introduce kvm logging interface (Glauber Costa)
Introduce functions to control logging of memory regions.We select regions based on its start address, aguest_physical_addr (target_phys_addr_t, in qemu nomenclature).
The main user of this interface right now is VGA optimization...
Make KVMSlot a real structure
struct kvm_userspace_memory_region does not use QEMU friendly types todefine memory slots. This results in lots of ugly casting with warningson 32-bit platforms.
This patch introduces a proper KVMSlot structure that uses QEMU types to...
kvm: de-register mem region for MMIO (Glauber Costa)
Besides unassigned memory, we also don't care about MMIO.So if we're giving an MMIO area that is already registered,wipe it out.
Signed-off-by: Glauber Costa <glommer@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>...
Make KVM slot management more robust
KVM keeps track of physical memory based on slots in the kernel. The currentcode that translates QEMU memory mappings to slots work but is not robustin the fact of reregistering partial regions of memory.
This patch does the right thing for reregistering partial regions of memory. It...
Define kvm_ioctl in the same way as ioctl
The third argument to ioctl is a ... which allows any value to be passed. Inpractice, glibc always treats the argument as a void *.
Do the same thing for the kvm ioctls to keep things consistent with atraditional ioctl....
KVM: simplify kvm_cpu_exec hook
We don't need to use cpu_loop_exit() because we never use thecondition codes so everything can be folded into a single case.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5669 c046a42c-6fe2-441c-8c8c-71466251a162
Add missing files to KVM commit.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5629 c046a42c-6fe2-441c-8c8c-71466251a162