History | View | Annotate | Download (50.4 kB)
Rename target_phys_addr_t to hwaddr
target_phys_addr_t is unwieldly, violates the C standard (_t suffixes arereserved) and its purpose doesn't match the name (most target_phys_addr_taddresses are not target specific). Replace it with a finger-friendly,...
memory: use AddressSpace for MemoryListener filtering
Using the AddressSpace type reduces confusion, as you can't accidentallysupply the MemoryRegion you're interested in.
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Avi Kivity <avi@redhat.com>
memory: manage coalesced mmio via a MemoryListener
Instead of calling a global function on coalesced mmio changes, whichroutes the call to kvm if enabled, add coalesced mmio hooks toMemoryListener and make kvm use that instead.
The motivation is support for multiple address spaces (which means we...
kvm: drop no-op MemoryListener callbacks
Removes quite a bit of useless code.
Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: use separate MemoryListeners for memory and I/O
The construct
if (address_space == get_system_memory()) { // memory thing } else { // io thing }
fails if we have more than two address spaces. Use a separate listenerfor memory and I/O, and utilize MemoryListener's address space filtering to...
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
kvm: Fix warning from static code analysis
Report from smatch:
kvm-all.c:1373 kvm_init(135) warn: variable dereferenced before check 's' (see line 1360)
's' cannot by NULL (it was alloced using g_malloc0), so there is no needto check it here.
Signed-off-by: Stefan Weil <sw@weilnetz.de>...
kvm: Rename irqchip_inject_ioctl to irq_set_ioctl
This variable is no longer bound to irqchip, and the IOCTL sets the IRQlevel, does not directly inject it. No functional changes.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: Stop flushing coalesced MMIO on vmexit
The memory subsystem will now take care of flushing whenever affectedregions are accessed or the memory mapping changes.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
Move the init of the irqchip_inject_ioctl field of KVMState out ofkvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()can be used even when no irqchip is created (for architectures...
kvm: Introduce kvm_has_intx_set_mask
Will be used by PCI device assignment code.
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>
kvm: Introduce kvm_irqchip_update_msi_route
This service allows to update an MSI route without releasing/reacquiringthe associated VIRQ. Will be used by PCI device assignment, later onlikely also by virtio/vhost and VFIO.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
kvm: Clean up irqfd API
No need to expose the fd-based interface, everyone will already be finewith the more handy EventNotifier variant. Rename the latter to clarifythat we are still talking about irqfds here.
qemu: Use valgrind annotations to mark kvm guest memory as defined
valgrind with kvm produces a big amount of false positives regarding"Conditional jump or move depends on uninitialised value(s)". Thishappens because the guest memory is allocated with qemu_vmalloc which...
kvm: Decouple 'GSI routing' from 'kernel irqchip'
Don't assume having an in-kernel irqchip means that GSIrouting is enabled.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: Decouple 'irqfds usable' from 'kernel irqchip'
Instead of assuming that we can use irqfds if and only ifkvm_irqchip_in_kernel(), add a bool to the KVMState whichindicates this, and is set only on x86 and only if theirqchip is in the kernel.
The kernel documentation implies that the only thing...
kvm: Decouple 'MSI routing via irqfds' from 'kernel irqchip'
Decouple another x86-specific assumption about what irqchips imply.
kvm: Move kvm_allows_irq0_override() to target-i386, fix return type
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....
kvm: Rename kvm_irqchip_set_irq() to kvm_set_irq()
Rename the function kvm_irqchip_set_irq() to kvm_set_irq(),since it can be used for sending (asynchronous) interrupts whetherthere is a full irqchip model in the kernel or not. (We don'tinclude 'async' in the function name since asynchronous is the...
kvm: Decouple 'async interrupt delivery' from 'kernel irqchip'
On x86 userspace delivers interrupts to the kernel asynchronously(and therefore VCPU idle management is done in the kernel) if andonly if there is an in-kernel irqchip. On other architectures this...
kvm: Check if smp_cpus exceeds max cpus supported by kvm
Add a helper function for fetching max cpus supported by kvm.
Make QEMU exit with an error message if smp_cpus exceeds limitof VCPU count retrieved by invoking this helper function.
Signed-off-by: Dunrong Huang <riegamaths@gmail.com>...
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging
virtio: move common irqfd handling out of virtio-pci
All transports can use the same event handler for the irqfd, though theexact mechanics of the assignment will be specific. Note that thereare three states: handled by the kernel, handled in userspace, disabled....
memory: pass EventNotifier, not eventfd
Under Win32, EventNotifiers will not have event_notifier_get_fd, so wecannot call it in common code such as hw/virtio-pci.c. Pass a pointer tothe notifier, and only retrieve the file descriptor in kvm-specific code....
s390: autodetect map private
By default qemu will use MAP_PRIVATE for guest pages. This will writeprotect pages and thus break on s390 systems that dont support this feature.Therefore qemu has a hack to always use MAP_SHARED for s390. But MAP_SHAREDhas other problems (no dirty pages tracking, a lot more swap overhead etc.)...
kvm: Don't abort on kvm_irqchip_add_msi_route()
Anyone using these functions has to be prepared that irqchipsupport may not be present. It shouldn't be up to the corecode to determine whether this is a fatal error. Currentlycode written as:
virq = kvm_irqchip_add_msi_route(...)...
kvm: add missing include files
These are included via monitor.h right now, add them explicitly.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
kvm: Fix build for non-CAP_IRQ_ROUTING targets
A type definition and a KVMState field initialization escaped therequired wrapping with KVM_CAP_IRQ_ROUTING. Also, we need to provide adummy kvm_irqchip_release_virq as virtio-pci references (but does notuse) it....
kvm: Introduce kvm_irqchip_add/remove_irqfd
Add services to associate an eventfd file descriptor as input with anIRQ line as output. Such a line can be an input pin of an in-kernelirqchip or a virtual line returned by kvm_irqchip_add_route.
kvm: Rename kvm_irqchip_add_route to kvm_irqchip_add_irq_route
We will add kvm_irqchip_add_msi_route, so let's make the differenceclearer.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: Introduce kvm_irqchip_add_msi_route
Add a service that establishes a static route from a virtual IRQ line toan MSI message. Will be used for IRQFD and device assignment. As we willuse this service outside of CONFIG_KVM protected code, stub it properly....
kvm: Publicize kvm_irqchip_release_virq
This allows to drop routes created by kvm_irqchip_add_irq/msi_routeagain.
kvm: Make kvm_irqchip_commit_routes an internal service
Automatically commit route changes after kvm_add_routing_entry andkvm_irqchip_release_virq. There is no performance relevant use case forwhich collecting multiple route changes is beneficial. This makes...
kvm: Add support for direct MSI injections
If the kernel supports KVM_SIGNAL_MSI, we can avoid the route-basedMSI injection mechanism.
kvm: Enable in-kernel irqchip support by default
As MSI is now fully supported by KVM (/wrt available features inupstream), we can finally enable the in-kernel irqchip by default.
kvm: Refactor KVMState::max_gsi to gsi_count
Instead of the bitmap size, store the maximum of GSIs the kernelsupport. Move the GSI limit assertion to the API functionkvm_irqchip_add_route and make it stricter.
kvm: Introduce basic MSI support for in-kernel irqchips
This patch basically adds kvm_irqchip_send_msi, a service for sendingarbitrary MSI messages to KVM's in-kernel irqchip models.
As the original KVM API requires us to establish a static route from a...
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.
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...
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.
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.
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.
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>
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: 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...