Re: [PATCH] KVM: nVMX: Avoid one redundant vmcs_read in prepare_vmcs12
On Wed, Feb 20, 2013 at 02:02:23PM +0100, Jan Kiszka wrote: IDT_VECTORING_INFO_FIELD was already read right after vmexit. Applied, thanks. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- arch/x86/kvm/vmx.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7d2fbd2..d99a519 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -7368,8 +7368,7 @@ void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) vmcs12-vm_exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO); vmcs12-vm_exit_intr_error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); - vmcs12-idt_vectoring_info_field = - vmcs_read32(IDT_VECTORING_INFO_FIELD); + vmcs12-idt_vectoring_info_field = to_vmx(vcpu)-idt_vectoring_info; vmcs12-idt_vectoring_error_code = vmcs_read32(IDT_VECTORING_ERROR_CODE); vmcs12-vm_exit_instruction_len = vmcs_read32(VM_EXIT_INSTRUCTION_LEN); -- 1.7.3.4 -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Tracing kvm: kvm_entry and kvm_exit
On Thu, Feb 28, 2013 at 5:49 AM, David Ahern dsah...@gmail.com wrote: On 2/27/13 9:39 AM, David Ahern wrote: I have been playing with the live mode a bit lately. I'll add a debug to note 2 consecutive entry events without an exit -- see if it sheds some light on it. If you feel game take this for a spin: https://github.com/dsahern/linux/commits/perf-kvm-live-3.8 This is very cool, thanks for sharing. Next time I'm profiling vmexit latencies I'll give it a try. Stefan -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] KVM: VMX: Pass vcpu to __vmx_complete_interrupts
On Wed, Feb 20, 2013 at 02:03:24PM +0100, Jan Kiszka wrote: Cleanup: __vmx_complete_interrupts has no use for the vmx structure. Signed-off-by: Jan Kiszka jan.kis...@siemens.com Fixed it to be applicable without nVMX: Rework event injection and recovery and applied. Thanks. --- Note: this applies on top of Rework event injection and recovery arch/x86/kvm/vmx.c | 31 ++- 1 files changed, 14 insertions(+), 17 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d99a519..d6ea4a7 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -6430,7 +6430,7 @@ static void vmx_recover_nmi_blocking(struct vcpu_vmx *vmx) ktime_to_ns(ktime_sub(ktime_get(), vmx-entry_time)); } -static void __vmx_complete_interrupts(struct vcpu_vmx *vmx, +static void __vmx_complete_interrupts(struct kvm_vcpu *vcpu, u32 idt_vectoring_info, int instr_len_field, int error_code_field) @@ -6441,46 +6441,43 @@ static void __vmx_complete_interrupts(struct vcpu_vmx *vmx, idtv_info_valid = idt_vectoring_info VECTORING_INFO_VALID_MASK; - vmx-vcpu.arch.nmi_injected = false; - kvm_clear_exception_queue(vmx-vcpu); - kvm_clear_interrupt_queue(vmx-vcpu); + vcpu-arch.nmi_injected = false; + kvm_clear_exception_queue(vcpu); + kvm_clear_interrupt_queue(vcpu); if (!idtv_info_valid) return; - kvm_make_request(KVM_REQ_EVENT, vmx-vcpu); + kvm_make_request(KVM_REQ_EVENT, vcpu); vector = idt_vectoring_info VECTORING_INFO_VECTOR_MASK; type = idt_vectoring_info VECTORING_INFO_TYPE_MASK; switch (type) { case INTR_TYPE_NMI_INTR: - vmx-vcpu.arch.nmi_injected = true; + vcpu-arch.nmi_injected = true; /* * SDM 3: 27.7.1.2 (September 2008) * Clear bit block by NMI before VM entry if a NMI * delivery faulted. */ - vmx_set_nmi_mask(vmx-vcpu, false); + vmx_set_nmi_mask(vcpu, false); break; case INTR_TYPE_SOFT_EXCEPTION: - vmx-vcpu.arch.event_exit_inst_len = - vmcs_read32(instr_len_field); + vcpu-arch.event_exit_inst_len = vmcs_read32(instr_len_field); /* fall through */ case INTR_TYPE_HARD_EXCEPTION: if (idt_vectoring_info VECTORING_INFO_DELIVER_CODE_MASK) { u32 err = vmcs_read32(error_code_field); - kvm_queue_exception_e(vmx-vcpu, vector, err); + kvm_queue_exception_e(vcpu, vector, err); } else - kvm_queue_exception(vmx-vcpu, vector); + kvm_queue_exception(vcpu, vector); break; case INTR_TYPE_SOFT_INTR: - vmx-vcpu.arch.event_exit_inst_len = - vmcs_read32(instr_len_field); + vcpu-arch.event_exit_inst_len = vmcs_read32(instr_len_field); /* fall through */ case INTR_TYPE_EXT_INTR: - kvm_queue_interrupt(vmx-vcpu, vector, - type == INTR_TYPE_SOFT_INTR); + kvm_queue_interrupt(vcpu, vector, type == INTR_TYPE_SOFT_INTR); break; default: break; @@ -6489,7 +6486,7 @@ static void __vmx_complete_interrupts(struct vcpu_vmx *vmx, static void vmx_complete_interrupts(struct vcpu_vmx *vmx) { - __vmx_complete_interrupts(vmx, vmx-idt_vectoring_info, + __vmx_complete_interrupts(vmx-vcpu, vmx-idt_vectoring_info, VM_EXIT_INSTRUCTION_LEN, IDT_VECTORING_ERROR_CODE); } @@ -6498,7 +6495,7 @@ static void vmx_cancel_injection(struct kvm_vcpu *vcpu) { if (to_vmx(vcpu)-nested.nested_run_pending) return; - __vmx_complete_interrupts(to_vmx(vcpu), + __vmx_complete_interrupts(vcpu, vmcs_read32(VM_ENTRY_INTR_INFO_FIELD), VM_ENTRY_INSTRUCTION_LEN, VM_ENTRY_EXCEPTION_ERROR_CODE); -- 1.7.3.4 -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v12 rebased] kvm: notify host when the guest is panicked
On Thu, Feb 07, 2013 at 11:39:47PM -0200, Marcelo Tosatti wrote: Hi, On Wed, Jan 23, 2013 at 03:19:21PM +0800, Hu Tao wrote: We can know the guest is panicked when the guest runs on xen. But we do not have such feature on kvm. Another purpose of this feature is: management app(for example: libvirt) can do auto dump when the guest is panicked. If management app does not do auto dump, the guest's user can do dump by hand if he sees the guest is panicked. We have three solutions to implement this feature: 1. use vmcall 2. use I/O port 3. use virtio-serial. We have decided to avoid touching hypervisor. The reason why I choose choose the I/O port is: 1. it is easier to implememt 2. it does not depend any virtual device 3. it can work when starting the kernel Signed-off-by: Wen Congyang we...@cn.fujitsu.com Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- arch/ia64/kvm/irq.h | 19 + arch/powerpc/include/asm/kvm_para.h | 18 arch/s390/include/asm/kvm_para.h | 19 + arch/x86/include/asm/kvm_para.h | 20 ++ arch/x86/include/uapi/asm/kvm_para.h | 2 ++ arch/x86/kernel/kvm.c| 53 include/linux/kvm_para.h | 18 include/uapi/linux/kvm_para.h| 6 kernel/panic.c | 4 +++ 9 files changed, 159 insertions(+) diff --git a/arch/ia64/kvm/irq.h b/arch/ia64/kvm/irq.h index c0785a7..b3870f8 100644 --- a/arch/ia64/kvm/irq.h +++ b/arch/ia64/kvm/irq.h @@ -30,4 +30,23 @@ static inline int irqchip_in_kernel(struct kvm *kvm) return 1; } +static inline int kvm_arch_pv_event_init(void) +{ + return 0; +} + +static inline unsigned int kvm_arch_pv_features(void) +{ + return 0; +} + +static inline void kvm_arch_pv_eject_event(unsigned int event) +{ +} + +static inline bool kvm_arch_pv_event_enabled(void) +{ + return false; +} + The interface is x86 only, no need to touch other architectures. OK. #endif diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h index 2b11965..17dd013 100644 --- a/arch/powerpc/include/asm/kvm_para.h +++ b/arch/powerpc/include/asm/kvm_para.h @@ -144,4 +144,22 @@ static inline bool kvm_check_and_clear_guest_paused(void) return false; } +static inline int kvm_arch_pv_event_init(void) +{ + return 0; +} + +static inline unsigned int kvm_arch_pv_features(void) +{ + return 0; +} + +static inline void kvm_arch_pv_eject_event(unsigned int event) +{ +} + +static inline bool kvm_arch_pv_event_enabled(void) +{ + return false; +} #endif /* __POWERPC_KVM_PARA_H__ */ diff --git a/arch/s390/include/asm/kvm_para.h b/arch/s390/include/asm/kvm_para.h index e0f8423..81d87ec 100644 --- a/arch/s390/include/asm/kvm_para.h +++ b/arch/s390/include/asm/kvm_para.h @@ -154,4 +154,23 @@ static inline bool kvm_check_and_clear_guest_paused(void) return false; } +static inline int kvm_arch_pv_event_init(void) +{ + return 0; +} + +static inline unsigned int kvm_arch_pv_features(void) +{ + return 0; +} + +static inline void kvm_arch_pv_eject_event(unsigned int event) +{ +} + +static inline bool kvm_arch_pv_event_enabled(void) +{ + return false; +} + #endif /* __S390_KVM_PARA_H */ --- a/arch/x86/include/asm/kvm_para.h +++ b/arch/x86/include/asm/kvm_para.h @@ -133,4 +133,24 @@ static inline void kvm_disable_steal_time(void) } #endif +static inline int kvm_arch_pv_event_init(void) +{ + if (!request_region(KVM_PV_EVENT_PORT, 4, KVM_PV_EVENT)) + return -1; + + return 0; +} This should be in a driver in arch/x86/kernel/kvm-panic.c, or so. + +static inline unsigned int kvm_arch_pv_features(void) +{ + return inl(KVM_PV_EVENT_PORT); +} + +static inline void kvm_arch_pv_eject_event(unsigned int event) +{ + outl(event, KVM_PV_EVENT_PORT); +} + +bool kvm_arch_pv_event_enabled(void); + #endif /* _ASM_X86_KVM_PARA_H */ diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h index 06fdbd9..c15ef33 100644 --- a/arch/x86/include/uapi/asm/kvm_para.h +++ b/arch/x86/include/uapi/asm/kvm_para.h @@ -96,5 +96,7 @@ struct kvm_vcpu_pv_apf_data { #define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK #define KVM_PV_EOI_DISABLED 0x0 +#define KVM_PV_EVENT_PORT (0x505UL) + No need for the ioport to be hard coded. What are the options to communicate an address to the guest? An MSR, via ACPI? I'm not quite understanding here. By 'address', you mean an ioport? how to communicate an address? (I have little knowledge about ACPI) #endif /* _UAPI_ASM_X86_KVM_PARA_H */ diff --git a/arch/x86/kernel/kvm.c
Re: [PATCH qemu-kvm] virtfs-proxy: fix build with F18
Michael S. Tsirkin m...@redhat.com writes: Ignoring return value of setfsgid(gid) and setfsuid(uid) causes warnings on F18. Check the return value: man page says glibc returns -1 on error. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- fsdev/virtfs-proxy-helper.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index f9a8270..2f0d2b3 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -282,6 +282,7 @@ static int send_status(int sockfd, struct iovec *iovec, int status) */ static int setfsugid(int uid, int gid) { +int ret; /* * We still need DAC_OVERRIDE because we don't change * supplementary group ids, and hence may be subjected DAC rules @@ -290,8 +291,10 @@ static int setfsugid(int uid, int gid) CAP_DAC_OVERRIDE, }; -setfsgid(gid); -setfsuid(uid); +ret = setfsgid(gid); +assert(ret != -1); +ret = setfsuid(uid); +assert(ret != -1); if (uid != 0 || gid != 0) { return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0); -- MST This got fixed upstream. http://git.qemu.org/?p=qemu.git;a=commitdiff;h=9fd2ecdc8cb2dc1a8a7c57b6c9c60bc9947b6a73 -aneesh -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] kvm-unit-test: more documentation and runner script
On Wed, Feb 27, 2013 at 11:40:37PM +0200, Michael S. Tsirkin wrote: On Wed, Feb 27, 2013 at 06:03:41PM -0300, Lucas Meneghel Rodrigues wrote: On 02/27/2013 05:44 PM, Michael S. Tsirkin wrote: +Using qemu (supported since qemu 1.3): +qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel ./x86/msr.flat I think it is worth here to point out that with new qemu, after the unittest is done, the exit status of qemu is 1, different from the 'old style', whose exit status in successful completion is 0. ^ comment above +exec ${command} $@ ^ What about checking the exit status of qemu here and print something like test $@ PASS or test $@ FAIL? How do we know how to interpret it? Overall I think it's best to rely on test output than on return status. See comment above. Well, test output may be good for humans, but it is really not good for machines [1], that's why when the test suite was developed, the convention was to make qemu to exit with a given return code on success and others on failure. Right but given a qemu binary, how do I find out what it is on success and what it is on failure? Since you know what device you are using you know expected value for successful/failure. Anyway, it was just a suggestion, feel free to disregard it. [1] having to parse the output and try to guess what is a pass or fail is a mess at best, and should be avoided unless we positively have no saner way of doing it. -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH qemu-kvm] virtfs-proxy: fix build with F18
On Thu, Feb 28, 2013 at 09:00:47AM +0200, Michael S. Tsirkin wrote: Ignoring return value of setfsgid(gid) and setfsuid(uid) causes warnings on F18. Check the return value: man page says glibc returns -1 on error. qemu-kvm is no more. It has ceased to be. Not sure what do you want me to do with the patch. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- fsdev/virtfs-proxy-helper.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index f9a8270..2f0d2b3 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -282,6 +282,7 @@ static int send_status(int sockfd, struct iovec *iovec, int status) */ static int setfsugid(int uid, int gid) { +int ret; /* * We still need DAC_OVERRIDE because we don't change * supplementary group ids, and hence may be subjected DAC rules @@ -290,8 +291,10 @@ static int setfsugid(int uid, int gid) CAP_DAC_OVERRIDE, }; -setfsgid(gid); -setfsuid(uid); +ret = setfsgid(gid); +assert(ret != -1); +ret = setfsuid(uid); +assert(ret != -1); if (uid != 0 || gid != 0) { return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0); -- MST -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/6] KVM: Clean up and optimize set_memory_region() - part2
On Thu, Feb 28, 2013 at 10:02:13AM +0900, Takuya Yoshikawa wrote: [ Resending since my email client seemed to fail. ] On Wed, 27 Feb 2013 18:23:45 +0200 Gleb Natapov g...@redhat.com wrote: On Wed, Feb 27, 2013 at 07:41:03PM +0900, Takuya Yoshikawa wrote: Note: this is based on the latest master branch. I'm sending this before 3.9-rc1 is released since this can cause extra conflicts unless we make this available to all arch before we start adding new stuff. I do not quite sure what you want me to do. Why can't this wait for 3.10? Sorry for my confusing explanation. This is exactly for 3.10. I'd like to let the maintainers of arch code know the plan and make them prepared for the possible changes for the next development cycle. It would be nice if this won't make it difficult to sync later: people tend to queue up their own code soon. Make perfect sense. Will be applied after -rc1 is released. At this point master will be merged to next/queue development branches. -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 0/6] kvm: Make ioeventfd usable on s390.
Here's v4 of the ioeventfd for s390 patch set. The most interesting change is the addition of MST's cookie patch, which enhances the virtio-ccw notify hypercall for future performance optimizations. This patch should go in for 3.9. I'd love to see the other patches in 3.9 as well; but I wouldn't mind postponing them to 3.10, your call. v3 - v4: - Pass cookies in virtio-ccw notify hypercall - Coding style v2 - v3: - Added a patch exporting the virtio-ccw api and use it for the diagnose implementation. - Better naming: We're dealing with virtio-ccw notifications only. v1 - v2: - Move irqfd initialization from a module init function to kvm_init, eliminating the need for a second module for kvm/s390. - Use kvm_io_device for s390 css devices. Cornelia Huck (5): KVM: s390: Export virtio-ccw api. KVM: Initialize irqfd from kvm_init(). KVM: Introduce KVM_VIRTIO_CCW_NOTIFY_BUS. KVM: ioeventfd for virtio-ccw devices. KVM: s390: Wire up ioeventfd. Michael S. Tsirkin (1): virtio_ccw: pass a cookie value to kvm hypercall Documentation/virtual/kvm/api.txt | 8 arch/s390/include/uapi/asm/Kbuild | 1 + arch/s390/include/uapi/asm/virtio-ccw.h | 21 + arch/s390/kvm/Kconfig | 1 + arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/diag.c| 26 ++ arch/s390/kvm/kvm-s390.c| 1 + drivers/s390/kvm/virtio_ccw.c | 16 +--- include/linux/kvm_host.h| 14 ++ include/uapi/linux/kvm.h| 3 +++ virt/kvm/eventfd.c | 24 +++- virt/kvm/kvm_main.c | 6 ++ 12 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 arch/s390/include/uapi/asm/virtio-ccw.h -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 1/6] virtio_ccw: pass a cookie value to kvm hypercall
From: Michael S. Tsirkin m...@redhat.com Lookups by channel/vq pair on host during virtio notifications might be expensive. Interpret hypercall return value as a cookie which host can use to do device lookups for the next notification more efficiently. [CH: Fix line 80 chars] Tested-by: Christian Borntraeger borntrae...@de.ibm.com Reviewed-by: Christian Borntraeger borntrae...@de.ibm.com Signed-off-by: Michael S. Tsirkin m...@redhat.com Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- drivers/s390/kvm/virtio_ccw.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c index 3217dfe..259a2fb 100644 --- a/drivers/s390/kvm/virtio_ccw.c +++ b/drivers/s390/kvm/virtio_ccw.c @@ -77,6 +77,7 @@ struct virtio_ccw_vq_info { void *queue; struct vq_info_block *info_block; struct list_head node; + long cookie; }; #define KVM_VIRTIO_CCW_RING_ALIGN 4096 @@ -145,15 +146,18 @@ static int ccw_io_helper(struct virtio_ccw_device *vcdev, } static inline long do_kvm_notify(struct subchannel_id schid, -unsigned long queue_index) +unsigned long queue_index, +long cookie) { register unsigned long __nr asm(1) = KVM_S390_VIRTIO_CCW_NOTIFY; register struct subchannel_id __schid asm(2) = schid; register unsigned long __index asm(3) = queue_index; register long __rc asm(2); + register long __cookie asm(4) = cookie; asm volatile (diag 2,4,0x500\n - : =d (__rc) : d (__nr), d (__schid), d (__index) + : =d (__rc) : d (__nr), d (__schid), d (__index), + d(__cookie) : memory, cc); return __rc; } @@ -166,7 +170,8 @@ static void virtio_ccw_kvm_notify(struct virtqueue *vq) vcdev = to_vc_device(info-vq-vdev); ccw_device_get_schid(vcdev-cdev, schid); - do_kvm_notify(schid, virtqueue_get_queue_index(vq)); + info-cookie = do_kvm_notify(schid, virtqueue_get_queue_index(vq), +info-cookie); } static int virtio_ccw_read_vq_conf(struct virtio_ccw_device *vcdev, -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 5/6] KVM: ioeventfd for virtio-ccw devices.
Enhance KVM_IOEVENTFD with a new flag that allows to attach to virtio-ccw devices on s390 via the KVM_VIRTIO_CCW_NOTIFY_BUS. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- Documentation/virtual/kvm/api.txt | 8 include/uapi/linux/kvm.h | 3 +++ virt/kvm/eventfd.c| 17 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index c2534c3..86232d6 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -1468,15 +1468,23 @@ struct kvm_ioeventfd { __u8 pad[36]; }; +For the special case of virtio-ccw devices on s390, the ioevent is matched +to a subchannel/virtqueue tuple instead. + The following flags are defined: #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 kvm_ioeventfd_flag_nr_datamatch) #define KVM_IOEVENTFD_FLAG_PIO (1 kvm_ioeventfd_flag_nr_pio) #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 kvm_ioeventfd_flag_nr_deassign) +#define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ + (1 kvm_ioeventfd_flag_nr_virtio_ccw_notify) If datamatch flag is set, the event will be signaled only if the written value to the registered address is equal to datamatch in struct kvm_ioeventfd. +For virtio-ccw devices, addr contains the subchannel id and datamatch the +virtqueue index. + 4.60 KVM_DIRTY_TLB diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 9a2db57..8f3e5ae 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -448,12 +448,15 @@ enum { kvm_ioeventfd_flag_nr_datamatch, kvm_ioeventfd_flag_nr_pio, kvm_ioeventfd_flag_nr_deassign, + kvm_ioeventfd_flag_nr_virtio_ccw_notify, kvm_ioeventfd_flag_nr_max, }; #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 kvm_ioeventfd_flag_nr_datamatch) #define KVM_IOEVENTFD_FLAG_PIO (1 kvm_ioeventfd_flag_nr_pio) #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 kvm_ioeventfd_flag_nr_deassign) +#define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ + (1 kvm_ioeventfd_flag_nr_virtio_ccw_notify) #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 kvm_ioeventfd_flag_nr_max) - 1) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index f0ced1a..c9b6494 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -675,15 +675,24 @@ ioeventfd_check_collision(struct kvm *kvm, struct _ioeventfd *p) return false; } +static enum kvm_bus ioeventfd_bus_from_flags(__u32 flags) +{ + if (flags KVM_IOEVENTFD_FLAG_PIO) + return KVM_PIO_BUS; + if (flags KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY) + return KVM_VIRTIO_CCW_NOTIFY_BUS; + return KVM_MMIO_BUS; +} + static int kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) { - int pio = args-flags KVM_IOEVENTFD_FLAG_PIO; - enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS; + enum kvm_bus bus_idx; struct _ioeventfd*p; struct eventfd_ctx *eventfd; int ret; + bus_idx = ioeventfd_bus_from_flags(args-flags); /* must be natural-word sized */ switch (args-len) { case 1: @@ -758,12 +767,12 @@ fail: static int kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) { - int pio = args-flags KVM_IOEVENTFD_FLAG_PIO; - enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS; + enum kvm_bus bus_idx; struct _ioeventfd*p, *tmp; struct eventfd_ctx *eventfd; int ret = -ENOENT; + bus_idx = ioeventfd_bus_from_flags(args-flags); eventfd = eventfd_ctx_fdget(args-fd); if (IS_ERR(eventfd)) return PTR_ERR(eventfd); -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 4/6] KVM: Introduce KVM_VIRTIO_CCW_NOTIFY_BUS.
Add a new bus type for virtio-ccw devices on s390. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- include/linux/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 3b768ef..206247f 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -148,6 +148,7 @@ struct kvm_io_bus { enum kvm_bus { KVM_MMIO_BUS, KVM_PIO_BUS, + KVM_VIRTIO_CCW_NOTIFY_BUS, KVM_NR_BUSES }; -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 3/6] KVM: Initialize irqfd from kvm_init().
Currently, eventfd introduces module_init/module_exit functions to initialize/cleanup the irqfd workqueue. This only works, however, if no other module_init/module_exit functions are built into the same module. Let's just move the initialization and cleanup to kvm_init and kvm_exit. This way, it is also clearer where kvm startup may fail. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- include/linux/kvm_host.h | 13 + virt/kvm/eventfd.c | 7 ++- virt/kvm/kvm_main.c | 6 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 722cae7..3b768ef 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -423,6 +423,19 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); int __must_check vcpu_load(struct kvm_vcpu *vcpu); void vcpu_put(struct kvm_vcpu *vcpu); +#ifdef __KVM_HAVE_IOAPIC +int kvm_irqfd_init(void); +void kvm_irqfd_exit(void); +#else +static inline int kvm_irqfd_init(void) +{ + return 0; +} + +static inline void kvm_irqfd_exit(void) +{ +} +#endif int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, struct module *module); void kvm_exit(void); diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index b6eea5c..f0ced1a 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -544,7 +544,7 @@ void kvm_irq_routing_update(struct kvm *kvm, * aggregated from all vm* instances. We need our own isolated single-thread * queue to prevent deadlock against flushing the normal work-queue. */ -static int __init irqfd_module_init(void) +int kvm_irqfd_init(void) { irqfd_cleanup_wq = create_singlethread_workqueue(kvm-irqfd-cleanup); if (!irqfd_cleanup_wq) @@ -553,13 +553,10 @@ static int __init irqfd_module_init(void) return 0; } -static void __exit irqfd_module_exit(void) +void kvm_irqfd_exit(void) { destroy_workqueue(irqfd_cleanup_wq); } - -module_init(irqfd_module_init); -module_exit(irqfd_module_exit); #endif /* diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index adc68fe..7c188a3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2920,6 +2920,9 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, int r; int cpu; + r = kvm_irqfd_init(); + if (r) + goto out_irqfd; r = kvm_arch_init(opaque); if (r) goto out_fail; @@ -3000,6 +3003,8 @@ out_free_0a: out_free_0: kvm_arch_exit(); out_fail: + kvm_irqfd_exit(); +out_irqfd: return r; } EXPORT_SYMBOL_GPL(kvm_init); @@ -3016,6 +3021,7 @@ void kvm_exit(void) on_each_cpu(hardware_disable_nolock, NULL, 1); kvm_arch_hardware_unsetup(); kvm_arch_exit(); + kvm_irqfd_exit(); free_cpumask_var(cpus_hardware_enabled); } EXPORT_SYMBOL_GPL(kvm_exit); -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 2/6] KVM: s390: Export virtio-ccw api.
Export the virtio-ccw api in a header for usage by other code. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- arch/s390/include/uapi/asm/Kbuild | 1 + arch/s390/include/uapi/asm/virtio-ccw.h | 21 + drivers/s390/kvm/virtio_ccw.c | 5 + 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 arch/s390/include/uapi/asm/virtio-ccw.h diff --git a/arch/s390/include/uapi/asm/Kbuild b/arch/s390/include/uapi/asm/Kbuild index 7bf68ff..9ccd190 100644 --- a/arch/s390/include/uapi/asm/Kbuild +++ b/arch/s390/include/uapi/asm/Kbuild @@ -44,5 +44,6 @@ header-y += termios.h header-y += types.h header-y += ucontext.h header-y += unistd.h +header-y += virtio-ccw.h header-y += vtoc.h header-y += zcrypt.h diff --git a/arch/s390/include/uapi/asm/virtio-ccw.h b/arch/s390/include/uapi/asm/virtio-ccw.h new file mode 100644 index 000..a9a4ebf --- /dev/null +++ b/arch/s390/include/uapi/asm/virtio-ccw.h @@ -0,0 +1,21 @@ +/* + * Definitions for virtio-ccw devices. + * + * Copyright IBM Corp. 2013 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (version 2 only) + * as published by the Free Software Foundation. + * + * Author(s): Cornelia Huck cornelia.h...@de.ibm.com + */ +#ifndef __KVM_VIRTIO_CCW_H +#define __KVM_VIRTIO_CCW_H + +/* Alignment of vring buffers. */ +#define KVM_VIRTIO_CCW_RING_ALIGN 4096 + +/* Subcode for diagnose 500 (virtio hypercall). */ +#define KVM_S390_VIRTIO_CCW_NOTIFY 3 + +#endif diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c index 259a2fb..bf5ba3b 100644 --- a/drivers/s390/kvm/virtio_ccw.c +++ b/drivers/s390/kvm/virtio_ccw.c @@ -31,6 +31,7 @@ #include asm/irq.h #include asm/cio.h #include asm/ccwdev.h +#include asm/virtio-ccw.h /* * virtio related functions @@ -80,10 +81,6 @@ struct virtio_ccw_vq_info { long cookie; }; -#define KVM_VIRTIO_CCW_RING_ALIGN 4096 - -#define KVM_S390_VIRTIO_CCW_NOTIFY 3 - #define CCW_CMD_SET_VQ 0x13 #define CCW_CMD_VDEV_RESET 0x33 #define CCW_CMD_SET_IND 0x43 -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 6/6] KVM: s390: Wire up ioeventfd.
Enable ioeventfd support on s390 and hook up diagnose 500 virtio-ccw notifications. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- arch/s390/kvm/Kconfig| 1 + arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/diag.c | 26 ++ arch/s390/kvm/kvm-s390.c | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index b58dd86..3c43e30 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig @@ -22,6 +22,7 @@ config KVM select PREEMPT_NOTIFIERS select ANON_INODES select HAVE_KVM_CPU_RELAX_INTERCEPT + select HAVE_KVM_EVENTFD ---help--- Support hosting paravirtualized guest machines using the SIE virtualization capability on the mainframe. This should work diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 3975722..8fe9d65 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -6,7 +6,7 @@ # it under the terms of the GNU General Public License (version 2 only) # as published by the Free Software Foundation. -common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o) +common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o eventfd.o) ccflags-y := -Ivirt/kvm -Iarch/s390/kvm diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c index a390687..96907f2 100644 --- a/arch/s390/kvm/diag.c +++ b/arch/s390/kvm/diag.c @@ -13,6 +13,7 @@ #include linux/kvm.h #include linux/kvm_host.h +#include asm/virtio-ccw.h #include kvm-s390.h #include trace.h #include trace-s390.h @@ -104,6 +105,29 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu) return -EREMOTE; } +static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu) +{ + int ret, idx; + + /* No virtio-ccw notification? Get out quickly. */ + if (!vcpu-kvm-arch.css_support || + (vcpu-run-s.regs.gprs[1] != KVM_S390_VIRTIO_CCW_NOTIFY)) + return -EOPNOTSUPP; + + idx = srcu_read_lock(vcpu-kvm-srcu); + /* +* The layout is as follows: +* - gpr 2 contains the subchannel id (passed as addr) +* - gpr 3 contains the virtqueue index (passed as datamatch) +*/ + ret = kvm_io_bus_write(vcpu-kvm, KVM_VIRTIO_CCW_NOTIFY_BUS, + vcpu-run-s.regs.gprs[2], + 8, vcpu-run-s.regs.gprs[3]); + srcu_read_unlock(vcpu-kvm-srcu, idx); + /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */ + return ret; +} + int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) { int code = (vcpu-arch.sie_block-ipb 0xfff) 16; @@ -118,6 +142,8 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) return __diag_time_slice_end_directed(vcpu); case 0x308: return __diag_ipl_functions(vcpu); + case 0x500: + return __diag_virtio_hypercall(vcpu); default: return -EOPNOTSUPP; } diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index f822d36..04d2454 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -142,6 +142,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_ONE_REG: case KVM_CAP_ENABLE_CAP: case KVM_CAP_S390_CSS_SUPPORT: + case KVM_CAP_IOEVENTFD: r = 1; break; case KVM_CAP_NR_VCPUS: -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[GIT PULL] KVM fixe for 3.9
Linus, Please pull from git://git.kernel.org/pub/scm/virt/kvm/kvm.git master To receive the following KVM bug fix. Peter Hurley (1): x86/kvm: Fix pvclock vsyscall fixmap arch/x86/kernel/pvclock.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
unable to get guests network working ( VLAN 802.1q )
Hello I'm new to KVM ... I've setup an hypervisor on a Debian server (7.0 RC1 ) and I have followed usual tutorial to do so. Everything seems work well except I am unable to connect the first guest I've build to my LAN. I use 802.1q VLAN , the Cisco switch is configured to use it and transport the VLANs on the connected port to the server the 8021q module is loaded. interface GigabitEthernet1/0/6 description HYPVM switchport trunk encapsulation dot1q switchport trunk allowed vlan 2,30,110,150 switchport mode trunk spanning-tree portfast trunk the /etc/network/interfaces of the server is pretty simple auto lo eth0 br-110 br-30 iface lo inet loopback iface eth0 inet manual iface br-30 inet static bridge_ports eth0.30 bridge_maxwait 0 bridge_stp off bridge_fd 0 address 147.215.1.25 netmask 255.255.255.0 broadcast 147.215.1.255 network 147.215.1.0 gateway 147.215.1.1 iface br-110 inet static bridge_ports eth0.110 bridge_maxwait 0 bridge_stp off bridge_fd 0 - VLAN numbers are 30 and 110 , I can connect to the br-30 interface from the LAN. the guest host is supposed to have an IP address in the 147.215.110.0 network ( VLAN 110 ). I can build it with virt-manager but when it try to access to the LAN it fails ... If someone could help ... thanks in advance -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] KVM: nVMX: Fix setting of CR0 and CR4 in guest mode
The logic for calculating the value with which we call kvm_set_cr0/4 was broken (will definitely be visible with nested unrestricted guest mode support). Also, we performed the check regarding CR0_ALWAYSON too early when in guest mode. What really needs to be done on both CR0 and CR4 is to mask out L1-owned bits and merge them in from GUEST_CR0/4. In contrast, arch.cr0/4 and arch.cr0/4_guest_owned_bits contain the mangled L0+L1 state and, thus, are not suited as input. For both CRs, we can then apply the check against VMXON_CRx_ALWAYSON and refuse the update if it fails. To be fully consistent, we implement this check now also for CR4. Finally, we have to set the shadow to the value L2 wanted to write originally. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- Found while making unrestricted guest mode working. Not sure what impact the bugs had on current feature level, if any. For interested folks, I've pushed my nEPT environment here: git://git.kiszka.org/linux-kvm.git nept-hacking arch/x86/kvm/vmx.c | 49 ++--- 1 files changed, 30 insertions(+), 19 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7cc566b..d1dac08 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4605,37 +4605,48 @@ vmx_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall) /* called to set cr0 as appropriate for a mov-to-cr0 exit. */ static int handle_set_cr0(struct kvm_vcpu *vcpu, unsigned long val) { - if (to_vmx(vcpu)-nested.vmxon - ((val VMXON_CR0_ALWAYSON) != VMXON_CR0_ALWAYSON)) - return 1; - if (is_guest_mode(vcpu)) { - /* -* We get here when L2 changed cr0 in a way that did not change -* any of L1's shadowed bits (see nested_vmx_exit_handled_cr), -* but did change L0 shadowed bits. This can currently happen -* with the TS bit: L0 may want to leave TS on (for lazy fpu -* loading) while pretending to allow the guest to change it. -*/ - if (kvm_set_cr0(vcpu, (val vcpu-arch.cr0_guest_owned_bits) | -(vcpu-arch.cr0 ~vcpu-arch.cr0_guest_owned_bits))) + struct vmcs12 *vmcs12 = get_vmcs12(vcpu); + unsigned long orig_val = val; + + val = (val ~vmcs12-cr0_guest_host_mask) | + (vmcs_read64(GUEST_CR0) vmcs12-cr0_guest_host_mask); + if ((val VMXON_CR0_ALWAYSON) != VMXON_CR0_ALWAYSON) + return 1; + + if (kvm_set_cr0(vcpu, val)) return 1; - vmcs_writel(CR0_READ_SHADOW, val); + vmcs_writel(CR0_READ_SHADOW, orig_val); return 0; - } else + } else { + if (to_vmx(vcpu)-nested.vmxon + ((val VMXON_CR0_ALWAYSON) != VMXON_CR0_ALWAYSON)) + return 1; return kvm_set_cr0(vcpu, val); + } } static int handle_set_cr4(struct kvm_vcpu *vcpu, unsigned long val) { if (is_guest_mode(vcpu)) { - if (kvm_set_cr4(vcpu, (val vcpu-arch.cr4_guest_owned_bits) | -(vcpu-arch.cr4 ~vcpu-arch.cr4_guest_owned_bits))) + struct vmcs12 *vmcs12 = get_vmcs12(vcpu); + unsigned long orig_val = val; + + val = (val ~vmcs12-cr4_guest_host_mask) | + (vmcs_readl(GUEST_CR4) vmcs12-cr4_guest_host_mask); + if ((val VMXON_CR4_ALWAYSON) != VMXON_CR4_ALWAYSON) + return 1; + + if (kvm_set_cr4(vcpu, val)) return 1; - vmcs_writel(CR4_READ_SHADOW, val); + vmcs_writel(CR4_READ_SHADOW, orig_val); return 0; - } else + } else { + if (to_vmx(vcpu)-nested.vmxon + ((val VMXON_CR4_ALWAYSON) != VMXON_CR4_ALWAYSON)) + return 1; return kvm_set_cr4(vcpu, val); + } } /* called to set cr0 as approriate for clts instruction exit. */ -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] kvm-unit-test: more documentation and runner script
On Thu, Feb 28, 2013 at 11:06:20AM +0200, Gleb Natapov wrote: On Wed, Feb 27, 2013 at 11:40:37PM +0200, Michael S. Tsirkin wrote: On Wed, Feb 27, 2013 at 06:03:41PM -0300, Lucas Meneghel Rodrigues wrote: On 02/27/2013 05:44 PM, Michael S. Tsirkin wrote: +Using qemu (supported since qemu 1.3): +qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel ./x86/msr.flat I think it is worth here to point out that with new qemu, after the unittest is done, the exit status of qemu is 1, different from the 'old style', whose exit status in successful completion is 0. ^ comment above +exec ${command} $@ ^ What about checking the exit status of qemu here and print something like test $@ PASS or test $@ FAIL? How do we know how to interpret it? Overall I think it's best to rely on test output than on return status. See comment above. Well, test output may be good for humans, but it is really not good for machines [1], that's why when the test suite was developed, the convention was to make qemu to exit with a given return code on success and others on failure. Right but given a qemu binary, how do I find out what it is on success and what it is on failure? Since you know what device you are using you know expected value for successful/failure. So exit status is 1 for success 0 for failure? Anyway, it was just a suggestion, feel free to disregard it. [1] having to parse the output and try to guess what is a pass or fail is a mess at best, and should be avoided unless we positively have no saner way of doing it. -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/6] KVM: Clean up and optimize set_memory_region() - part2
On Wed, 27 Feb 2013 19:41:03 +0900 Takuya Yoshikawa yoshikawa_takuya...@lab.ntt.co.jp wrote: Note: this is based on the latest master branch. I'm sending this before 3.9-rc1 is released since this can cause extra conflicts unless we make this available to all arch before we start adding new stuff. Please review: every change is trivial and should not change anything. Takuya Yoshikawa (6): KVM: set_memory_region: Drop user_alloc from prepare/commit_memory_region() KVM: set_memory_region: Drop user_alloc from set_memory_region() KVM: set_memory_region: Make kvm_mr_change available to arch code KVM: set_memory_region: Refactor prepare_memory_region() KVM: set_memory_region: Refactor commit_memory_region() KVM: ARM: Remove kvm_arch_set_memory_region() arch/arm/kvm/arm.c | 15 ++-- arch/ia64/kvm/kvm-ia64.c | 25 ++--- arch/powerpc/include/asm/kvm_ppc.h |2 +- arch/powerpc/kvm/book3s_hv.c |4 +- arch/powerpc/kvm/book3s_pr.c |2 +- arch/powerpc/kvm/booke.c |2 +- arch/powerpc/kvm/powerpc.c | 13 +-- arch/s390/kvm/kvm-s390.c | 10 ++-- arch/x86/kvm/vmx.c |6 ++-- arch/x86/kvm/x86.c | 25 + include/linux/kvm_host.h | 35 +- virt/kvm/kvm_main.c| 40 --- 12 files changed, 67 insertions(+), 112 deletions(-) Looks fine on s390. Tested-by: Cornelia Huck cornelia.h...@de.ibm.com -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 6/6] KVM: s390: Wire up ioeventfd.
On Thu, Feb 28, 2013 at 10:22:32AM +0100, Cornelia Huck wrote: Enable ioeventfd support on s390 and hook up diagnose 500 virtio-ccw notifications. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- arch/s390/kvm/Kconfig| 1 + arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/diag.c | 26 ++ arch/s390/kvm/kvm-s390.c | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index b58dd86..3c43e30 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig @@ -22,6 +22,7 @@ config KVM select PREEMPT_NOTIFIERS select ANON_INODES select HAVE_KVM_CPU_RELAX_INTERCEPT + select HAVE_KVM_EVENTFD ---help--- Support hosting paravirtualized guest machines using the SIE virtualization capability on the mainframe. This should work diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 3975722..8fe9d65 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -6,7 +6,7 @@ # it under the terms of the GNU General Public License (version 2 only) # as published by the Free Software Foundation. -common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o) +common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o eventfd.o) ccflags-y := -Ivirt/kvm -Iarch/s390/kvm diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c index a390687..96907f2 100644 --- a/arch/s390/kvm/diag.c +++ b/arch/s390/kvm/diag.c @@ -13,6 +13,7 @@ #include linux/kvm.h #include linux/kvm_host.h +#include asm/virtio-ccw.h #include kvm-s390.h #include trace.h #include trace-s390.h @@ -104,6 +105,29 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu) return -EREMOTE; } +static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu) +{ + int ret, idx; + + /* No virtio-ccw notification? Get out quickly. */ + if (!vcpu-kvm-arch.css_support || + (vcpu-run-s.regs.gprs[1] != KVM_S390_VIRTIO_CCW_NOTIFY)) + return -EOPNOTSUPP; + + idx = srcu_read_lock(vcpu-kvm-srcu); + /* + * The layout is as follows: + * - gpr 2 contains the subchannel id (passed as addr) + * - gpr 3 contains the virtqueue index (passed as datamatch) + */ + ret = kvm_io_bus_write(vcpu-kvm, KVM_VIRTIO_CCW_NOTIFY_BUS, + vcpu-run-s.regs.gprs[2], + 8, vcpu-run-s.regs.gprs[3]); + srcu_read_unlock(vcpu-kvm-srcu, idx); + /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */ + return ret; Yes but it returns 8 on success. You probably want 0. So: return ret 0 ? ret : 0; +} + int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) { int code = (vcpu-arch.sie_block-ipb 0xfff) 16; @@ -118,6 +142,8 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) return __diag_time_slice_end_directed(vcpu); case 0x308: return __diag_ipl_functions(vcpu); + case 0x500: + return __diag_virtio_hypercall(vcpu); default: return -EOPNOTSUPP; } diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index f822d36..04d2454 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -142,6 +142,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_ONE_REG: case KVM_CAP_ENABLE_CAP: case KVM_CAP_S390_CSS_SUPPORT: + case KVM_CAP_IOEVENTFD: r = 1; break; case KVM_CAP_NR_VCPUS: -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] kvm-unit-test: more documentation and runner script
On Thu, Feb 28, 2013 at 11:45:33AM +0200, Michael S. Tsirkin wrote: On Thu, Feb 28, 2013 at 11:06:20AM +0200, Gleb Natapov wrote: On Wed, Feb 27, 2013 at 11:40:37PM +0200, Michael S. Tsirkin wrote: On Wed, Feb 27, 2013 at 06:03:41PM -0300, Lucas Meneghel Rodrigues wrote: On 02/27/2013 05:44 PM, Michael S. Tsirkin wrote: +Using qemu (supported since qemu 1.3): +qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel ./x86/msr.flat I think it is worth here to point out that with new qemu, after the unittest is done, the exit status of qemu is 1, different from the 'old style', whose exit status in successful completion is 0. ^ comment above +exec ${command} $@ ^ What about checking the exit status of qemu here and print something like test $@ PASS or test $@ FAIL? How do we know how to interpret it? Overall I think it's best to rely on test output than on return status. See comment above. Well, test output may be good for humans, but it is really not good for machines [1], that's why when the test suite was developed, the convention was to make qemu to exit with a given return code on success and others on failure. Right but given a qemu binary, how do I find out what it is on success and what it is on failure? Since you know what device you are using you know expected value for successful/failure. So exit status is 1 for success 0 for failure? As Lucas said above upstream is different from qemu-kvm unfortunately. On upstream you need to shift return value right for 1 bit to get to the tests return value (why?) and then 0 will be success otherwise failure. -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: What cpu for 60-120 vmы?
ciao Vasiliy, What is the best for some small vms? 2-Xeon E5520 or 1- E5-2620 Second have more performance but only one. First have less perfarmance.. What is the best - performance of single cpu or count of cpus with less performance? usually the bottleneck is the storage, not the cpu power But of course it depends on what your VM have to do... high cpu calculus? web server? mail server? multimedia streaming? . ciao -- Paolo Pedaletti -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 6/6] KVM: s390: Wire up ioeventfd.
On Thu, 28 Feb 2013 11:50:45 +0200 Michael S. Tsirkin m...@redhat.com wrote: On Thu, Feb 28, 2013 at 10:22:32AM +0100, Cornelia Huck wrote: Enable ioeventfd support on s390 and hook up diagnose 500 virtio-ccw notifications. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- arch/s390/kvm/Kconfig| 1 + arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/diag.c | 26 ++ arch/s390/kvm/kvm-s390.c | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index b58dd86..3c43e30 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig @@ -22,6 +22,7 @@ config KVM select PREEMPT_NOTIFIERS select ANON_INODES select HAVE_KVM_CPU_RELAX_INTERCEPT + select HAVE_KVM_EVENTFD ---help--- Support hosting paravirtualized guest machines using the SIE virtualization capability on the mainframe. This should work diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 3975722..8fe9d65 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -6,7 +6,7 @@ # it under the terms of the GNU General Public License (version 2 only) # as published by the Free Software Foundation. -common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o) +common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o eventfd.o) ccflags-y := -Ivirt/kvm -Iarch/s390/kvm diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c index a390687..96907f2 100644 --- a/arch/s390/kvm/diag.c +++ b/arch/s390/kvm/diag.c @@ -13,6 +13,7 @@ #include linux/kvm.h #include linux/kvm_host.h +#include asm/virtio-ccw.h #include kvm-s390.h #include trace.h #include trace-s390.h @@ -104,6 +105,29 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu) return -EREMOTE; } +static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu) +{ + int ret, idx; + + /* No virtio-ccw notification? Get out quickly. */ + if (!vcpu-kvm-arch.css_support || + (vcpu-run-s.regs.gprs[1] != KVM_S390_VIRTIO_CCW_NOTIFY)) + return -EOPNOTSUPP; + + idx = srcu_read_lock(vcpu-kvm-srcu); + /* +* The layout is as follows: +* - gpr 2 contains the subchannel id (passed as addr) +* - gpr 3 contains the virtqueue index (passed as datamatch) +*/ + ret = kvm_io_bus_write(vcpu-kvm, KVM_VIRTIO_CCW_NOTIFY_BUS, + vcpu-run-s.regs.gprs[2], + 8, vcpu-run-s.regs.gprs[3]); + srcu_read_unlock(vcpu-kvm-srcu, idx); + /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */ + return ret; Yes but it returns 8 on success. You probably want 0. So: return ret 0 ? ret : 0; Whoops. Doesn't seem to have hurt, though. v6 will come up shortly. +} + int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) { int code = (vcpu-arch.sie_block-ipb 0xfff) 16; @@ -118,6 +142,8 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) return __diag_time_slice_end_directed(vcpu); case 0x308: return __diag_ipl_functions(vcpu); + case 0x500: + return __diag_virtio_hypercall(vcpu); default: return -EOPNOTSUPP; } diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index f822d36..04d2454 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -142,6 +142,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_ONE_REG: case KVM_CAP_ENABLE_CAP: case KVM_CAP_S390_CSS_SUPPORT: + case KVM_CAP_IOEVENTFD: r = 1; break; case KVM_CAP_NR_VCPUS: -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 6/6] KVM: s390: Wire up ioeventfd.
On Thu, Feb 28, 2013 at 11:20:13AM +0100, Cornelia Huck wrote: Whoops. Doesn't seem to have hurt, though. v6 will come up shortly. Are you going to skip v5? -- Gleb. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 6/6] KVM: s390: Wire up ioeventfd.
On Thu, 28 Feb 2013 12:24:19 +0200 Gleb Natapov g...@redhat.com wrote: On Thu, Feb 28, 2013 at 11:20:13AM +0100, Cornelia Huck wrote: Whoops. Doesn't seem to have hurt, though. v6 will come up shortly. Are you going to skip v5? -- Gleb. I meant v5 (-ENOCOFFEE). -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: What cpu for 60-120 vmы?
ciao Vasiliy, Each vm have apache+mysql so huge RAM (for web and db cache) and fast storage (for db) ciao -- Paolo Pedaletti -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 1/6] virtio_ccw: pass a cookie value to kvm hypercall
From: Michael S. Tsirkin m...@redhat.com Lookups by channel/vq pair on host during virtio notifications might be expensive. Interpret hypercall return value as a cookie which host can use to do device lookups for the next notification more efficiently. [CH: Fix line 80 chars] Tested-by: Christian Borntraeger borntrae...@de.ibm.com Reviewed-by: Christian Borntraeger borntrae...@de.ibm.com Signed-off-by: Michael S. Tsirkin m...@redhat.com Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- drivers/s390/kvm/virtio_ccw.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c index 3217dfe..259a2fb 100644 --- a/drivers/s390/kvm/virtio_ccw.c +++ b/drivers/s390/kvm/virtio_ccw.c @@ -77,6 +77,7 @@ struct virtio_ccw_vq_info { void *queue; struct vq_info_block *info_block; struct list_head node; + long cookie; }; #define KVM_VIRTIO_CCW_RING_ALIGN 4096 @@ -145,15 +146,18 @@ static int ccw_io_helper(struct virtio_ccw_device *vcdev, } static inline long do_kvm_notify(struct subchannel_id schid, -unsigned long queue_index) +unsigned long queue_index, +long cookie) { register unsigned long __nr asm(1) = KVM_S390_VIRTIO_CCW_NOTIFY; register struct subchannel_id __schid asm(2) = schid; register unsigned long __index asm(3) = queue_index; register long __rc asm(2); + register long __cookie asm(4) = cookie; asm volatile (diag 2,4,0x500\n - : =d (__rc) : d (__nr), d (__schid), d (__index) + : =d (__rc) : d (__nr), d (__schid), d (__index), + d(__cookie) : memory, cc); return __rc; } @@ -166,7 +170,8 @@ static void virtio_ccw_kvm_notify(struct virtqueue *vq) vcdev = to_vc_device(info-vq-vdev); ccw_device_get_schid(vcdev-cdev, schid); - do_kvm_notify(schid, virtqueue_get_queue_index(vq)); + info-cookie = do_kvm_notify(schid, virtqueue_get_queue_index(vq), +info-cookie); } static int virtio_ccw_read_vq_conf(struct virtio_ccw_device *vcdev, -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 2/6] KVM: s390: Export virtio-ccw api.
Export the virtio-ccw api in a header for usage by other code. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- arch/s390/include/uapi/asm/Kbuild | 1 + arch/s390/include/uapi/asm/virtio-ccw.h | 21 + drivers/s390/kvm/virtio_ccw.c | 5 + 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 arch/s390/include/uapi/asm/virtio-ccw.h diff --git a/arch/s390/include/uapi/asm/Kbuild b/arch/s390/include/uapi/asm/Kbuild index 7bf68ff..9ccd190 100644 --- a/arch/s390/include/uapi/asm/Kbuild +++ b/arch/s390/include/uapi/asm/Kbuild @@ -44,5 +44,6 @@ header-y += termios.h header-y += types.h header-y += ucontext.h header-y += unistd.h +header-y += virtio-ccw.h header-y += vtoc.h header-y += zcrypt.h diff --git a/arch/s390/include/uapi/asm/virtio-ccw.h b/arch/s390/include/uapi/asm/virtio-ccw.h new file mode 100644 index 000..a9a4ebf --- /dev/null +++ b/arch/s390/include/uapi/asm/virtio-ccw.h @@ -0,0 +1,21 @@ +/* + * Definitions for virtio-ccw devices. + * + * Copyright IBM Corp. 2013 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (version 2 only) + * as published by the Free Software Foundation. + * + * Author(s): Cornelia Huck cornelia.h...@de.ibm.com + */ +#ifndef __KVM_VIRTIO_CCW_H +#define __KVM_VIRTIO_CCW_H + +/* Alignment of vring buffers. */ +#define KVM_VIRTIO_CCW_RING_ALIGN 4096 + +/* Subcode for diagnose 500 (virtio hypercall). */ +#define KVM_S390_VIRTIO_CCW_NOTIFY 3 + +#endif diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c index 259a2fb..bf5ba3b 100644 --- a/drivers/s390/kvm/virtio_ccw.c +++ b/drivers/s390/kvm/virtio_ccw.c @@ -31,6 +31,7 @@ #include asm/irq.h #include asm/cio.h #include asm/ccwdev.h +#include asm/virtio-ccw.h /* * virtio related functions @@ -80,10 +81,6 @@ struct virtio_ccw_vq_info { long cookie; }; -#define KVM_VIRTIO_CCW_RING_ALIGN 4096 - -#define KVM_S390_VIRTIO_CCW_NOTIFY 3 - #define CCW_CMD_SET_VQ 0x13 #define CCW_CMD_VDEV_RESET 0x33 #define CCW_CMD_SET_IND 0x43 -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 3/6] KVM: Initialize irqfd from kvm_init().
Currently, eventfd introduces module_init/module_exit functions to initialize/cleanup the irqfd workqueue. This only works, however, if no other module_init/module_exit functions are built into the same module. Let's just move the initialization and cleanup to kvm_init and kvm_exit. This way, it is also clearer where kvm startup may fail. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- include/linux/kvm_host.h | 13 + virt/kvm/eventfd.c | 7 ++- virt/kvm/kvm_main.c | 6 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 722cae7..3b768ef 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -423,6 +423,19 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); int __must_check vcpu_load(struct kvm_vcpu *vcpu); void vcpu_put(struct kvm_vcpu *vcpu); +#ifdef __KVM_HAVE_IOAPIC +int kvm_irqfd_init(void); +void kvm_irqfd_exit(void); +#else +static inline int kvm_irqfd_init(void) +{ + return 0; +} + +static inline void kvm_irqfd_exit(void) +{ +} +#endif int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, struct module *module); void kvm_exit(void); diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index b6eea5c..f0ced1a 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -544,7 +544,7 @@ void kvm_irq_routing_update(struct kvm *kvm, * aggregated from all vm* instances. We need our own isolated single-thread * queue to prevent deadlock against flushing the normal work-queue. */ -static int __init irqfd_module_init(void) +int kvm_irqfd_init(void) { irqfd_cleanup_wq = create_singlethread_workqueue(kvm-irqfd-cleanup); if (!irqfd_cleanup_wq) @@ -553,13 +553,10 @@ static int __init irqfd_module_init(void) return 0; } -static void __exit irqfd_module_exit(void) +void kvm_irqfd_exit(void) { destroy_workqueue(irqfd_cleanup_wq); } - -module_init(irqfd_module_init); -module_exit(irqfd_module_exit); #endif /* diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index adc68fe..7c188a3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2920,6 +2920,9 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, int r; int cpu; + r = kvm_irqfd_init(); + if (r) + goto out_irqfd; r = kvm_arch_init(opaque); if (r) goto out_fail; @@ -3000,6 +3003,8 @@ out_free_0a: out_free_0: kvm_arch_exit(); out_fail: + kvm_irqfd_exit(); +out_irqfd: return r; } EXPORT_SYMBOL_GPL(kvm_init); @@ -3016,6 +3021,7 @@ void kvm_exit(void) on_each_cpu(hardware_disable_nolock, NULL, 1); kvm_arch_hardware_unsetup(); kvm_arch_exit(); + kvm_irqfd_exit(); free_cpumask_var(cpus_hardware_enabled); } EXPORT_SYMBOL_GPL(kvm_exit); -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 4/6] KVM: Introduce KVM_VIRTIO_CCW_NOTIFY_BUS.
Add a new bus type for virtio-ccw devices on s390. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- include/linux/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 3b768ef..206247f 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -148,6 +148,7 @@ struct kvm_io_bus { enum kvm_bus { KVM_MMIO_BUS, KVM_PIO_BUS, + KVM_VIRTIO_CCW_NOTIFY_BUS, KVM_NR_BUSES }; -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 5/6] KVM: ioeventfd for virtio-ccw devices.
Enhance KVM_IOEVENTFD with a new flag that allows to attach to virtio-ccw devices on s390 via the KVM_VIRTIO_CCW_NOTIFY_BUS. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- Documentation/virtual/kvm/api.txt | 8 include/uapi/linux/kvm.h | 3 +++ virt/kvm/eventfd.c| 17 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index c2534c3..86232d6 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -1468,15 +1468,23 @@ struct kvm_ioeventfd { __u8 pad[36]; }; +For the special case of virtio-ccw devices on s390, the ioevent is matched +to a subchannel/virtqueue tuple instead. + The following flags are defined: #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 kvm_ioeventfd_flag_nr_datamatch) #define KVM_IOEVENTFD_FLAG_PIO (1 kvm_ioeventfd_flag_nr_pio) #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 kvm_ioeventfd_flag_nr_deassign) +#define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ + (1 kvm_ioeventfd_flag_nr_virtio_ccw_notify) If datamatch flag is set, the event will be signaled only if the written value to the registered address is equal to datamatch in struct kvm_ioeventfd. +For virtio-ccw devices, addr contains the subchannel id and datamatch the +virtqueue index. + 4.60 KVM_DIRTY_TLB diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 9a2db57..8f3e5ae 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -448,12 +448,15 @@ enum { kvm_ioeventfd_flag_nr_datamatch, kvm_ioeventfd_flag_nr_pio, kvm_ioeventfd_flag_nr_deassign, + kvm_ioeventfd_flag_nr_virtio_ccw_notify, kvm_ioeventfd_flag_nr_max, }; #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 kvm_ioeventfd_flag_nr_datamatch) #define KVM_IOEVENTFD_FLAG_PIO (1 kvm_ioeventfd_flag_nr_pio) #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 kvm_ioeventfd_flag_nr_deassign) +#define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ + (1 kvm_ioeventfd_flag_nr_virtio_ccw_notify) #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 kvm_ioeventfd_flag_nr_max) - 1) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index f0ced1a..c9b6494 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -675,15 +675,24 @@ ioeventfd_check_collision(struct kvm *kvm, struct _ioeventfd *p) return false; } +static enum kvm_bus ioeventfd_bus_from_flags(__u32 flags) +{ + if (flags KVM_IOEVENTFD_FLAG_PIO) + return KVM_PIO_BUS; + if (flags KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY) + return KVM_VIRTIO_CCW_NOTIFY_BUS; + return KVM_MMIO_BUS; +} + static int kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) { - int pio = args-flags KVM_IOEVENTFD_FLAG_PIO; - enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS; + enum kvm_bus bus_idx; struct _ioeventfd*p; struct eventfd_ctx *eventfd; int ret; + bus_idx = ioeventfd_bus_from_flags(args-flags); /* must be natural-word sized */ switch (args-len) { case 1: @@ -758,12 +767,12 @@ fail: static int kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) { - int pio = args-flags KVM_IOEVENTFD_FLAG_PIO; - enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS; + enum kvm_bus bus_idx; struct _ioeventfd*p, *tmp; struct eventfd_ctx *eventfd; int ret = -ENOENT; + bus_idx = ioeventfd_bus_from_flags(args-flags); eventfd = eventfd_ctx_fdget(args-fd); if (IS_ERR(eventfd)) return PTR_ERR(eventfd); -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 0/6] kvm: Make ioeventfd usable on s390.
v5 of the ioeventfd patch set, this time with a proper return code from __diag_virtio_hypercall(), otherwise unchanged. v4 - v5: - Proper return code in __diag_virtio_hypercall() v3 - v4: - Pass cookies in virtio-ccw notify hypercall - Coding style v2 - v3: - Added a patch exporting the virtio-ccw api and use it for the diagnose implementation. - Better naming: We're dealing with virtio-ccw notifications only. v1 - v2: - Move irqfd initialization from a module init function to kvm_init, eliminating the need for a second module for kvm/s390. - Use kvm_io_device for s390 css devices. Cornelia Huck (5): KVM: s390: Export virtio-ccw api. KVM: Initialize irqfd from kvm_init(). KVM: Introduce KVM_VIRTIO_CCW_NOTIFY_BUS. KVM: ioeventfd for virtio-ccw devices. KVM: s390: Wire up ioeventfd. Michael S. Tsirkin (1): virtio_ccw: pass a cookie value to kvm hypercall Documentation/virtual/kvm/api.txt | 8 arch/s390/include/uapi/asm/Kbuild | 1 + arch/s390/include/uapi/asm/virtio-ccw.h | 21 + arch/s390/kvm/Kconfig | 1 + arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/diag.c| 26 ++ arch/s390/kvm/kvm-s390.c| 1 + drivers/s390/kvm/virtio_ccw.c | 16 +--- include/linux/kvm_host.h| 14 ++ include/uapi/linux/kvm.h| 3 +++ virt/kvm/eventfd.c | 24 +++- virt/kvm/kvm_main.c | 6 ++ 12 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 arch/s390/include/uapi/asm/virtio-ccw.h -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 6/6] KVM: s390: Wire up ioeventfd.
Enable ioeventfd support on s390 and hook up diagnose 500 virtio-ccw notifications. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- arch/s390/kvm/Kconfig| 1 + arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/diag.c | 26 ++ arch/s390/kvm/kvm-s390.c | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index b58dd86..3c43e30 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig @@ -22,6 +22,7 @@ config KVM select PREEMPT_NOTIFIERS select ANON_INODES select HAVE_KVM_CPU_RELAX_INTERCEPT + select HAVE_KVM_EVENTFD ---help--- Support hosting paravirtualized guest machines using the SIE virtualization capability on the mainframe. This should work diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 3975722..8fe9d65 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -6,7 +6,7 @@ # it under the terms of the GNU General Public License (version 2 only) # as published by the Free Software Foundation. -common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o) +common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o eventfd.o) ccflags-y := -Ivirt/kvm -Iarch/s390/kvm diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c index a390687..1c01a99 100644 --- a/arch/s390/kvm/diag.c +++ b/arch/s390/kvm/diag.c @@ -13,6 +13,7 @@ #include linux/kvm.h #include linux/kvm_host.h +#include asm/virtio-ccw.h #include kvm-s390.h #include trace.h #include trace-s390.h @@ -104,6 +105,29 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu) return -EREMOTE; } +static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu) +{ + int ret, idx; + + /* No virtio-ccw notification? Get out quickly. */ + if (!vcpu-kvm-arch.css_support || + (vcpu-run-s.regs.gprs[1] != KVM_S390_VIRTIO_CCW_NOTIFY)) + return -EOPNOTSUPP; + + idx = srcu_read_lock(vcpu-kvm-srcu); + /* +* The layout is as follows: +* - gpr 2 contains the subchannel id (passed as addr) +* - gpr 3 contains the virtqueue index (passed as datamatch) +*/ + ret = kvm_io_bus_write(vcpu-kvm, KVM_VIRTIO_CCW_NOTIFY_BUS, + vcpu-run-s.regs.gprs[2], + 8, vcpu-run-s.regs.gprs[3]); + srcu_read_unlock(vcpu-kvm-srcu, idx); + /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */ + return ret 0 ? ret : 0; +} + int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) { int code = (vcpu-arch.sie_block-ipb 0xfff) 16; @@ -118,6 +142,8 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) return __diag_time_slice_end_directed(vcpu); case 0x308: return __diag_ipl_functions(vcpu); + case 0x500: + return __diag_virtio_hypercall(vcpu); default: return -EOPNOTSUPP; } diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 4377d18..c7671e5 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -142,6 +142,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_ONE_REG: case KVM_CAP_ENABLE_CAP: case KVM_CAP_S390_CSS_SUPPORT: + case KVM_CAP_IOEVENTFD: r = 1; break; case KVM_CAP_NR_VCPUS: -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 0/8] pv event interface between host and guest
This series implements a new interface, kvm pv event, to notify host when some events happen in guest. Right now there is one supported event: guest panic. Also, the cpu runstate is preserved during save/load vm and migration. Thus, if vm is panicked during migration, we can still know it by quring the status of vm in destination host when migration completes. v12: http://lists.nongnu.org/archive/html/qemu-devel/2013-01/msg04120.html changes from v12: - no DO_UPCASE - the interface is only for x86 now - request 4 bytes io range(hw/kvm_pv_event.c) - rebase to the latest tree Hu Tao (7): save/load cpu runstate update kernel headers add a new runstate: RUN_STATE_GUEST_PANICKED add a new qevent: QEVENT_GUEST_PANICKED introduce a new qom device to deal with panicked event allower the user to disable pv event support pv event: add document to describe the usage Wen Congyang (1): start vm after resetting it docs/pv-event.txt| 17 hw/kvm/Makefile.objs | 2 +- hw/kvm/pv_event.c| 198 +++ hw/pc_piix.c | 12 +++ include/block/block.h| 2 + include/monitor/monitor.h| 1 + include/sysemu/kvm.h | 2 + include/sysemu/sysemu.h | 2 + kvm-stub.c | 4 + linux-headers/asm-x86/kvm_para.h | 1 + linux-headers/linux/kvm_para.h | 6 ++ migration.c | 7 +- monitor.c| 6 +- qapi-schema.json | 6 +- qemu-options.hx | 3 +- qmp.c| 5 +- savevm.c | 1 + vl.c | 56 ++- 18 files changed, 314 insertions(+), 17 deletions(-) create mode 100644 docs/pv-event.txt create mode 100644 hw/kvm/pv_event.c -- 1.8.1.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 2/8] start vm after resetting it
From: Wen Congyang we...@cn.fujitsu.com The guest should run after resetting it, but it does not run if its old state is RUN_STATE_INTERNAL_ERROR or RUN_STATE_PAUSED. We don't set runstate to RUN_STATE_PAUSED when resetting the guest, so the runstate will be changed from RUN_STATE_INTERNAL_ERROR or RUN_STATE_PAUSED to RUN_STATE_RUNNING(not RUN_STATE_PAUSED). Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- include/block/block.h | 2 ++ qmp.c | 2 +- vl.c | 7 --- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 0f750d7..8effc1e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -376,6 +376,8 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_set_in_use(BlockDriverState *bs, int in_use); int bdrv_in_use(BlockDriverState *bs); +void iostatus_bdrv_it(void *opaque, BlockDriverState *bs); + #ifdef CONFIG_LINUX_AIO int raw_get_aio_fd(BlockDriverState *bs); #else diff --git a/qmp.c b/qmp.c index 55b056b..5f1bed1 100644 --- a/qmp.c +++ b/qmp.c @@ -130,7 +130,7 @@ SpiceInfo *qmp_query_spice(Error **errp) }; #endif -static void iostatus_bdrv_it(void *opaque, BlockDriverState *bs) +void iostatus_bdrv_it(void *opaque, BlockDriverState *bs) { bdrv_iostatus_reset(bs); } diff --git a/vl.c b/vl.c index 7991f2e..3d08e1a 100644 --- a/vl.c +++ b/vl.c @@ -537,7 +537,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, -{ RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, +{ RUN_STATE_INTERNAL_ERROR, RUN_STATE_RUNNING }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, @@ -572,7 +572,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, -{ RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, +{ RUN_STATE_SHUTDOWN, RUN_STATE_RUNNING }, { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED }, @@ -2002,7 +2002,8 @@ static bool main_loop_should_exit(void) resume_all_vcpus(); if (runstate_check(RUN_STATE_INTERNAL_ERROR) || runstate_check(RUN_STATE_SHUTDOWN)) { -runstate_set(RUN_STATE_PAUSED); +bdrv_iterate(iostatus_bdrv_it, NULL); +vm_start(); } } if (qemu_wakeup_requested()) { -- 1.8.1.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 4/8] add a new runstate: RUN_STATE_GUEST_PANICKED
The guest will be in this state when it is panicked. Signed-off-by: Wen Congyang we...@cn.fujitsu.com Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- migration.c | 1 + qapi-schema.json | 6 +- qmp.c| 3 ++- vl.c | 11 ++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/migration.c b/migration.c index c29830e..fa17b82 100644 --- a/migration.c +++ b/migration.c @@ -698,6 +698,7 @@ static void *buffered_file_thread(void *opaque) int64_t start_time, end_time; DPRINTF(done iterating\n); +save_run_state(); start_time = qemu_get_clock_ms(rt_clock); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); if (old_vm_running) { diff --git a/qapi-schema.json b/qapi-schema.json index 28b070f..8f1d138 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -174,11 +174,15 @@ # @suspended: guest is suspended (ACPI S3) # # @watchdog: the watchdog action is configured to pause and has been triggered +# +# @guest-panicked: the panicked action is configured to pause and has been +# triggered. ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', -'running', 'save-vm', 'shutdown', 'suspended', 'watchdog' ] } +'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', +'guest-panicked' ] } ## # @SnapshotInfo diff --git a/qmp.c b/qmp.c index 5f1bed1..f5027f6 100644 --- a/qmp.c +++ b/qmp.c @@ -150,7 +150,8 @@ void qmp_cont(Error **errp) Error *local_err = NULL; if (runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN)) { +runstate_check(RUN_STATE_SHUTDOWN) || +runstate_check(RUN_STATE_GUEST_PANICKED)) { error_set(errp, QERR_RESET_REQUIRED); return; } else if (runstate_check(RUN_STATE_SUSPENDED)) { diff --git a/vl.c b/vl.c index 3d08e1a..51d4922 100644 --- a/vl.c +++ b/vl.c @@ -536,6 +536,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, +{ RUN_STATE_INMIGRATE, RUN_STATE_GUEST_PANICKED }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_RUNNING }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, @@ -549,6 +550,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_POSTMIGRATE, RUN_STATE_PAUSED }, { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_POSTMIGRATE, RUN_STATE_GUEST_PANICKED }, { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, @@ -559,6 +561,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, { RUN_STATE_RESTORE_VM, RUN_STATE_PAUSED }, +{ RUN_STATE_RESTORE_VM, RUN_STATE_GUEST_PANICKED }, { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, @@ -569,6 +572,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM }, { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, +{ RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, @@ -583,6 +587,10 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING }, +{ RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED }, +{ RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_MAX, RUN_STATE_MAX }, }; @@ -2001,7 +2009,8 @@ static bool main_loop_should_exit(void) qemu_system_reset(VMRESET_REPORT); resume_all_vcpus(); if (runstate_check(RUN_STATE_INTERNAL_ERROR) || -runstate_check(RUN_STATE_SHUTDOWN)) { +runstate_check(RUN_STATE_SHUTDOWN) || +runstate_check(RUN_STATE_GUEST_PANICKED)) { bdrv_iterate(iostatus_bdrv_it, NULL); vm_start(); } -- 1.8.1.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 3/8] update kernel headers
update kernel headers to add pv event macros. Signed-off-by: Wen Congyang we...@cn.fujitsu.com Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- linux-headers/asm-x86/kvm_para.h | 1 + linux-headers/linux/kvm_para.h | 6 ++ 2 files changed, 7 insertions(+) diff --git a/linux-headers/asm-x86/kvm_para.h b/linux-headers/asm-x86/kvm_para.h index a1c3d72..e9b082d 100644 --- a/linux-headers/asm-x86/kvm_para.h +++ b/linux-headers/asm-x86/kvm_para.h @@ -96,5 +96,6 @@ struct kvm_vcpu_pv_apf_data { #define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK #define KVM_PV_EOI_DISABLED 0x0 +#define KVM_PV_EVENT_PORT(0x505UL) #endif /* _ASM_X86_KVM_PARA_H */ diff --git a/linux-headers/linux/kvm_para.h b/linux-headers/linux/kvm_para.h index 7bdcf93..6c42923 100644 --- a/linux-headers/linux/kvm_para.h +++ b/linux-headers/linux/kvm_para.h @@ -20,6 +20,12 @@ #define KVM_HC_FEATURES3 #define KVM_HC_PPC_MAP_MAGIC_PAGE 4 +/* The bit of supported pv event */ +#define KVM_PV_FEATURE_PANICKED 0 + +/* The pv event value */ +#define KVM_PV_EVENT_PANICKED1 + /* * hypercalls use architecture specific */ -- 1.8.1.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 7/8] allower the user to disable pv event support
Signed-off-by: Wen Congyang we...@cn.fujitsu.com Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- hw/pc_piix.c| 9 - qemu-options.hx | 3 ++- vl.c| 4 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 24a9bf3..82a421a 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -44,6 +44,7 @@ #include exec/memory.h #include exec/address-spaces.h #include cpu.h +#include qemu/config-file.h #ifdef CONFIG_XEN # include xen/hvm/hvm_info_table.h #endif @@ -86,6 +87,8 @@ static void pc_init1(MemoryRegion *system_memory, MemoryRegion *pci_memory; MemoryRegion *rom_memory; void *fw_cfg = NULL; +QemuOptsList *list = qemu_find_opts(machine); +bool enable_pv_event = false; pc_cpus_init(cpu_model); pc_acpi_init(acpi-dsdt.aml); @@ -218,7 +221,11 @@ static void pc_init1(MemoryRegion *system_memory, pc_pci_device_init(pci_bus); } -if (kvm_enabled()) { +if (list !QTAILQ_EMPTY(list-head)) { +enable_pv_event = qemu_opt_get_bool(QTAILQ_FIRST(list-head), +enable_pv_event, false); +} +if (kvm_enabled() enable_pv_event) { kvm_pv_event_init(isa_bus); } } diff --git a/qemu-options.hx b/qemu-options.hx index 797d992..1ad4041 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -35,7 +35,8 @@ DEF(machine, HAS_ARG, QEMU_OPTION_machine, \ kernel_irqchip=on|off controls accelerated irqchip support\n kvm_shadow_mem=size of KVM shadow MMU\n dump-guest-core=on|off include guest memory in a core dump (default=on)\n -mem-merge=on|off controls memory merge support (default: on)\n, +mem-merge=on|off controls memory merge support (default: on)\n +enable_pv_event=on|off controls pv event support (default: off)\n, QEMU_ARCH_ALL) STEXI @item -machine [type=]@var{name}[,prop=@var{value}[,...]] diff --git a/vl.c b/vl.c index 51d4922..5b3a279 100644 --- a/vl.c +++ b/vl.c @@ -427,6 +427,10 @@ static QemuOptsList qemu_machine_opts = { .name = usb, .type = QEMU_OPT_BOOL, .help = Set on/off to enable/disable usb, +}, { +.name = enable_pv_event, +.type = QEMU_OPT_BOOL, +.help = handle pv event }, { /* End of list */ } }, -- 1.8.1.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 5/8] add a new qevent: QEVENT_GUEST_PANICKED
This event will be emited when the guest is panicked. Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- include/monitor/monitor.h | 1 + monitor.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 87fb49c..4006905 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -45,6 +45,7 @@ typedef enum MonitorEvent { QEVENT_WAKEUP, QEVENT_BALLOON_CHANGE, QEVENT_SPICE_MIGRATE_COMPLETED, +QEVENT_GUEST_PANICKED, /* Add to 'monitor_event_names' array in monitor.c when * defining new events here */ diff --git a/monitor.c b/monitor.c index bf974b4..d65218d 100644 --- a/monitor.c +++ b/monitor.c @@ -463,6 +463,7 @@ static const char *monitor_event_names[] = { [QEVENT_WAKEUP] = WAKEUP, [QEVENT_BALLOON_CHANGE] = BALLOON_CHANGE, [QEVENT_SPICE_MIGRATE_COMPLETED] = SPICE_MIGRATE_COMPLETED, +[QEVENT_GUEST_PANICKED] = GUEST_PANICKED, }; QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX) -- 1.8.1.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 1/8] save/load cpu runstate
This patch enables preservation of cpu runstate during save/load vm. So when a vm is restored from snapshot, the cpu runstate is restored, too. See following example: # save two vms: one is running, the other is paused (qemu) info status VM status: running (qemu) savevm running (qemu) stop (qemu) info status VM status: paused (qemu) savevm paused # restore the one running (qemu) info status VM status: paused (qemu) loadvm running (qemu) info status VM status: running # restore the one paused (qemu) loadvm paused (qemu) info status VM status: paused (qemu) cont (qemu)info status VM status: running Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- include/sysemu/sysemu.h | 2 ++ migration.c | 6 +- monitor.c | 5 ++--- savevm.c| 1 + vl.c| 34 ++ 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index b19ec95..f121213 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -19,6 +19,8 @@ extern uint8_t qemu_uuid[]; int qemu_uuid_parse(const char *str, uint8_t *uuid); #define UUID_FMT %02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx +void save_run_state(void); +void load_run_state(void); bool runstate_check(RunState state); void runstate_set(RunState new_state); int runstate_is_running(void); diff --git a/migration.c b/migration.c index 11725ae..c29830e 100644 --- a/migration.c +++ b/migration.c @@ -107,11 +107,7 @@ static void process_incoming_migration_co(void *opaque) /* Make sure all file formats flush their mutable metadata */ bdrv_invalidate_cache_all(); -if (autostart) { -vm_start(); -} else { -runstate_set(RUN_STATE_PAUSED); -} +load_run_state(); } void process_incoming_migration(QEMUFile *f) diff --git a/monitor.c b/monitor.c index 32a6e74..bf974b4 100644 --- a/monitor.c +++ b/monitor.c @@ -2059,13 +2059,12 @@ void qmp_closefd(const char *fdname, Error **errp) static void do_loadvm(Monitor *mon, const QDict *qdict) { -int saved_vm_running = runstate_is_running(); const char *name = qdict_get_str(qdict, name); vm_stop(RUN_STATE_RESTORE_VM); -if (load_vmstate(name) == 0 saved_vm_running) { -vm_start(); +if (load_vmstate(name) == 0) { +load_run_state(); } } diff --git a/savevm.c b/savevm.c index a8a53ef..aa631eb 100644 --- a/savevm.c +++ b/savevm.c @@ -2143,6 +2143,7 @@ void do_savevm(Monitor *mon, const QDict *qdict) } saved_vm_running = runstate_is_running(); +save_run_state(); vm_stop(RUN_STATE_SAVE_VM); memset(sn, 0, sizeof(*sn)); diff --git a/vl.c b/vl.c index febd2ea..7991f2e 100644 --- a/vl.c +++ b/vl.c @@ -523,6 +523,7 @@ static int default_driver_check(QemuOpts *opts, void *opaque) /* QEMU state */ static RunState current_run_state = RUN_STATE_PRELAUNCH; +static RunState saved_run_state = RUN_STATE_RUNNING; typedef struct { RunState from; @@ -546,6 +547,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, +{ RUN_STATE_POSTMIGRATE, RUN_STATE_PAUSED }, { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, @@ -556,6 +558,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, +{ RUN_STATE_RESTORE_VM, RUN_STATE_PAUSED }, { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, @@ -585,11 +588,39 @@ static const RunStateTransition runstate_transitions_def[] = { static bool runstate_valid_transitions[RUN_STATE_MAX][RUN_STATE_MAX]; +void save_run_state(void) +{ +saved_run_state = current_run_state; +} + +void load_run_state(void) +{ +if (saved_run_state == RUN_STATE_RUNNING) { +vm_start(); +} else if (!runstate_check(saved_run_state)) { +runstate_set(saved_run_state); +} else { +; /* leave unchanged */ +} +} + bool runstate_check(RunState state) { return current_run_state == state; } +static void runstate_save(QEMUFile *f, void *opaque) +{ +qemu_put_byte(f, saved_run_state); +} + +static int runstate_load(QEMUFile *f, void *opaque, int version_id) +{ +saved_run_state = qemu_get_byte(f); + +return 0; +} + static void runstate_init(void) { const RunStateTransition *p; @@ -599,6 +630,9 @@ static void runstate_init(void) for (p = runstate_transitions_def[0]; p-from != RUN_STATE_MAX; p++) { runstate_valid_transitions[p-from][p-to] = true; } + +register_savevm(NULL, runstate, 0, 1, +runstate_save, runstate_load, NULL); } /* This function will abort() on
[PATCH v13 8/8] pv event: add document to describe the usage
Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- docs/pv-event.txt | 17 + 1 file changed, 17 insertions(+) create mode 100644 docs/pv-event.txt diff --git a/docs/pv-event.txt b/docs/pv-event.txt new file mode 100644 index 000..ac9e7fa --- /dev/null +++ b/docs/pv-event.txt @@ -0,0 +1,17 @@ +KVM PV EVENT + + +kvm pv event allows guest OS to notify host OS of some events, for +example, guest panic. Currently, there is one event supported, that +is, guest panic. More events can be added later. + +By default, kvm pv event is disabled. In order to enable it, you have +to specify enable_pv_event=on for -machine command line option, along +with -global kvm_pv_event.panicked_action to specify the action taken +when panic event has occurred. Aviable panic actions are: none, +pause, poweroff and reset. Following is example: + + qemu-system-x86_64 -enable-kvm -machine pc-0.12,enable_pv_event=on \ +-global kvm_pv_event.panicked_action=pause other options + +kvm pv event needs kvm support. -- 1.8.1.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 6/8] introduce a new qom device to deal with panicked event
If the target is x86/x86_64, the guest's kernel will write 0x01 to the port KVM_PV_EVENT_PORT when it is panciked. This patch introduces a new qom device kvm_pv_ioport to listen this I/O port, and deal with panicked event according to panicked_action's value. The possible actions are: 1. emit QEVENT_GUEST_PANICKED only 2. emit QEVENT_GUEST_PANICKED and pause the guest 3. emit QEVENT_GUEST_PANICKED and poweroff the guest 4. emit QEVENT_GUEST_PANICKED and reset the guest I/O ports does not work for some targets(for example: s390). And you can implement another qom device, and include it's code into pv_event.c for such target. Note: if we emit QEVENT_GUEST_PANICKED only, and the management application does not receive this event(the management may not run when the event is emitted), the management won't know the guest is panicked. Signed-off-by: Wen Congyang we...@cn.fujitsu.com Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- hw/kvm/Makefile.objs | 2 +- hw/kvm/pv_event.c| 198 +++ hw/pc_piix.c | 5 ++ include/sysemu/kvm.h | 2 + kvm-stub.c | 4 ++ 5 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 hw/kvm/pv_event.c diff --git a/hw/kvm/Makefile.objs b/hw/kvm/Makefile.objs index f620d7f..cf93199 100644 --- a/hw/kvm/Makefile.objs +++ b/hw/kvm/Makefile.objs @@ -1 +1 @@ -obj-$(CONFIG_KVM) += clock.o apic.o i8259.o ioapic.o i8254.o pci-assign.o +obj-$(CONFIG_KVM) += clock.o apic.o i8259.o ioapic.o i8254.o pci-assign.o pv_event.o diff --git a/hw/kvm/pv_event.c b/hw/kvm/pv_event.c new file mode 100644 index 000..5e68190 --- /dev/null +++ b/hw/kvm/pv_event.c @@ -0,0 +1,198 @@ +/* + * QEMU KVM support, paravirtual event device + * + * Copyright Fujitsu, Corp. 2012 + * + * Authors: + * Wen Congyang we...@cn.fujitsu.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include linux/kvm_para.h +#include asm/kvm_para.h +#include qapi/qmp/qobject.h +#include qapi/qmp/qjson.h +#include monitor/monitor.h +#include sysemu/sysemu.h +#include sysemu/kvm.h + +/* Possible values for action parameter. */ +#define PANICKED_REPORT 1 /* emit QEVENT_GUEST_PANICKED only */ +#define PANICKED_PAUSE 2 /* emit QEVENT_GUEST_PANICKED and pause VM */ +#define PANICKED_POWEROFF 3 /* emit QEVENT_GUEST_PANICKED and quit VM */ +#define PANICKED_RESET 4 /* emit QEVENT_GUEST_PANICKED and reset VM */ + +#define PV_EVENT_DRIVER kvm_pv_event +#define PV_IOPORT(obj) OBJECT_CHECK(PVIOPortState, (obj), PV_EVENT_DRIVER) + +struct PVEventAction { +char *panicked_action; +int panicked_action_value; +}; + +#define DEFINE_PV_EVENT_PROPERTIES(_state, _conf) \ +DEFINE_PROP_STRING(panicked_action, _state, _conf.panicked_action) + +static void panicked_mon_event(const char *action) +{ +QObject *data; + +data = qobject_from_jsonf({ 'action': %s }, action); +monitor_protocol_event(QEVENT_GUEST_PANICKED, data); +qobject_decref(data); +} + +static void panicked_perform_action(uint32_t panicked_action) +{ +switch (panicked_action) { +case PANICKED_REPORT: +panicked_mon_event(report); +break; + +case PANICKED_PAUSE: +panicked_mon_event(pause); +vm_stop(RUN_STATE_GUEST_PANICKED); +break; + +case PANICKED_POWEROFF: +panicked_mon_event(poweroff); +qemu_system_shutdown_request(); +break; + +case PANICKED_RESET: +panicked_mon_event(reset); +qemu_system_reset_request(); +break; +} +} + +static uint64_t supported_event(void) +{ +return 1 KVM_PV_FEATURE_PANICKED; +} + +static void handle_event(int event, struct PVEventAction *conf) +{ +if (event == KVM_PV_EVENT_PANICKED) { +panicked_perform_action(conf-panicked_action_value); +} +} + +static int pv_event_init(struct PVEventAction *conf) +{ +if (!conf-panicked_action) { +conf-panicked_action_value = PANICKED_REPORT; +} else if (strcasecmp(conf-panicked_action, none) == 0) { +conf-panicked_action_value = PANICKED_REPORT; +} else if (strcasecmp(conf-panicked_action, pause) == 0) { +conf-panicked_action_value = PANICKED_PAUSE; +} else if (strcasecmp(conf-panicked_action, poweroff) == 0) { +conf-panicked_action_value = PANICKED_POWEROFF; +} else if (strcasecmp(conf-panicked_action, reset) == 0) { +conf-panicked_action_value = PANICKED_RESET; +} else { +return -1; +} + +return 0; +} + +#if defined(KVM_PV_EVENT_PORT) + +#include hw/isa.h + +typedef struct { +ISADevice dev; +struct PVEventAction conf; +MemoryRegion ioport; +} PVIOPortState; + +static uint64_t pv_io_read(void *opaque, hwaddr addr, unsigned size) +{ +return supported_event(); +} + +static void pv_io_write(void *opaque, hwaddr addr, uint64_t val, +
[PATCH v13] kvm: notify host when the guest is panicked
We can know the guest is panicked when the guest runs on xen. But we do not have such feature on kvm. Another purpose of this feature is: management app(for example: libvirt) can do auto dump when the guest is panicked. If management app does not do auto dump, the guest's user can do dump by hand if he sees the guest is panicked. We have three solutions to implement this feature: 1. use vmcall 2. use I/O port 3. use virtio-serial. We have decided to avoid touching hypervisor. The reason why I choose choose the I/O port is: 1. it is easier to implememt 2. it does not depend any virtual device 3. it can work when starting the kernel Signed-off-by: Wen Congyang we...@cn.fujitsu.com Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- arch/x86/include/asm/kvm_para.h | 26 + arch/x86/include/uapi/asm/kvm_para.h | 2 ++ arch/x86/kernel/Makefile | 2 +- arch/x86/kernel/kvm.c| 44 arch/x86/kernel/kvm_panic.c | 32 ++ kernel/panic.c | 4 6 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 arch/x86/kernel/kvm_panic.c diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h index 695399f..deae820 100644 --- a/arch/x86/include/asm/kvm_para.h +++ b/arch/x86/include/asm/kvm_para.h @@ -133,4 +133,30 @@ static inline void kvm_disable_steal_time(void) } #endif +/* The bit of supported pv event */ +#define KVM_PV_FEATURE_PANICKED0 + +/* The pv event value */ +#define KVM_PV_EVENT_PANICKED 1 + +static inline unsigned int kvm_arch_pv_features(void) +{ + return inl(KVM_PV_EVENT_PORT); +} + +static inline unsigned int kvm_arch_pv_has_feature(unsigned int feature) +{ + if (kvm_arch_pv_features() (1UL feature)) + return 1; + return 0; +} + +static inline void kvm_arch_pv_send_event(unsigned int event) +{ + outl(event, KVM_PV_EVENT_PORT); +} + +bool kvm_arch_pv_event_enabled(void); +int kvm_arch_pv_event_init(void); + #endif /* _ASM_X86_KVM_PARA_H */ diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h index 06fdbd9..c15ef33 100644 --- a/arch/x86/include/uapi/asm/kvm_para.h +++ b/arch/x86/include/uapi/asm/kvm_para.h @@ -96,5 +96,7 @@ struct kvm_vcpu_pv_apf_data { #define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK #define KVM_PV_EOI_DISABLED 0x0 +#define KVM_PV_EVENT_PORT (0x505UL) + #endif /* _UAPI_ASM_X86_KVM_PARA_H */ diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 7bd3bd3..f0629b2 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -80,7 +80,7 @@ obj-$(CONFIG_DEBUG_RODATA_TEST) += test_rodata.o obj-$(CONFIG_DEBUG_NX_TEST)+= test_nx.o obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o -obj-$(CONFIG_KVM_GUEST)+= kvm.o kvmclock.o +obj-$(CONFIG_KVM_GUEST)+= kvm.o kvmclock.o kvm_panic.o obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index b686a90..727ef91 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -73,6 +73,20 @@ static int parse_no_kvmclock_vsyscall(char *arg) early_param(no-kvmclock-vsyscall, parse_no_kvmclock_vsyscall); +static int pv_event = 1; +static int parse_no_pv_event(char *arg) +{ + pv_event = 0; + return 0; +} + +bool kvm_arch_pv_event_enabled(void) +{ + return !!pv_event; +} + +early_param(no-pv-event, parse_no_pv_event); + static DEFINE_PER_CPU(struct kvm_vcpu_pv_apf_data, apf_reason) __aligned(64); static DEFINE_PER_CPU(struct kvm_steal_time, steal_time) __aligned(64); static int has_steal_clock = 0; @@ -386,6 +400,17 @@ static struct notifier_block kvm_pv_reboot_nb = { .notifier_call = kvm_pv_reboot_notify, }; +static int +kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused) +{ + kvm_arch_pv_send_event(KVM_PV_EVENT_PANICKED); + return NOTIFY_DONE; +} + +static struct notifier_block kvm_pv_panic_nb = { + .notifier_call = kvm_pv_panic_notify, +}; + static u64 kvm_steal_clock(int cpu) { u64 steal; @@ -463,6 +488,23 @@ static void __init kvm_apf_trap_init(void) set_intr_gate(14, async_page_fault); } +static void __init kvm_pv_panicked_event_init(void) +{ + if (kvm_arch_pv_has_feature(KVM_PV_FEATURE_PANICKED)) + atomic_notifier_chain_register(panic_notifier_list, + kvm_pv_panic_nb); +} + +static void enable_pv_event(void) +{ + if (pv_event) { + if (kvm_arch_pv_event_init()) + return; + + kvm_pv_panicked_event_init(); + } +} + void __init kvm_guest_init(void) { int i; @@ -494,6 +536,8 @@ void __init kvm_guest_init(void) #else
Re: [PATCH] kvm-unit-test: more documentation and runner script
On 02/28/2013 06:51 AM, Gleb Natapov wrote: On Thu, Feb 28, 2013 at 11:45:33AM +0200, Michael S. Tsirkin wrote: On Thu, Feb 28, 2013 at 11:06:20AM +0200, Gleb Natapov wrote: On Wed, Feb 27, 2013 at 11:40:37PM +0200, Michael S. Tsirkin wrote: On Wed, Feb 27, 2013 at 06:03:41PM -0300, Lucas Meneghel Rodrigues wrote: On 02/27/2013 05:44 PM, Michael S. Tsirkin wrote: +Using qemu (supported since qemu 1.3): +qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel ./x86/msr.flat I think it is worth here to point out that with new qemu, after the unittest is done, the exit status of qemu is 1, different from the 'old style', whose exit status in successful completion is 0. ^ comment above +exec ${command} $@ ^ What about checking the exit status of qemu here and print something like test $@ PASS or test $@ FAIL? How do we know how to interpret it? Overall I think it's best to rely on test output than on return status. See comment above. Well, test output may be good for humans, but it is really not good for machines [1], that's why when the test suite was developed, the convention was to make qemu to exit with a given return code on success and others on failure. Right but given a qemu binary, how do I find out what it is on success and what it is on failure? Since you know what device you are using you know expected value for successful/failure. So exit status is 1 for success 0 for failure? For qemu-kvm, 0 success, non 0 for failure For qemu upstream, shift that 1 bit. As Lucas said above upstream is different from qemu-kvm unfortunately. On upstream you need to shift return value right for 1 bit to get to the tests return value (why?) and then 0 will be success otherwise failure. On the why, It was Anthony's call. See, as the upstream test device doesn't have any ports we can write to to make qemu exit, we used another device that can do that. I vaguely remember he argued for the exit code to be shifted by 1 on that other device, and said it wasn't a problem for test suites, since they can define what is a success and what is a failure. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 0/6] kvm: Make ioeventfd usable on s390.
On Thu, Feb 28, 2013 at 12:33:15PM +0100, Cornelia Huck wrote: v5 of the ioeventfd patch set, this time with a proper return code from __diag_virtio_hypercall(), otherwise unchanged. v4 - v5: - Proper return code in __diag_virtio_hypercall() v3 - v4: - Pass cookies in virtio-ccw notify hypercall - Coding style v2 - v3: - Added a patch exporting the virtio-ccw api and use it for the diagnose implementation. - Better naming: We're dealing with virtio-ccw notifications only. v1 - v2: - Move irqfd initialization from a module init function to kvm_init, eliminating the need for a second module for kvm/s390. - Use kvm_io_device for s390 css devices. The patches look obviously correct to me. I take no strong position on whether the userspace interface and the addition of virtio-specific bits in s390 kvm are acceptable, but looks ok to me too. Acked-by: Michael S. Tsirkin m...@redhat.com Cornelia Huck (5): KVM: s390: Export virtio-ccw api. KVM: Initialize irqfd from kvm_init(). KVM: Introduce KVM_VIRTIO_CCW_NOTIFY_BUS. KVM: ioeventfd for virtio-ccw devices. KVM: s390: Wire up ioeventfd. Michael S. Tsirkin (1): virtio_ccw: pass a cookie value to kvm hypercall Documentation/virtual/kvm/api.txt | 8 arch/s390/include/uapi/asm/Kbuild | 1 + arch/s390/include/uapi/asm/virtio-ccw.h | 21 + arch/s390/kvm/Kconfig | 1 + arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/diag.c| 26 ++ arch/s390/kvm/kvm-s390.c| 1 + drivers/s390/kvm/virtio_ccw.c | 16 +--- include/linux/kvm_host.h| 14 ++ include/uapi/linux/kvm.h| 3 +++ virt/kvm/eventfd.c | 24 +++- virt/kvm/kvm_main.c | 6 ++ 12 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 arch/s390/include/uapi/asm/virtio-ccw.h -- 1.7.12.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v13 2/8] start vm after resetting it
On 2013-02-28 13:13, Hu Tao wrote: From: Wen Congyang we...@cn.fujitsu.com The guest should run after resetting it, but it does not run if its old state is RUN_STATE_INTERNAL_ERROR or RUN_STATE_PAUSED. We don't set runstate to RUN_STATE_PAUSED when resetting the guest, so the runstate will be changed from RUN_STATE_INTERNAL_ERROR or RUN_STATE_PAUSED to RUN_STATE_RUNNING(not RUN_STATE_PAUSED). I just wonder what will happen if I interrupted the guest via gdb and then issue monitor system_reset, also via gdb - common pattern if you set a breakpoint on some BUG() or fault handler and then want to restart the guest. Will the guest continue then while gdb thinks it is still stopped? Likely, we do not differentiate between gdb-initiated stops and the rest. Could you clarify? Thanks, Jan -- Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: virtio PCI on KVM without IO BARs
On 2013-02-28 16:24, Michael S. Tsirkin wrote: Another problem with PIO is support for physical virtio devices, and nested virt: KVM currently programs all PIO accesses to cause vm exit, so using this device in a VM will be slow. Not answering your question, but support for programming direct PIO access into KVM's I/O bitmap would be feasible. Such feature may have some value for assigned devices that use PIO more heavily. They cause lengthy user-space exists so far. Jan -- Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] Added ONE_REG interface for debug instruction
On 02/27/2013 10:13:11 PM, Bharat Bhushan wrote: diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 8b553c0..a41cd6d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1448,6 +1448,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) case KVM_REG_PPC_TSR: r = put_user(vcpu-arch.tsr, (u32 __user *)(long)reg-addr); break; + case KVM_REG_PPC_DEBUG_INST: { + u32 opcode = KVMPPC_INST_EHPRIV; + r = copy_to_user((u32 __user *)(long)reg-addr, +opcode, sizeof(u32)); + break; + } We're using ehpriv even for PR-mode KVM (e.g. e500v2)? -Scott -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/7] Rename EMULATE_DO_PAPR to EMULATE_EXIT_USER
On 02/27/2013 10:13:15 PM, Bharat Bhushan wrote: Instruction emulation return EMULATE_DO_PAPR when it requires exit to userspace on book3s. Similar return is required for booke. EMULATE_DO_PAPR reads out to be confusing so it is renamed to EMULATE_EXIT_USER. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com --- arch/powerpc/include/asm/kvm_ppc.h |2 +- arch/powerpc/kvm/book3s_emulate.c |2 +- arch/powerpc/kvm/book3s_pr.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 44a657a..8b81468 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -44,7 +44,7 @@ enum emulation_result { EMULATE_DO_DCR, /* kvm_run filled with DCR request */ EMULATE_FAIL, /* can't emulate this instruction */ EMULATE_AGAIN,/* something went wrong. go again */ - EMULATE_DO_PAPR, /* kvm_run filled with PAPR request */ + EMULATE_EXIT_USER,/* emulation requires exit to user-space */ }; extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 836c569..cdd19d6 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -194,7 +194,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, run-papr_hcall.args[i] = gpr; } - emulated = EMULATE_DO_PAPR; + emulated = EMULATE_EXIT_USER; break; } #endif diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 73ed11c..8df2d2d 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -760,7 +760,7 @@ program_interrupt: run-exit_reason = KVM_EXIT_MMIO; r = RESUME_HOST_NV; break; - case EMULATE_DO_PAPR: + case EMULATE_EXIT_USER: run-exit_reason = KVM_EXIT_PAPR_HCALL; vcpu-arch.hcall_needed = 1; r = RESUME_HOST_NV; I don't think it makes sense to genericize this. It means more than just return to user; it indicates what sort of exit reason should be passed back. What if book3s later wants to be able to return KVM_EXIT_DEBUG, or we want to have userspace-handled hcalls on booke? -Scott -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/7] Rename EMULATE_DO_PAPR to EMULATE_EXIT_USER
On 28.02.2013, at 17:31, Scott Wood wrote: On 02/27/2013 10:13:15 PM, Bharat Bhushan wrote: Instruction emulation return EMULATE_DO_PAPR when it requires exit to userspace on book3s. Similar return is required for booke. EMULATE_DO_PAPR reads out to be confusing so it is renamed to EMULATE_EXIT_USER. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com --- arch/powerpc/include/asm/kvm_ppc.h |2 +- arch/powerpc/kvm/book3s_emulate.c |2 +- arch/powerpc/kvm/book3s_pr.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 44a657a..8b81468 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -44,7 +44,7 @@ enum emulation_result { EMULATE_DO_DCR, /* kvm_run filled with DCR request */ EMULATE_FAIL, /* can't emulate this instruction */ EMULATE_AGAIN,/* something went wrong. go again */ -EMULATE_DO_PAPR, /* kvm_run filled with PAPR request */ +EMULATE_EXIT_USER,/* emulation requires exit to user-space */ }; extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 836c569..cdd19d6 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -194,7 +194,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, run-papr_hcall.args[i] = gpr; } -emulated = EMULATE_DO_PAPR; +emulated = EMULATE_EXIT_USER; break; } #endif diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 73ed11c..8df2d2d 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -760,7 +760,7 @@ program_interrupt: run-exit_reason = KVM_EXIT_MMIO; r = RESUME_HOST_NV; break; -case EMULATE_DO_PAPR: +case EMULATE_EXIT_USER: run-exit_reason = KVM_EXIT_PAPR_HCALL; vcpu-arch.hcall_needed = 1; r = RESUME_HOST_NV; I don't think it makes sense to genericize this. It makes sense if the run-exit_reason = ... and hcall_needed = ... lines get pulled into the emulator. The question is basically whether we want to have another layer of abstraction inside our own emulator / kvm interface. I don't have a strong feeling either way. Alex It means more than just return to user; it indicates what sort of exit reason should be passed back. What if book3s later wants to be able to return KVM_EXIT_DEBUG, or we want to have userspace-handled hcalls on booke? -Scott -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] Added ONE_REG interface for debug instruction
On 28.02.2013, at 17:23, Scott Wood wrote: On 02/27/2013 10:13:11 PM, Bharat Bhushan wrote: diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 8b553c0..a41cd6d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1448,6 +1448,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) case KVM_REG_PPC_TSR: r = put_user(vcpu-arch.tsr, (u32 __user *)(long)reg-addr); break; +case KVM_REG_PPC_DEBUG_INST: { +u32 opcode = KVMPPC_INST_EHPRIV; +r = copy_to_user((u32 __user *)(long)reg-addr, + opcode, sizeof(u32)); +break; +} We're using ehpriv even for PR-mode KVM (e.g. e500v2)? If it's a reserved instruction, that should work. Since we need to use a single instruction to replace the debugged one with, any reserved opcode should be as good as any other, right? Alex -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/7] Rename EMULATE_DO_PAPR to EMULATE_EXIT_USER
On 02/28/2013 10:51:10 AM, Alexander Graf wrote: On 28.02.2013, at 17:31, Scott Wood wrote: On 02/27/2013 10:13:15 PM, Bharat Bhushan wrote: Instruction emulation return EMULATE_DO_PAPR when it requires exit to userspace on book3s. Similar return is required for booke. EMULATE_DO_PAPR reads out to be confusing so it is renamed to EMULATE_EXIT_USER. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com --- arch/powerpc/include/asm/kvm_ppc.h |2 +- arch/powerpc/kvm/book3s_emulate.c |2 +- arch/powerpc/kvm/book3s_pr.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 44a657a..8b81468 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -44,7 +44,7 @@ enum emulation_result { EMULATE_DO_DCR, /* kvm_run filled with DCR request */ EMULATE_FAIL, /* can't emulate this instruction */ EMULATE_AGAIN,/* something went wrong. go again */ - EMULATE_DO_PAPR, /* kvm_run filled with PAPR request */ + EMULATE_EXIT_USER,/* emulation requires exit to user-space */ }; extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 836c569..cdd19d6 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -194,7 +194,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, run-papr_hcall.args[i] = gpr; } - emulated = EMULATE_DO_PAPR; + emulated = EMULATE_EXIT_USER; break; } #endif diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 73ed11c..8df2d2d 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -760,7 +760,7 @@ program_interrupt: run-exit_reason = KVM_EXIT_MMIO; r = RESUME_HOST_NV; break; - case EMULATE_DO_PAPR: + case EMULATE_EXIT_USER: run-exit_reason = KVM_EXIT_PAPR_HCALL; vcpu-arch.hcall_needed = 1; r = RESUME_HOST_NV; I don't think it makes sense to genericize this. It makes sense if the run-exit_reason = ... and hcall_needed = ... lines get pulled into the emulator. That would be fine. -Scott -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v13 1/8] save/load cpu runstate
On 02/28/2013 05:13 AM, Hu Tao wrote: This patch enables preservation of cpu runstate during save/load vm. So when a vm is restored from snapshot, the cpu runstate is restored, too. What happens if a management app wants to override the runstate when restoring the domain? I can think of several useful scenarios: 1. management app pauses the guest, then saves domain state and other things (management state, or disk clones), then resumes the guest. Later, the management wants to revert to the saved state, but have the guest running right away. I guess here, knowing that the guest was saved in a paused state doesn't hurt, since the management app can resume it right away. 2. management app saves domain state of a live guest, then copies that state elsewhere. In its new location, the management app wants to investigate the state for forensic analysis - so even though the guest remembers that it was running, management wants to start it paused. Here, it is important that there must not be a window of time where the guest can run, otherwise, the results are not reproducible. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
RE: [PATCH 2/7] Added ONE_REG interface for debug instruction
-Original Message- From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc- ow...@vger.kernel.org] On Behalf Of Alexander Graf Sent: Thursday, February 28, 2013 10:22 PM To: Wood Scott-B07421 Cc: Bhushan Bharat-R65777; kvm-...@vger.kernel.org; kvm@vger.kernel.org; Bhushan Bharat-R65777 Subject: Re: [PATCH 2/7] Added ONE_REG interface for debug instruction On 28.02.2013, at 17:23, Scott Wood wrote: On 02/27/2013 10:13:11 PM, Bharat Bhushan wrote: diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 8b553c0..a41cd6d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1448,6 +1448,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) case KVM_REG_PPC_TSR: r = put_user(vcpu-arch.tsr, (u32 __user *)(long)reg-addr); break; + case KVM_REG_PPC_DEBUG_INST: { + u32 opcode = KVMPPC_INST_EHPRIV; + r = copy_to_user((u32 __user *)(long)reg-addr, + opcode, sizeof(u32)); + break; + } We're using ehpriv even for PR-mode KVM (e.g. e500v2)? If it's a reserved instruction, that should work. Since we need to use a single instruction to replace the debugged one with, any reserved opcode should be as good as any other, right? Right, that has been the idea here. Thanks -Bharat Alex -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Bug 54061] guest panic after live migration
https://bugzilla.kernel.org/show_bug.cgi?id=54061 Jay Ren yongjie@intel.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution||CODE_FIX --- Comment #4 from Jay Ren yongjie@intel.com 2013-03-01 07:33:31 --- By reverting the buggy commit, this bug was fixed. See the following commit: commit 6b73a96065e89dc9fa75ba4f78b1aa3a3bbd0470 Author: Marcelo Tosatti mtosa...@redhat.com Date: Wed Feb 20 18:52:02 2013 -0300 Revert KVM: MMU: lazily drop large spte This reverts commit caf6900f2d8aaebe404c976753f6813ccd31d95e. It is causing migration failures, reference https://bugzilla.kernel.org/show_bug.cgi?id=54061. Signed-off-by: Marcelo Tosatti mtosa...@redhat.com -- Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are watching the assignee of the bug. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Bug 54061] guest panic after live migration
https://bugzilla.kernel.org/show_bug.cgi?id=54061 Jay Ren yongjie@intel.com changed: What|Removed |Added Status|VERIFIED|CLOSED -- Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are watching the assignee of the bug. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v13 1/8] save/load cpu runstate
On Thu, Feb 28, 2013 at 02:12:37PM -0700, Eric Blake wrote: On 02/28/2013 05:13 AM, Hu Tao wrote: This patch enables preservation of cpu runstate during save/load vm. So when a vm is restored from snapshot, the cpu runstate is restored, too. What happens if a management app wants to override the runstate when restoring the domain? I can think of several useful scenarios: 1. management app pauses the guest, then saves domain state and other things (management state, or disk clones), then resumes the guest. Later, the management wants to revert to the saved state, but have the guest running right away. I guess here, knowing that the guest was saved in a paused state doesn't hurt, since the management app can resume it right away. 2. management app saves domain state of a live guest, then copies that state elsewhere. In its new location, the management app wants to investigate the state for forensic analysis - so even though the guest remembers that it was running, management wants to start it paused. Here, it is important that there must not be a window of time where the guest can run, otherwise, the results are not reproducible. -S takes precedence in the case. But for in-migration, runstate is loaded from src. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] Added ONE_REG interface for debug instruction
On 02/27/2013 10:13:11 PM, Bharat Bhushan wrote: diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 8b553c0..a41cd6d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1448,6 +1448,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) case KVM_REG_PPC_TSR: r = put_user(vcpu-arch.tsr, (u32 __user *)(long)reg-addr); break; + case KVM_REG_PPC_DEBUG_INST: { + u32 opcode = KVMPPC_INST_EHPRIV; + r = copy_to_user((u32 __user *)(long)reg-addr, +opcode, sizeof(u32)); + break; + } We're using ehpriv even for PR-mode KVM (e.g. e500v2)? -Scott -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/7] Rename EMULATE_DO_PAPR to EMULATE_EXIT_USER
On 02/27/2013 10:13:15 PM, Bharat Bhushan wrote: Instruction emulation return EMULATE_DO_PAPR when it requires exit to userspace on book3s. Similar return is required for booke. EMULATE_DO_PAPR reads out to be confusing so it is renamed to EMULATE_EXIT_USER. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com --- arch/powerpc/include/asm/kvm_ppc.h |2 +- arch/powerpc/kvm/book3s_emulate.c |2 +- arch/powerpc/kvm/book3s_pr.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 44a657a..8b81468 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -44,7 +44,7 @@ enum emulation_result { EMULATE_DO_DCR, /* kvm_run filled with DCR request */ EMULATE_FAIL, /* can't emulate this instruction */ EMULATE_AGAIN,/* something went wrong. go again */ - EMULATE_DO_PAPR, /* kvm_run filled with PAPR request */ + EMULATE_EXIT_USER,/* emulation requires exit to user-space */ }; extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 836c569..cdd19d6 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -194,7 +194,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, run-papr_hcall.args[i] = gpr; } - emulated = EMULATE_DO_PAPR; + emulated = EMULATE_EXIT_USER; break; } #endif diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 73ed11c..8df2d2d 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -760,7 +760,7 @@ program_interrupt: run-exit_reason = KVM_EXIT_MMIO; r = RESUME_HOST_NV; break; - case EMULATE_DO_PAPR: + case EMULATE_EXIT_USER: run-exit_reason = KVM_EXIT_PAPR_HCALL; vcpu-arch.hcall_needed = 1; r = RESUME_HOST_NV; I don't think it makes sense to genericize this. It means more than just return to user; it indicates what sort of exit reason should be passed back. What if book3s later wants to be able to return KVM_EXIT_DEBUG, or we want to have userspace-handled hcalls on booke? -Scott -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] Added ONE_REG interface for debug instruction
On 28.02.2013, at 17:23, Scott Wood wrote: On 02/27/2013 10:13:11 PM, Bharat Bhushan wrote: diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 8b553c0..a41cd6d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1448,6 +1448,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) case KVM_REG_PPC_TSR: r = put_user(vcpu-arch.tsr, (u32 __user *)(long)reg-addr); break; +case KVM_REG_PPC_DEBUG_INST: { +u32 opcode = KVMPPC_INST_EHPRIV; +r = copy_to_user((u32 __user *)(long)reg-addr, + opcode, sizeof(u32)); +break; +} We're using ehpriv even for PR-mode KVM (e.g. e500v2)? If it's a reserved instruction, that should work. Since we need to use a single instruction to replace the debugged one with, any reserved opcode should be as good as any other, right? Alex -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/7] Rename EMULATE_DO_PAPR to EMULATE_EXIT_USER
On 02/28/2013 10:51:10 AM, Alexander Graf wrote: On 28.02.2013, at 17:31, Scott Wood wrote: On 02/27/2013 10:13:15 PM, Bharat Bhushan wrote: Instruction emulation return EMULATE_DO_PAPR when it requires exit to userspace on book3s. Similar return is required for booke. EMULATE_DO_PAPR reads out to be confusing so it is renamed to EMULATE_EXIT_USER. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com --- arch/powerpc/include/asm/kvm_ppc.h |2 +- arch/powerpc/kvm/book3s_emulate.c |2 +- arch/powerpc/kvm/book3s_pr.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 44a657a..8b81468 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -44,7 +44,7 @@ enum emulation_result { EMULATE_DO_DCR, /* kvm_run filled with DCR request */ EMULATE_FAIL, /* can't emulate this instruction */ EMULATE_AGAIN,/* something went wrong. go again */ - EMULATE_DO_PAPR, /* kvm_run filled with PAPR request */ + EMULATE_EXIT_USER,/* emulation requires exit to user-space */ }; extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 836c569..cdd19d6 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -194,7 +194,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, run-papr_hcall.args[i] = gpr; } - emulated = EMULATE_DO_PAPR; + emulated = EMULATE_EXIT_USER; break; } #endif diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 73ed11c..8df2d2d 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -760,7 +760,7 @@ program_interrupt: run-exit_reason = KVM_EXIT_MMIO; r = RESUME_HOST_NV; break; - case EMULATE_DO_PAPR: + case EMULATE_EXIT_USER: run-exit_reason = KVM_EXIT_PAPR_HCALL; vcpu-arch.hcall_needed = 1; r = RESUME_HOST_NV; I don't think it makes sense to genericize this. It makes sense if the run-exit_reason = ... and hcall_needed = ... lines get pulled into the emulator. That would be fine. -Scott -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 2/7] Added ONE_REG interface for debug instruction
-Original Message- From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc- ow...@vger.kernel.org] On Behalf Of Alexander Graf Sent: Thursday, February 28, 2013 10:22 PM To: Wood Scott-B07421 Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan Bharat-R65777 Subject: Re: [PATCH 2/7] Added ONE_REG interface for debug instruction On 28.02.2013, at 17:23, Scott Wood wrote: On 02/27/2013 10:13:11 PM, Bharat Bhushan wrote: diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 8b553c0..a41cd6d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1448,6 +1448,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) case KVM_REG_PPC_TSR: r = put_user(vcpu-arch.tsr, (u32 __user *)(long)reg-addr); break; + case KVM_REG_PPC_DEBUG_INST: { + u32 opcode = KVMPPC_INST_EHPRIV; + r = copy_to_user((u32 __user *)(long)reg-addr, + opcode, sizeof(u32)); + break; + } We're using ehpriv even for PR-mode KVM (e.g. e500v2)? If it's a reserved instruction, that should work. Since we need to use a single instruction to replace the debugged one with, any reserved opcode should be as good as any other, right? Right, that has been the idea here. Thanks -Bharat Alex -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html