Re: [CFT PATCH 2/2] KVM: x86: support XSAVES usage in the host

2014-11-23 Thread Wanpeng Li
Hi Paolo, On Fri, Nov 21, 2014 at 07:31:18PM +0100, Paolo Bonzini wrote: [...] >+ u64 feature = valid & -valid; >+ int index = fls64(feature) - 1; >+ void *src = get_xsave_addr(xsave, feature); >+ >+ if (src) { >+ u32 size, of

Re: KVM causes #GP on XRSTORS

2014-11-23 Thread Wanpeng Li
Hi Paolo, On Fri, Nov 21, 2014 at 03:46:55PM +0100, Paolo Bonzini wrote: > > >On 20/11/2014 17:34, Nadav Amit wrote: >> Fenghua, >> >> I got KVM (v3.17) crashing on a machine that supports XRSTORS - It appears >> to get a #GP when it is trying to load the guest FPU. >> One reason for the #GP is t

Re: nested KVM slower than QEMU with gnumach guest kernel

2014-11-23 Thread Samuel Thibault
Jan Kiszka, le Mon 17 Nov 2014 07:28:23 +0100, a écrit : > I suppose this is a SMP host and guest? Does reducing CPUs to 1 change > to picture? Oddly enough, putting my host into UniProcessor mode is making L1 realmode simulation awfully slow. That also happens when binding kvm on a single hardwa

Re: nested KVM slower than QEMU with gnumach guest kernel

2014-11-23 Thread Samuel Thibault
Jan Kiszka, le Mon 17 Nov 2014 10:04:37 +0100, a écrit : > On 2014-11-17 10:03, Samuel Thibault wrote: > > Gleb Natapov, le Mon 17 Nov 2014 10:58:45 +0200, a écrit : > >> Do you know how gnumach timekeeping works? Does it have a timer that fires > >> each 1ms? > >> Which clock device is it using?

[PATCH v3 0/8] KVM-VFIO IRQ forward control

2014-11-23 Thread Eric Auger
This series proposes an integration of "ARM: Forwarding physical interrupts to a guest VM" (http://lwn.net/Articles/603514/) in KVM. It enables to transform a VFIO platform driver IRQ into a forwarded IRQ. When a physical IRQ is forwarded (to a guest), the host does not deactivates this latter. C

[PATCH v3 1/8] KVM: arm: Enable the KVM-VFIO device

2014-11-23 Thread Eric Auger
From: Kim Phillips Used by KVM-enabled VFIO-based device passthrough support in QEMU. Signed-off-by: Kim Phillips --- arch/arm/kvm/Kconfig | 1 + arch/arm/kvm/Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index e519a

[PATCH v3 3/8] VFIO: platform: forwarded state tested when selecting IRQ handler

2014-11-23 Thread Eric Auger
In case the IRQ is forwarded, the VFIO platform IRQ handler does not need to disable the IRQ anymore. When setting the IRQ handler we now also test the forwarded state. In case the IRQ is forwarded we select the edge handler (no automaske). Signed-off-by: Eric Auger --- v2 -> v3: - forwarded s

[PATCH v3 5/8] VFIO: External user API device helpers

2014-11-23 Thread Eric Auger
The VFIO external user API is enriched with 3 new functions that allows a kernel user external to VFIO to retrieve some information from a VFIO device. - vfio_device_get_external_user enables to get a vfio device from its fd and increments its reference counter - vfio_device_put_external_user de

[PATCH v3 7/8] KVM: kvm-vfio: generic forwarding control

2014-11-23 Thread Eric Auger
This patch introduces a new KVM_DEV_VFIO_DEVICE group. This is a new control channel which enables KVM to cooperate with viable VFIO devices. Functions are introduced to check the validity of a VFIO device file descriptor, increment/decrement the ref counter of the VFIO device. The patch introdu

[PATCH v3 6/8] KVM: kvm-vfio: wrapper to VFIO external API device helpers

2014-11-23 Thread Eric Auger
Provide wrapper functions that allow KVM-VFIO device code to interact with a vfio device: - kvm_vfio_device_get_external_user gets a handle to a struct vfio_device from the vfio device file descriptor and increments its reference counter, - kvm_vfio_device_put_external_user decrements the refer

[PATCH v3 8/8] KVM: arm: kvm-vfio: forwarding control

2014-11-23 Thread Eric Auger
This patch sets __KVM_HAVE_ARCH_KVM_VFIO_FORWARD and implements kvm_arch_vfio_set_forward for ARM. As a result the KVM-VFIO device now allows to forward/unforward a VFIO device IRQ on ARM. kvm_arch_vfio_set_forward programs both genirq and the VGIC to control where the physical IRQ deactivation i

[PATCH v3 4/8] KVM: kvm-vfio: User API for IRQ forwarding

2014-11-23 Thread Eric Auger
This patch adds and document a new KVM_DEV_VFIO_DEVICE group and 2 device attributes: KVM_DEV_VFIO_DEVICE_FORWARD_IRQ, KVM_DEV_VFIO_DEVICE_UNFORWARD_IRQ. The purpose is to be able to set a VFIO device IRQ as forwarded or not forwarded. the command takes as argument a handle to a new struct named kv

[PATCH v3 2/8] KVM: arm64: Enable the KVM-VFIO device

2014-11-23 Thread Eric Auger
Used by KVM-enabled VFIO-based device passthrough support in QEMU. Signed-off-by: Joel Schopp Signed-off-by: Eric Auger --- Extracted from [RFC PATCH] arm64: KVM: add irqfd support http://www.spinics.net/lists/kvm-arm/msg10798.html --- arch/arm64/kvm/Kconfig | 1 + arch/arm64/kvm/Makefile |

[RFC 0/4] vgic additions for forwarded irq

2014-11-23 Thread Eric Auger
This series applies on top of "ARM: Forwarding physical interrupts to a guest VM" (http://lwn.net/Articles/603514/) series. It brings some extra functionalities that were requested to be able to inject virtual level sensitive IRQs triggered from VFIO/irqfd. It adds: - a specific handling of forwa

[RFC 2/4] KVM: arm: vgic: add forwarded irq rbtree lock

2014-11-23 Thread Eric Auger
Add a lock related to the rb tree manipulation. The rb tree can be searched in one thread (irqfd handler for instance) and map/unmap may happen in another. Signed-off-by: Eric Auger --- v2 -> v3: re-arrange lock sequence in vgic_map_phys_irq --- include/kvm/arm_vgic.h | 1 + virt/kvm/arm/vgic

[RFC 3/4] KVM: arm: vgic: cleanup forwarded IRQs on destroy

2014-11-23 Thread Eric Auger
When the VGIC is destroyed it must take care of - restoring the forwarded IRQs in non forwarded state, - deactivating the IRQ in case the guest left without doing it - cleaning nodes of the phys_map rbtree Signed-off-by: Eric Auger --- virt/kvm/arm/vgic.c | 36 +++

[RFC 1/4] KVM: arm: vgic: fix state machine for forwarded IRQ

2014-11-23 Thread Eric Auger
Fix multiple injection of level sensitive forwarded IRQs. With current code, the second injection fails since the state bitmaps are not reset (process_maintenance is not called anymore). New implementation follows those principles: - A forwarded IRQ only can be sampled when it is pending - when qu

[RFC 4/4] KVM: arm: vgic: handle irqfd forwarded IRQ injection before vgic readiness

2014-11-23 Thread Eric Auger
This patch handles the case where irqfd attempts to inject a forwarded IRQ before the vgic is ready to accept it. We cannot simply return pretending nothing happened since the IRQ will never be deactivated by the guest. Indeed, the corresponding virtual IRQ cannot be injected into the guest and the

[PATCH v4 1/3] KVM: arm/arm64: unset CONFIG_HAVE_KVM_IRQCHIP

2014-11-23 Thread Eric Auger
CONFIG_HAVE_KVM_IRQCHIP is needed to support IRQ routing (along with irq_comm.c and irqchip.c usage). This is not the case for arm/arm64 currently. This patch unsets the flag for both arm and arm64. Signed-off-by: Eric Auger --- arch/arm/kvm/Kconfig | 2 -- arch/arm64/kvm/Kconfig | 1 - 2 fil

[PATCH v4 3/3] KVM: arm64: add irqfd support

2014-11-23 Thread Eric Auger
From: Joel Schopp This patch enables irqfd for arm64. Signed-off-by: Joel Schopp Signed-off-by: Eric Auger --- [Eric Auger] - originates from Joel's [RFC PATCH] arm64: KVM: add irqfd support http://www.spinics.net/lists/kvm-arm/msg10798.html - isolates modifications really related to irqfd

[PATCH v4 2/3] KVM: arm: add irqfd support

2014-11-23 Thread Eric Auger
This patch enables irqfd on arm. Both irqfd and resamplefd are supported. Injection is implemented in vgic.c without routing. This patch enables CONFIG_HAVE_KVM_EVENTFD and CONFIG_HAVE_KVM_IRQFD. KVM_CAP_IRQFD is now advertised. KVM_CAP_IRQFD_RESAMPLE capability automatically is advertised as so

[PATCH v4 0/3] irqfd support for arm/arm64

2014-11-23 Thread Eric Auger
This patch series enables irqfd on arm and arm64. Irqfd framework enables to inject a virtual IRQ into a guest upon an eventfd trigger. User-side uses KVM_IRQFD VM ioctl to provide KVM with a kvm_irqfd struct that associates a VM, an eventfd, a virtual IRQ number (aka. the gsi). When an actor sign

[PULL 05/15] memory: expose alignment used for allocating RAM as MemoryRegion API

2014-11-23 Thread Michael S. Tsirkin
From: Igor Mammedov introduce memory_region_get_alignment() that returns underlying memory block alignment or 0 if it's not relevant/implemented for backend. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/exec-all.h | 2 +- inc

[PULL 02/15] pc: kvm: check if KVM has free memory slots to avoid abort()

2014-11-23 Thread Michael S. Tsirkin
From: Igor Mammedov When more memory devices are used than available KVM memory slots, QEMU crashes with: kvm_alloc_slot: no free slot available Aborted (core dumped) Fix this by checking that KVM has a free slot before attempting to map memory in guest address space. Signed-off-by: Igor Mamme

Re: [CFT PATCH 0/2] KVM: support XSAVES usage in the host

2014-11-23 Thread Wanpeng Li
On 11/23/14, 4:31 PM, Nadav Amit wrote: On Nov 23, 2014, at 10:24, Wanpeng Li wrote: Hi Nadav, On 11/23/14, 4:16 PM, Nadav Amit wrote: I’ll try to check it tomorrow (I don’t have access to the failing machine at the moment). If the machine you mentioned support xsaves and what's machine you

Re: [CFT PATCH 0/2] KVM: support XSAVES usage in the host

2014-11-23 Thread Nadav Amit
> On Nov 23, 2014, at 10:24, Wanpeng Li wrote: > > Hi Nadav, > On 11/23/14, 4:16 PM, Nadav Amit wrote: >> I’ll try to check it tomorrow (I don’t have access to the failing machine at >> the moment). > > If the machine you mentioned support xsaves and what's machine you are using? It supports

Re: [CFT PATCH 0/2] KVM: support XSAVES usage in the host

2014-11-23 Thread Wanpeng Li
Hi Nadav, On 11/23/14, 4:16 PM, Nadav Amit wrote: I’ll try to check it tomorrow (I don’t have access to the failing machine at the moment). If the machine you mentioned support xsaves and what's machine you are using? Regards, Wanpeng Li Thanks for the quick response. Nadav On Nov 21,

Re: [CFT PATCH 0/2] KVM: support XSAVES usage in the host

2014-11-23 Thread Nadav Amit
I’ll try to check it tomorrow (I don’t have access to the failing machine at the moment). Thanks for the quick response. Nadav > On Nov 21, 2014, at 20:31, Paolo Bonzini wrote: > > The first patch ensures that XSAVES is not exposed in the guest until > we emulate MSR_IA32_XSS. The second exp