History | View | Annotate | Download (42.9 kB)
kvm: Fix dirty tracking with large kernel page size
If the kernel page size is larger than TARGET_PAGE_SIZE, whichhappens for example on ppc64 with kernels compiled for 64K pages,the dirty tracking doesn't work.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>...
kvm: set gsi_bits and max_gsi correctly
The current kvm_init_irq_routing() doesn't set up the used_gsi_bitmapcorrectly, and as a consequence pins max_gsi to 32 when it reallyshould be 1024. I ran into this limitation while testing pcipassthrough, where I consistently got an -ENOSPC return from...
kvm: allow arbitrarily sized mmio ioeventfd
We use a 2 byte ioeventfd for virtio memory,add support for this.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Reviewed-by: Amos Kong <akong@redhat.com>Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: Drop unused kvm_pit_in_kernel
This is now implied by kvm_irqchip_in_kernel.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: Comparison with ioctl number macros needs to be unsigned
In kvm-all.c we store an ioctl cmd number in the irqchip_inject_ioctl fieldof KVMState, which has type 'int'. This seems to make sense since theioctl() man page says that the cmd parameter has type int....
Rename CPUState -> CPUArchState
Scripted conversion: for file in .[hc] hw/.[hc] hw/kvm/*.[hc] linux-user/*.[hc] linux-user/m68k/*.[hc] bsd-user/*.[hc] darwin-user/*.[hc] tcg/*/*.[hc] target-*/cpu.h; do sed -i "s/CPUState/CPUArchState/g" $file done...
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
Spelling fixes in comments (it's -> its)
Reviewed-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Stefan Weil <sw@weilnetz.de>...
kvm: fill in padding to help valgrind
valgrind warns about padding fields which are passedto vcpu ioctls uninitialized.This is not an error in practice because kvm ignored padding.Since the ioctls in question are off data path andthe cost is zero anyway, initialize padding to 0...
kvm: Add kvm_has_pit_state2 helper
To be used for in-kernel PIT emulation.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Avi Kivity <avi@redhat.com>
Merge remote-tracking branch 'qemu-kvm/memory/urgent' into staging
Merge remote-tracking branch 'qemu-kvm/memory/core' into staging
kvm: fix unaligned slots
kvm_set_phys_mem() may be passed sections that are not aligned to a pageboundary. The current code simply brute-forces the alignment which leadsto an inconsistency and an abort().
Fix by aligning the start and the end of the section correctly, discarding...
memory: allow MemoryListeners to observe a specific address space
Ignore any regions not belonging to a specified address space.
Signed-off-by: Avi Kivity <avi@redhat.com>
memory: support stateless memory listeners
Current memory listeners are incremental; that is, they are expected tomaintain their own state, and receive callbacks for changes to that state.
This patch adds support for stateless listeners; these work by receiving...
memory: switch memory listeners to a QTAILQ
This allows reverse iteration, which in turns allows consistent orderingamong multiple listeners:
l1->add l2->add l2->del l1->del
Signed-off-by: Avi Kivity <avi@redhat.com>Reviewed-by: Richard Henderson <rth@twiddle.net>
memory: move ioeventfd ops to MemoryListener
This way the accelerator (kvm) can handle them directly.
kvm: Set cpu_single_env only once
As we have thread-local cpu_single_env now and KVM uses exactly onethread per VCPU, we can drop the cpu_single_env updates from the loopand initialize this variable only once during setup.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: Implement kvm_irqchip_in_kernel like kvm_enabled
To both avoid that kvm_irqchip_in_kernel always has to be paired withkvm_enabled and that the former ends up in a function call, implement itlike the latter. This means keeping the state in a global variable and...
KVM: Fix compilation on non-x86
Commit 84b058d broke compilation for KVM on non-x86 targets, whichdon't have KVM_CAP_IRQ_ROUTING defined.
Fix by not using the unavailable constant when it's not around.
Signed-off-by: Alexander Graf <agraf@suse.de>
memory: change dirty setting APIs to take a size
Instead of each target knowing or guessing the guest page size,just pass the desired size of dirtied memory area.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging
Fix dirty logging with 32-bit qemu & 64-bit guests
The kvm_get_dirty_pages_log_range() function uses two addressvariables to step through the monitored memory region to update thedirty log. However, these variables have type unsigned long, whichcan overflow if running a 64-bit guest with a 32-bit qemu binary....
kvm: Introduce core services for in-kernel irqchip support
Add the basic infrastructure to active in-kernel irqchip support, injectinterrupts into these models, and maintain IRQ routes.
Routing is optional and depends on the host arch supportingKVM_CAP_IRQ_ROUTING. When it's not available on x86, we looe the HPET as...
kvm: x86: Establish IRQ0 override control
KVM is forced to disable the IRQ0 override when we run with in-kernelirqchip but without IRQ routing support of the kernel. Set the fwcfgvalue correspondingly. This aligns us with qemu-kvm.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
kvm: flush the dirty log when unregistering a slot
Otherwise, the dirty log information is lost in the kernel forever.
Fixes opensuse-12.1 boot screen, which changes the vga windows rapidly.
kvm: avoid cpu_get_physical_page_desc()
This reaches into the innards of the memory core, which are beingchanged. Switch to a memory API version.
kvm: switch kvm slots to use host virtual address instead of ram_addr_t
This simplifies a later switch to the memory API in slot management.
kvm: convert to MemoryListener API
Drop the use of cpu_register_phys_memory_client() in favour of the newMemoryListener API. The new API simplifies the caller, since there is noneed to deal with splitting and merging slots; however this is not exploited...
kvm: Print something before calling abort() if KVM_RUN fails
It's a little unfriendly to call abort() without printing any sort oferror message. So turn the DPRINTK into an fprintf(stderr, ...).
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>...
kvm_init didn't set return value after create vm failed
And kvm_ioctl(s, KVM_CREATE_VM, 0)'s return value can be < -1,so change the check of vmfd at label 'err'.
Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: avoid reentring kvm_flush_coalesced_mmio_buffer()
mmio callbacks invoked by kvm_flush_coalesced_mmio_buffer() maythemselves indirectly call kvm_flush_coalesced_mmio_buffer().Prevent reentering the function by checking a flag that indicateswe're processing coalesced mmio requests....
RunState: Rename enum values as generated by the QAPI
Next commit will convert the query-status command to use theRunState type as generated by the QAPI.
In order to "transparently" replace the current enum by the QAPIone, we have to make some changes to some enum values....
Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),we pass a VMSTOP macro as the 'reason' argument. This is not idealbecause the VMSTOP macros tell why qemu stopped and not exactlywhat the current VM state is....
main: force enabling of I/O thread
Enabling the I/O thread by default seems like an important part of declaring1.0. Besides allowing true SMP support with KVM, the I/O thread means that theTCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
kvm: Drop obsolete KVM_IOEVENTFD #ifdefs
kvm: Drop KVM_CAP build dependencies
No longer needed with accompanied kernel headers. We are only left withbuild dependencies that are controlled by kvm arch headers.
CC: Alexander Graf <agraf@suse.de>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: Drop useless zero-initializations
Backing KVMState is alreay zero-initialized.
kvm: ppc: warn user on PAGE_SIZE mismatch
On PPC, the default PAGE_SIZE is 64kb. Unfortunately, the hardwarealignments don't match here: There are RAM and MMIO regions withina single page when it's 64kb in size.
So the only way out for now is to tell the user that he should use 4k...
Merge remote branch 'origin/master' into pci
Conflicts: exec.c
kvm: use qemu_free consistently
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: Install specialized interrupt handler
KVM only requires to set the raised IRQ in CPUState and to kick thereceiving vcpu if it is remote. Installing a specialized handler allowspotential future changes to the TCG code path without risking KVM sideeffects....
fix crash in migration, 32-bit userspace on 64-bit host
This change fixes a long-standing immediate crash (memory corruptionand abort in glibc malloc code) in migration on 32bits.
The bug is present since this commit:
commit 692d9aca97b865b0f7903565274a52606910f129...
kvm: halve number of set memory calls for vga
use the new api to reduce the number of these (expensive)system calls.
Note: using this API, we should be able toget rid of vga_dirty_log_xxx APIs. Using them doesn'taffect the performance though because we detects...
cpu: add set_memory flag to request dirty logging
Pass the flag to all cpu notifiers, doingnothing at this point. Will be used byfollow-up patches.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
kvm: Consider EXIT_DEBUG unknown without CAP_SET_GUEST_DEBUG
Without KVM_CAP_SET_GUEST_DEBUG, we neither motivate the kernel toreport KVM_EXIT_DEBUG nor do we expect such exits. So fall through tothe arch code which will simply report an unknown exit reason....
kvm: Keep KVM_RUN return value in separate variable
Avoid using 'ret' both for the return value of KVM_RUN as well as thecode kvm_cpu_exec is supposed to return. Both have no direct relation.
kvm: Reorder error handling of KVM_RUN
Test for general errors first as this is the slower path.
kvm: Rework inner loop of kvm_cpu_exec
Let kvm_cpu_exec return EXCP_* values consistently and generate thosecodes already inside its inner loop. This means we will now re-enter thekernel while ret == 0.
Update kvm_handle_internal_error accordingly, but keep...
kvm: Align kvm_arch_handle_exit to kvm_cpu_exec changes
Make the return code of kvm_arch_handle_exit directly usable forkvm_cpu_exec. This is straightforward for x86 and ppc, just s390would require more work. Avoid this for now by pushing the return code...
kvm: x86: Push kvm_arch_debug to kvm_arch_handle_exit
There are no generic bits remaining in the handling of KVM_EXIT_DEBUG.So push its logic completely into arch hands, i.e. only x86 so far.
kvm: Mark VCPU state dirty on creation
This avoids that early cpu_synchronize_state calls try to retrieve anuninitialized state from the kernel. That even causes a deadlock ifio-thread is enabled.
kvm: Rename kvm_arch_process_irqchip_events to async_events
We will broaden the scope of this function on x86 beyond irqchip events.
kvm: Fix build warning when KVM_CAP_SET_GUEST_DEBUG is lacking
Original fix by David Gibson.
CC: David Gibson <david@gibson.dropbear.id.au>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
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
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.
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)
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
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...