summaryrefslogtreecommitdiff
path: root/kvm-all.c
AgeCommit message (Collapse)AuthorFilesLines
2013-06-03fix double free the memslot in kvm_set_phys_memXiao Guangrong1-1/+2
Luiz Capitulino reported that guest refused to boot and qemu complained with: kvm_set_phys_mem: error unregistering overlapping slot: Invalid argument It is caused by commit 235e8982ad that did double free for the memslot so that the second one raises the -EINVAL error Fix it by reset memory size only if it is needed Reported-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-05-29kvm: support using KVM_MEM_READONLY flag for regionsJordan Justen1-9/+28
For readonly memory regions and rom devices in romd_mode, we make use of the KVM_MEM_READONLY. A slot that uses KVM_MEM_READONLY can be read from and code can execute from the region, but writes will exit to qemu. For rom devices with !romd_mode, we force the slot to be removed so reads or writes to the region will exit to qemu. (Note that a memory region in this state is not executable within kvm.) v7: * Update for readable => romd_mode rename (5f9a5ea1) Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> (v4) Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> (v5) Message-id: 1369816047-16384-4-git-send-email-jordan.l.justen@intel.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-05-29kvm: add kvm_readonly_mem_enabledJordan Justen1-0/+6
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.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-05-14osdep, kvm: rename low-level RAM allocation functionsPaolo Bonzini1-3/+3
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> Message-id: 1368454796-14989-2-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-05-03kvm-all: add kvm_run_exit tracepointKazuya Saito1-0/+1
This patch enable us to know exit reason of KVM_RUN. It will help us know 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>
2013-05-03kvm-all: add kvm_ioctl, kvm_vm_ioctl, kvm_vcpu_ioctl tracepointsKazuya Saito1-0/+4
This patch adds tracepoints at ioctl to kvm. Tracing these ioctl is useful for clarification whether the cause of troubles is qemu or kvm. 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>
2013-05-01cpu: Call cpu_synchronize_post_init() from DeviceClass::realize()Igor Mammedov1-0/+1
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>
2013-04-19Merge remote-tracking branch 'mst/tags/for_anthony' into stagingAnthony Liguori1-65/+68
pci: add pci test device This adds a new device that we can use for testing PCI PIO and MMIO, with and without ioeventfd in different configurations. FAST_MMIO will be added if/when kvm supports it. Also included are minor cleanups in kvm APIs that it needs. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Mon 15 Apr 2013 05:42:24 PM CDT using RSA key ID D28D5469 # gpg: Can't check signature: public key not found # By Michael S. Tsirkin # Via Michael S. Tsirkin * mst/tags/for_anthony: pci: add pci test device kvm: support non datamatch ioeventfd kvm: support any size for pio eventfd kvm: remove unused APIs Message-id: cover.1366272004.git.mst@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-16cpu: Pass CPUState to *cpu_synchronize_post*()Igor Mammedov1-6/+2
... so it could be called without requiring CPUArchState. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-04-14kvm: support non datamatch ioeventfdMichael S. Tsirkin1-16/+18
Adding restrictions just adds code. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-04-14kvm: support any size for pio eventfdMichael S. Tsirkin1-12/+12
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-04-14kvm: remove unused APIsMichael S. Tsirkin1-53/+54
There are only used internally now, move them out of header and out of stub. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-03-12cpu: Pass CPUState to cpu_interrupt()Andreas Färber1-3/+1
Move it to qom/cpu.h to avoid issues with include order. Change pc_acpi_smi_interrupt() opaque to X86CPU. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-03-12cpu: Move halted and interrupt_request fields to CPUStateAndreas Färber1-1/+1
Both fields are used in VMState, thus need to be moved together. Explicitly zero them on reset since they were located before breakpoints. Pass PowerPCCPU to kvmppc_handle_halt(). Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-02-16cpu: Move exit_request field to CPUStateAndreas Färber1-3/+3
Since it was located before breakpoints field, it needs to be reset. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-01-28kvm: Pass CPUState to kvm_on_sigbus_vcpu()Andreas Färber1-2/+1
Since commit 20d695a9254c1b086a456d3b79a3c311236643ba (kvm: Pass CPUState 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> Reviewed-by: Gleb Natapov <gleb@redhat.com>
2013-01-27kvm: Create kvm_arch_vcpu_id() functionEduardo Habkost1-1/+1
This will allow each architecture to define how the VCPU ID is set on the 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>
2013-01-15kvm: add stub for kvm_irqchip_update_msi_routeMichael S. Tsirkin1-0/+5
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>
2013-01-15kvm: Pass CPUState to kvm_init_vcpu()Andreas Färber1-2/+1
CPUArchState is no longer needed, and it thereby no longer depends on NEED_CPU_H. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-01-15cpu: Move cpu_index field to CPUStateAndreas Färber1-1/+1
Note that target-alpha accesses this field from TCG, now using a negative 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(). Acked-by: Richard Henderson <rth@twiddle.net> (for alpha) [AF: Rebased onto ppc CPU subclasses and openpic changes] Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-12-23Merge branch 'master' of git://git.qemu.org/qemu into qom-cpuAndreas Färber1-13/+11
Adapt header include paths. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-12-19cpu: Move kvm_run into CPUStateAndreas Färber1-4/+4
Pass CPUState / {X86,S390}CPU to helper functions. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-12-19cpu: Move kvm_state field into CPUStateAndreas Färber1-14/+14
Adapt some functions to take CPUState / {PowerPC,S390}CPU argument. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-12-19kvm: Pass CPUState to kvm_vcpu_ioctl()Andreas Färber1-7/+7
Adapt helper functions to pass X86CPU / PowerPCCPU / S390CPU. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-12-19kvm: Pass CPUState to kvm_arch_*Andreas Färber1-31/+44
Move kvm_vcpu_dirty field into CPUState to simplify things and change its type to bool while at it. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-12-19cpu: Move kvm_fd into CPUStateAndreas Färber1-3/+5
Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-5/+5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19exec: move include files to include/exec/Paolo Bonzini1-3/+3
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-17kvm: do not flush after deleting gsiMichael S. Tsirkin1-2/+0
Deleting a GSI isn't necessary: it is enough to stop using it. Delay flush until an entry is used. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-12-17pci: update all users to look in pci/Michael S. Tsirkin1-1/+1
update all users so we can remove the makefile hack. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-11-26kvm: fix incorrect length in a loop over kvm dirty pages mapAlexey Kardashevskiy1-1/+1
QEMU allocates a map enough for 4k pages. However the system page size can be 64K (for example on POWER) and the host kernel uses only a small part of it as one big stores a dirty flag for 16 pages 4K each, the hpratio variable stores this ratio and the kvm_get_dirty_pages_log_range function handles it correctly. However kvm_get_dirty_pages_log_range still goes beyond the data provided by the host kernel which is not correct. It does not cause errors at the moment as the whole bitmap is zeroed before doing KVM ioctl. The patch reduces number of iterations over the map. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Alexander Graf <agraf@suse.de>
2012-11-14kvm: Actually remove software breakpoints from list on cleanupJan Kiszka1-0/+2
So far we only removed them from the guest, leaving its states in the list. This made it impossible for gdb to re-enable breakpoints on the same address after re-attaching. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-10-31cpus: Pass CPUState to run_on_cpu()Andreas Färber1-2/+5
CPUArchState is no longer needed. Move the declaration to include/qemu/cpu.h and add documentation. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-10-31cpus: Pass CPUState to qemu_cpu_kick()Andreas Färber1-1/+1
CPUArchState is no longer needed there. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-10-31cpus: Pass CPUState to qemu_cpu_is_self()Andreas Färber1-1/+3
Change return type to bool, move to include/qemu/cpu.h and add 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()]
2012-10-23Rename target_phys_addr_t to hwaddrAvi Kivity1-14/+14
target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-10-22memory: use AddressSpace for MemoryListener filteringAvi Kivity1-2/+2
Using the AddressSpace type reduces confusion, as you can't accidentally supply the MemoryRegion you're interested in. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-22memory: manage coalesced mmio via a MemoryListenerAvi Kivity1-10/+10
Instead of calling a global function on coalesced mmio changes, which routes the call to kvm if enabled, add coalesced mmio hooks to MemoryListener and make kvm use that instead. The motivation is support for multiple address spaces (which means we we need to filter the call on the right address space) but the result is cleaner as well. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-15kvm: drop no-op MemoryListener callbacksAvi Kivity1-30/+0
Removes quite a bit of useless code. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-15kvm: use separate MemoryListeners for memory and I/OAvi Kivity1-39/+44
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 listener for memory and I/O, and utilize MemoryListener's address space filtering to fix this. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-09-17Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori1-7/+5
* stefanha/trivial-patches: configure: fix seccomp check arch_init.c: add missing '%' symbols before PRIu64 in debug printfs kvm: Fix warning from static code analysis qapi: Fix enumeration typo error console: Clean up bytes per pixel calculation Fix copy&paste typos in documentation comments linux-user: Remove #if 0'd cpu_get_real_ticks() definition ui: Fix spelling in comment (ressource -> resource) Spelling fixes in comments and macro names (ressource -> resource) Fix spelling (licenced -> licensed) in GPL Spelling fixes in comments and documentation srp: Don't use QEMU_PACKED for single elements of a structured type
2012-09-14kvm: Fix warning from static code analysisStefan Weil1-7/+5
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 need to check it here. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-09-11kvm: Rename irqchip_inject_ioctl to irq_set_ioctlJan Kiszka1-5/+5
This variable is no longer bound to irqchip, and the IOCTL sets the IRQ level, 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> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-09-11kvm: Stop flushing coalesced MMIO on vmexitJan Kiszka1-2/+0
The memory subsystem will now take care of flushing whenever affected regions are accessed or the memory mapping changes. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-09-11kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()Peter Maydell1-4/+5
Move the init of the irqchip_inject_ioctl field of KVMState out of kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq() can be used even when no irqchip is created (for architectures that support async interrupt notification even without an in kernel irqchip). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-09-10kvm: Introduce kvm_has_intx_set_maskJan Kiszka1-0/+8
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>
2012-09-10kvm: Introduce kvm_irqchip_update_msi_routeJan Kiszka1-0/+42
This service allows to update an MSI route without releasing/reacquiring the associated VIRQ. Will be used by PCI device assignment, later on likely also by virtio/vhost and VFIO. 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>
2012-09-09kvm: Clean up irqfd APIJan Kiszka1-14/+4
No need to expose the fd-based interface, everyone will already be fine with the more handy EventNotifier variant. Rename the latter to clarify that we are still talking about irqfds here. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-09-09qemu: Use valgrind annotations to mark kvm guest memory as definedChristian Borntraeger1-0/+7
valgrind with kvm produces a big amount of false positives regarding "Conditional jump or move depends on uninitialised value(s)". This happens because the guest memory is allocated with qemu_vmalloc which boils down posix_memalign etc. This function is (correctly) considered by valgrind as returning undefined memory. Since valgrind is based on jitting code, it will not be able to see changes made by the guest to guest memory if this is done by KVM_RUN, thus keeping most of the guest memory undefined. Now lots of places in qemu will then use guest memory to change behaviour. To avoid the flood of these messages, lets declare the whole guest memory as defined. This will reduce the noise and allows us to see real problems. In the future we might want to make this conditional, since there is actually something that we can use those false positives for: These messages will point to code that depends on guest memory, so we can use these backtraces to actually make an audit that is focussed only at those code places. For normal development we dont want to see those messages, though. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>