Re: [PATCH v2 0/3] KVM: arm/arm64: Allow to use KVM without in-kernel irqchip

2015-07-24 Thread Marc Zyngier
On 24/07/15 16:27, Pavel Fedin wrote: >>> Ok, let's leave this API alone then for now... >>> Will then be a concensus if i tweak the thing a little bit and we just >>> enable KVM without both > vGIC >>> and vTimer ? It will be an emulator's problem how to handle them then. >> >> Well, let's see

[PATCH v3 06/11] KVM: arm/arm64: vgic: Allow dynamic mapping of physical/virtual interrupts

2015-07-24 Thread Marc Zyngier
In order to be able to feed physical interrupts to a guest, we need to be able to establish the virtual-physical mapping between the two worlds. The mappings are kept in a set of RCU lists, indexed by virtual interrupts. Signed-off-by: Marc Zyngier --- arch/arm/kvm/arm.c | 2 + include/kv

[PATCH v3 11/11] KVM: arm/arm64: vgic: Allow HW interrupts for non-shared devices

2015-07-24 Thread Marc Zyngier
So far, the only use of the HW interrupt facility is the timer, implying that the active state is context-switched for each vcpu, as the device is is shared across all vcpus. This does not work for a device that has been assigned to a VM, as the guest is entierely in control of that device (the HW

[PATCH v3 03/11] KVM: arm/arm64: vgic: Convert struct vgic_lr to use bitfields

2015-07-24 Thread Marc Zyngier
As we're about to cram more information in the vgic_lr structure (HW interrupt number and additional state information), we switch to a layout similar to the HW's: - use bitfields to save space (we don't need more than 10 bits to represent the irq numbers) - source CPU and HW interrupt can share

[PATCH v3 07/11] KVM: arm/arm64: vgic: Allow HW interrupts to be queued to a guest

2015-07-24 Thread Marc Zyngier
To allow a HW interrupt to be injected into a guest, we lookup the guest virtual interrupt in the irq_phys_map list, and if we have a match, encode both interrupts in the LR. We also mark the interrupt as "active" at the host distributor level. On guest EOI on the virtual interrupt, the host inte

[PATCH v3 05/11] KVM: arm/arm64: vgic: Relax vgic_can_sample_irq for edge IRQs

2015-07-24 Thread Marc Zyngier
We only set the irq_queued flag for level interrupts, meaning that "!vgic_irq_is_queued(vcpu, irq)" is a good enough predicate for all interrupts. This will allow us to inject edge HW interrupts, for which the state ACTIVE+PENDING is not allowed. Reviewed-by: Christoffer Dall Signed-off-by: Marc

[PATCH v3 02/11] arm/arm64: KVM: Move vgic handling to a non-preemptible section

2015-07-24 Thread Marc Zyngier
As we're about to introduce some serious GIC-poking to the vgic code, it is important to make sure that we're going to poke the part of the GIC that belongs to the CPU we're about to run on (otherwise, we'd end up with some unexpected interrupts firing)... Introducing a non-preemptible section in

[PATCH v3 04/11] KVM: arm/arm64: vgic: Allow HW irq to be encoded in LR

2015-07-24 Thread Marc Zyngier
Now that struct vgic_lr supports the LR_HW bit and carries a hwirq field, we can encode that information into the list registers. This patch provides implementations for both GICv2 and GICv3. Signed-off-by: Marc Zyngier --- include/linux/irqchip/arm-gic-v3.h | 3 +++ include/linux/irqchip/arm-

[PATCH v3 00/11] arm/arm64: KVM: Active interrupt state switching for shared devices

2015-07-24 Thread Marc Zyngier
>From day 1, our timer code has been using a terrible hack: whenever the guest is scheduled with a timer interrupt pending (i.e. the HW timer has expired), we restore the timer state with the MASK bit set, in order to avoid the physical interrupt to fire again. And again. And again... This is abso

[PATCH v3 10/11] KVM: arm/arm64: timer: Allow the timer to control the active state

2015-07-24 Thread Marc Zyngier
In order to remove the crude hack where we sneak the masked bit into the timer's control register, make use of the phys_irq_map API control the active state of the interrupt. This causes some limited changes to allow for potential error propagation. Signed-off-by: Marc Zyngier --- arch/arm/kvm/

[PATCH v3 09/11] KVM: arm/arm64: vgic: Prevent userspace injection of a mapped interrupt

2015-07-24 Thread Marc Zyngier
Virtual interrupts mapped to a HW interrupt should only be triggered from inside the kernel. Otherwise, you could end up confusing the kernel (and the GIC's) state machine. Rearrange the injection path so that kvm_vgic_inject_irq is used for non-mapped interrupts, and kvm_vgic_inject_mapped_irq is

[PATCH v3 01/11] arm/arm64: KVM: Fix ordering of timer/GIC on guest entry

2015-07-24 Thread Marc Zyngier
As we now inject the timer interrupt when we're about to enter the guest, it makes a lot more sense to make sure this happens before the vgic code queues the pending interrupts. Otherwise, we get the interrupt on the following exit, which is not great for latency (and leads to all kind of bizarre

[PATCH v3 08/11] KVM: arm/arm64: vgic: Add vgic_{get, set}_phys_irq_active

2015-07-24 Thread Marc Zyngier
In order to control the active state of an interrupt, introduce a pair of accessors allowing the state to be set/queried. This only affects the logical state, and the HW state will only be applied at world-switch time. Acked-by: Christoffer Dall Signed-off-by: Marc Zyngier --- include/kvm/arm_

RE: [PATCH v2 0/3] KVM: arm/arm64: Allow to use KVM without in-kernel irqchip

2015-07-24 Thread Pavel Fedin
> > Ok, let's leave this API alone then for now... > > Will then be a concensus if i tweak the thing a little bit and we just > > enable KVM without both vGIC > > and vTimer ? It will be an emulator's problem how to handle them then. > > Well, let's see the patches first, and how invasive they

add multiple times opening support to a virtserialport

2015-07-24 Thread Matt Ma
Hi all, Linaro has developed the foundation for the new Android Emulator code base based on a fairly recent upstream QEMU code base, when we re-based the code, we updated the device model to be more virtio based (for example the drives are now virtio block devices). The aim of this is to minimise

add multiple times opening support to a virtserialport

2015-07-24 Thread Matt Ma
Hi all, Linaro has developed the foundation for the new Android Emulator code base based on a fairly recent upstream QEMU code base, when we re-based the code, we updated the device model to be more virtio based (for example the drives are now virtio block devices). The aim of this is to minimise

[RFC 2/2] drivers: vfio: pci: Add virtual MSI doorbell support.

2015-07-24 Thread Pranavkumar Sawargaonkar
In ARM/ARM64 MSI transactions goes through iommu/smmu. This means there has to be an iommu mapping created for MSI addresses. This patch adds a new ioctl "VFIO_DEVICE_PCI_MSI_VIRT_DOORBELL". Userspace can call this ioctl to do following things: 1. Create a virtual doorbell mapping between MSI IOV

[RFC 0/2] VFIO: Add virtual MSI doorbell support.

2015-07-24 Thread Pranavkumar Sawargaonkar
In current VFIO MSI/MSI-X implementation, linux host kernel allocates MSI/MSI-X vectors when userspace requests through vfio ioctls. Vfio creates irqfd mappings to notify MSI/MSI-X interrupts to the userspace when raised. Guest OS will see emulated MSI/MSI-X controller and receives an interrupt whe

[RFC 1/2] drivers: vfio: iommu map and unmap device specific memory from kernel.

2015-07-24 Thread Pranavkumar Sawargaonkar
In vfio we map and unmap various regions using "VFIO_IOMMU_MAP_DMA" and "VFIO_IOMMU_UNMAP_DMA" ioctls from userspace. Some device regions (like MSI in case of PCI), which we do not expose to the userspace with mmap. These regions might require vfio driver to create an iommu mapping, as their trans