History | View | Annotate | Download (52.5 kB)
Merge remote-tracking branch 'afaerber/tags/qom-cpu-for-anthony' into staging
QOM CPUState refactorings
cpu: Make first_cpu and next_cpu CPUState
Move next_cpu from CPU_COMMON to CPUState.Move first_cpu variable to qom/cpu.h.
gdbstub needs to use CPUState::env_ptr for now.cpu_copy() no longer needs to save and restore cpu_next.
Acked-by: Paolo Bonzini <pbonzini@redhat.com>...
kvm: Free current_cpu identifier
Since CPU loops are done as last step in kvm_{insert,remove}_breakpoint()and kvm_remove_all_breakpoints(), we do not need to distinguish betweeninvoking CPU and iterated CPUs and can thereby free the identifier foruse as a global variable....
kvm: Change kvm_remove_all_breakpoints() argument to CPUState
Acked-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Andreas Färber <afaerber@suse.de>
Fix -machine options accel, kernel_irqchip, kvm_shadow_mem
Multiple -machine options with the same ID are merged. All but theone without an ID are to be silently ignored.
In most places, we query these options with a null ID. This iscorrect.
In some places, we instead query whatever options come first in the...
Merge remote-tracking branch 'bonzini/iommu-for-anthony' into staging
memory: add ref/unref calls
Add ref/unref calls at the following places:
- places where memory regions are stashed by a listener and used outside the BQL (including in Xen or KVM).
- memory_region_find callsites
- creation of aliases and containers (only the aliased/contained...
kvm: skip system call when msi route is unchanged
Some guests do a large number of mask/unmaskcalls which currently trigger expensive route updatesystem calls.Detect that route in unchanged and skip the system call.
Reported-by: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>...
kvm: add detail error message when fail to add ioeventfd
I try to hotplug 28 * 8 multiple-function devices to guest withold host kernel, ioeventfds in host kernel will be exhausted, thenqemu fails to allocate ioeventfds for blk/nic devices.
It's better to add detail error here....
kvm: zero-initialize KVM_SET_GSI_ROUTING input
kvm_add_routing_entry makes an attempt tozero-initialize any new routing entry.However, it fails to initialize paddingwithin the u field of the structurekvm_irq_routing_entry.
Other functions like kvm_irqchip_update_msi_route...
KVM: Export kvm_init_irq_routing
On PPC, we can have different types of interrupt controllers, so we reallyonly know that we are going to use one when we created it.
Export kvm_init_irq_routing() to common code, so that we don't have to callkvm_irqchip_create()....
KVM: MSI: Swap payload to native endianness
The usual MSI injection mechanism writes msi.data into memory using anle32 wrapper. So on big endian guests, this swaps msg.data into theexpected byte order.
For irqfd however, we don't swap the payload right now, rendering...
KVM: PIC: Only commit irq routing when necessary
The current logic updates KVM's view of our interrupt map every time wechange it. While this is nice and bullet proof, it slows things downbadly for me. QEMU spends about 3 seconds on every start telling KVM what...
KVM: Don't assume that mpstate exists with in-kernel PIC always
On PPC, we don't support MP state. So far it's not necessary and I'mnot convinced yet that we really need to support it ever.
However, the current idle logic in QEMU assumes that an in-kernel PIC...
kvm: Change kvm_cpu_synchronize_state() argument to CPUState
It no longer relies on CPUArchState since 20d695a.
Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Richard Henderson <rth@twiddle.net>...
kvm: Change kvm_set_signal_mask() argument to CPUState
CPUArchState is no longer needed.
Prepares for changing qemu_kvm_init_cpu_signals() argument to CPUState.
Acked-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Richard Henderson <rth@twiddle.net>...
cpu: Turn cpu_dump_{state,statistics}() into CPUState hooks
Make cpustats monitor command available unconditionally.
Prepares for changing kvm_handle_internal_error() and kvm_cpu_exec()arguments to CPUState.
Signed-off-by: Andreas Färber <afaerber@suse.de>
kvm: Change kvm_handle_internal_error() argument to CPUState
It no longer uses CPUArchState.
Prepares for changing kvm_cpu_exec() argument to CPUState.
kvm: Change kvm_cpu_exec() argument to CPUState
Prepares for changing qemu_kvm_cpu_thread_fn() opaque to CPUState.
memory: make section size a 128-bit integer
So far, the size of all regions passed to listeners could fit in 64 bits,because artificial regions (containers and aliases) are eliminated bythe memory core, leaving only device regions which have reasonable sizes...
fix double free the memslot in kvm_set_phys_mem
Luiz Capitulino reported that guest refused to boot and qemucomplained with:kvm_set_phys_mem: error unregistering overlapping slot: Invalid argument
It is caused by commit 235e8982ad that did double free for the memslot...
kvm: support using KVM_MEM_READONLY flag for regions
For readonly memory regions and rom devices in romd_mode,we make use of the KVM_MEM_READONLY. A slot that usesKVM_MEM_READONLY can be read from and code can execute from theregion, but writes will exit to qemu....
kvm: add kvm_readonly_mem_enabled
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Message-id: 1369816047-16384-3-git-send-email-jordan.l.justen@intel.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
osdep, kvm: rename low-level RAM allocation functions
This is preparatory to the introduction of a separate freeing API.
Reported-by: Amos Kong <akong@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Amos Kong <akong@redhat.com>...
kvm-all: add kvm_run_exit tracepoint
This patch enable us to know exit reason of KVM_RUN. It will help usknow where the trouble is caused.
Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
kvm-all: add kvm_ioctl, kvm_vm_ioctl, kvm_vcpu_ioctl tracepoints
This patch adds tracepoints at ioctl to kvm. Tracing these ioctl isuseful for clarification whether the cause of troubles is qemu or kvm.
Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>...
cpu: Call cpu_synchronize_post_init() from DeviceClass::realize()
If hotplugged, synchronize CPU state to KVM.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
pci: add pci test device
This adds a new device that we can use for testing PCI PIO and MMIO, with andwithout ioeventfd in different configurations. FAST_MMIO will be added if/whenkvm supports it. Also included are minor cleanups in kvm APIs that it needs....
cpu: Pass CPUState to cpu_synchronize_post()
... so it could be called without requiring CPUArchState.
kvm: remove unused APIs
There are only used internally now, move themout of header and out of stub.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
kvm: support any size for pio eventfd
kvm: support non datamatch ioeventfd
Adding restrictions just adds code.
cpu: Move halted and interrupt_request fields to CPUState
Both fields are used in VMState, thus need to be moved together.Explicitly zero them on reset since they were located beforebreakpoints.
Pass PowerPCCPU to kvmppc_handle_halt().
cpu: Pass CPUState to cpu_interrupt()
Move it to qom/cpu.h to avoid issues with include order.
Change pc_acpi_smi_interrupt() opaque to X86CPU.
cpu: Move exit_request field to CPUState
Since it was located before breakpoints field, it needs to be reset.
kvm: Pass CPUState to kvm_on_sigbus_vcpu()
Since commit 20d695a9254c1b086a456d3b79a3c311236643ba (kvm: PassCPUState to kvm_arch_*) CPUArchState is no longer needed.
Allows to change qemu_kvm_eat_signals() argument as well.
Signed-off-by: Andreas Färber <afaerber@suse.de>...
kvm: Create kvm_arch_vcpu_id() function
This will allow each architecture to define how the VCPU ID is set onthe KVM_CREATE_VCPU ioctl call.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>Acked-by: Gleb Natapov <gleb@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
kvm: add stub for kvm_irqchip_update_msi_route
ppc64 build needs this stub to build with virtio enabled.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Tested-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
cpu: Move cpu_index field to CPUState
Note that target-alpha accesses this field from TCG, now using anegative offset. Therefore the field is placed last in CPUState.
Pass PowerPCCPU to [kvm]ppc_fixup_cpu() to facilitate this change.
Move common parts of mips cpu_state_reset() to mips_cpu_reset()....
kvm: Pass CPUState to kvm_init_vcpu()
CPUArchState is no longer needed, and it thereby no longer depends onNEED_CPU_H.
Merge branch 'master' of git://git.qemu.org/qemu into qom-cpu
Adapt header include paths.
cpu: Move kvm_state field into CPUState
Adapt some functions to take CPUState / {PowerPC,S390}CPU argument.
cpu: Move kvm_run into CPUState
Pass CPUState / {X86,S390}CPU to helper functions.
cpu: Move kvm_fd into CPUState
kvm: Pass CPUState to kvm_arch_*
Move kvm_vcpu_dirty field into CPUState to simplify things and changeits type to bool while at it.
kvm: Pass CPUState to kvm_vcpu_ioctl()
Adapt helper functions to pass X86CPU / PowerPCCPU / S390CPU.
softmmu: move include files to include/sysemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
misc: move include files to include/qemu/
exec: move include files to include/exec/
kvm: do not flush after deleting gsi
Deleting a GSI isn't necessary: it is enoughto stop using it. Delay flush until an entry is used.
pci: update all users to look in pci/
update all users so we can remove the makefile hack.
kvm: fix incorrect length in a loop over kvm dirty pages map
QEMU allocates a map enough for 4k pages. However the system page sizecan be 64K (for example on POWER) and the host kernel uses only a smallpart of it as one big stores a dirty flag for 16 pages 4K each,...
kvm: Actually remove software breakpoints from list on cleanup
So far we only removed them from the guest, leaving its states in thelist. This made it impossible for gdb to re-enable breakpoints on thesame address after re-attaching.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
cpus: Pass CPUState to run_on_cpu()
Move the declaration to include/qemu/cpu.h and add documentation.
cpus: Pass CPUState to qemu_cpu_kick()
CPUArchState is no longer needed there.
cpus: Pass CPUState to qemu_cpu_is_self()
Change return type to bool, move to include/qemu/cpu.h andadd 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()]
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.
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...