History | View | Annotate | Download (34.6 kB)
Introduce log_start/log_stop in CPUPhysMemoryClient
In order to use log_start/log_stop with Xen as well in the vga code,this two operations have been put in CPUPhysMemoryClient.
The two new functions cpu_physical_log_start,cpu_physical_log_stop areused in hw/vga.c and replace the kvm_log_start/stop. With this, vga does...
kvm: Make kvm_state globally available
KVM-assisted devices need access to it but we have no clean channel todistribute a reference. As a workaround until there is a bettersolution, export kvm_state for global use, though use should remainrestricted to the mentioned scenario....
Improve vm_stop reason declarations
Define and use dedicated constants for vm_stop reasons, they actuallyhave nothing to do with the EXCP_* defines used so far. At this chance,specify more detailed reasons so that VM state change handlers canevaluate them....
kvm: Separate TCG from KVM cpu execution
Mixing up TCG bits with KVM already led to problems around eflagsemulation on x86. Moreover, quite some code that TCG requires on cpuenty/exit is useless for KVM. So dispatch between tcg_cpu_exec andkvm_cpu_exec as early as possible....
kvm: Remove unneeded memory slot reservation
The number of slots and the location of private ones changed severaltimes in KVM's early days. However, it's stable since 2.6.29 (ourrequired baseline), and slots 8..11 are no longer reserved since then.So remove this unneeded restriction....
kvm: Report proper error on GET_VCPU_MMAP_SIZE failures
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: Provide sigbus services arch-independently
Provide arch-independent kvm_on_sigbus* stubs to remove the #ifdef'eryfrom cpus.c. This patch also fixes --disable-kvm build by providing themissing kvm_on_sigbus_vcpu kvm-stub.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: Unconditionally reenter kernel after IO exits
KVM requires to reenter the kernel after IO exits in order to completeinstruction emulation. Failing to do so will leave the kernel stateinconsistently behind. To ensure that we will get back ASAP, we issue a...
kvm: Remove static return code of kvm_handle_io
Improve the readability of the exit dispatcher by moving the staticreturn value of kvm_handle_io to its caller.
kvm: Leave kvm_cpu_exec directly after KVM_EXIT_SHUTDOWN
The reset we issue on KVM_EXIT_SHUTDOWN implies that we should alsoleave the VCPU loop. As we now check for exit_request which is set byqemu_system_reset_request, this bug is no longer critical. Still it's an...
Merge remote branch 'qemu-kvm/uq/master' into staging
aliguori: fix build with !defined(KVM_CAP_ASYNC_PF)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD
It is not possible to use virtio-ioeventfd when building without an I/Othread. We rely on a signal to kick us out of vcpu execution. Timersand AIO use SIGALRM and SIGUSR2 respectively. Unfortunately eventfd...
kvm: Consolidate must-have capability checks
Instead of splattering the code with #ifdefs and runtime checks forcapabilities we cannot work without anyway, provide central testinfrastructure for verifying their availability both at build andruntime.
kvm: Flush coalesced mmio buffer on IO window exits
We must flush pending mmio writes if we leave kvm_cpu_exec for an IOwindow. Otherwise we risk to loose those requests when migrating to adifferent host during that window.
kvm: Drop smp_cpus argument from init functions
No longer used.
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.
kvm: Improve reporting of fatal errors
Report KVM_EXIT_UNKNOWN, KVM_EXIT_FAIL_ENTRY, and KVM_EXIT_EXCEPTIONwith more details to stderr. The latter two are so far x86-only, so movethem into the arch-specific handler. Integrate the Intel real modewarning on KVM_EXIT_FAIL_ENTRY that qemu-kvm carries, but actually...
x86: Optionally dump code bytes on cpu_dump_state
Introduce the cpu_dump_state flag CPU_DUMP_CODE and implement it forx86. This writes out the code bytes around the current instructionpointer. Make use of this feature in KVM to help debugging fatal vmexits....
kvm: Fix coding style violations
No functional changes.
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>
kvm: test for ioeventfd support on old kernels
There used to be a limit of 6 KVM io bus devices in the kernel.On such a kernel, we can't use many ioeventfds for host notificationsince the limit is reached too easily.
Add an API to test for this condition....
migration: stable ram block ordering
This makes ram block ordering under migration stable, ordered by offset.This is especially useful for migration to exec, for debugging.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Tested-by: Jason Wang <jasowang@redhat.com>
Add RAM -> physical addr mapping in MCE simulation
In QEMU-KVM, physical address != RAM address. While MCE simulationneeds physical address instead of RAM address. Sokvm_physical_memory_addr_from_ram() is implemented to do theconversion, and it is invoked before being filled in the IA32_MCi_ADDR...
Introduce qemu_madvise()
vl.c has a Sun-specific hack to supply a prototype for madvise(),but the call site has apparently moved to arch_init.c.
Haiku doesn't implement madvise() in favor of posix_madvise().OpenBSD and Solaris 10 don't implement posix_madvise() but madvise()....
Add function to assign ioeventfd to MMIO.
Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: remove guest triggerable abort()
This abort() condition is easily triggerable by a guest if it configurespci bar with unaligned address that overlaps main memory.
Signed-off-by: Gleb Natapov <gleb@redhat.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: Don't walk memory_size == 0 slots in kvm_client_migration_log
If we've unregistered a memory area, we should avoid callingqemu_get_ram_ptr() on the left over phys_offset cruft in theslot array. Now that we support removing ramblocks, thephys_offset ram_addr_t can go away and cause a lookup fault...
Rework debug exception processing for gdb use
Guest debugging is currently broken under CONFIG_IOTHREAD. The reason isinconsistent or even lacking signaling the debug events from the sourceVCPU to the main loop and the gdbstub.
This patch addresses the issue by pushing this signaling into a...
kvm: Switch kvm_update_guest_debug to run_on_cpu
Guest debugging under KVM is currently broken once io-threads areenabled. Easily fixable by switching the fake on_vcpu to the realrun_on_cpu implementation.
kvm: Enable XSAVE live migration support
Signed-off-by: Sheng Yang <sheng@linux.intel.com>Signed-off-by: Marcelo Tosatti <mtosatti@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.
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.
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.
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.
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...