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

2015-08-07 Thread Marc Zyngier
On 07/08/15 08:05, Eric Auger wrote: Hi Marc, On 08/06/2015 06:44 PM, Marc Zyngier wrote: On 05/08/15 14:47, Christoffer Dall wrote: On Wed, Aug 05, 2015 at 01:47:27PM +0200, Eric Auger wrote: On 08/05/2015 12:53 PM, Christoffer Dall wrote: On Wed, Aug 05, 2015 at 10:44:09AM +0100, Marc

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

2015-08-07 Thread Eric Auger
Hi Marc, On 08/06/2015 06:44 PM, Marc Zyngier wrote: On 05/08/15 14:47, Christoffer Dall wrote: On Wed, Aug 05, 2015 at 01:47:27PM +0200, Eric Auger wrote: On 08/05/2015 12:53 PM, Christoffer Dall wrote: On Wed, Aug 05, 2015 at 10:44:09AM +0100, Marc Zyngier wrote: On 05/08/15 08:32, Eric

Re: [PATCH] kvm:arm:Fix error handling in the function vgic_v3_probe

2015-08-07 Thread Krzysztof Kozlowski
On 07.08.2015 10:31, nick wrote: On 2015-08-06 08:47 PM, Krzysztof Kozlowski wrote: 2015-08-06 22:16 GMT+09:00 nick xerofo...@gmail.com: On 2015-08-06 08:00 AM, Paolo Bonzini wrote: On 06/08/2015 10:06, Marc Zyngier wrote: If this structure of function pointers can handle function

[PATCH v2 4/4] KVM: arm/arm64: implement kvm_arm_[halt,resume]_guest

2015-08-07 Thread Eric Auger
We introduce kvm_arm_halt_guest and resume functions. They will be used for IRQ forward state change. Halt is synchronous and prevents the guest from being re-entered. We use the same mechanism put in place for PSCI former pause, now renamed power_off. A new flag is introduced in arch vcpu state,

[PATCH v2 3/4] KVM: arm/arm64: check power_off in critical section before VCPU run

2015-08-07 Thread Eric Auger
In case KVM_SET_MP_STATE ioctl is called just after we executed the vcpu_sleep check, we can enter the guest although KVM_MP_STATE_STOPPED is set. Let's check the power_off state in the critical section, just before entering the guest. Signed-off-by: Eric Auger eric.au...@linaro.org Reported-by:

[PATCH v2 2/4] KVM: arm/arm64: check power_off in kvm_arch_vcpu_runnable

2015-08-07 Thread Eric Auger
kvm_arch_vcpu_runnable now also checks whether the power_off flag is set. Signed-off-by: Eric Auger eric.au...@linaro.org --- arch/arm/kvm/arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 3ac6b4c..4f50be3 100644 ---

[PATCH v2 0/4] KVM: arm/arm64: guest synchronous halt/resume

2015-08-07 Thread Eric Auger
This series introduces the capability to synchronously exit the guest and prevent it from being re-entered. This modality will be used by IRQ forwarding series when changing the state of the IRQ. Former pause flag used when starting the vcpu in KVM_ARM_VCPU_POWER_OFF state, in PSCI calls and in

Re: [PATCH 2/2] kvm: arm/arm64: implement kvm_arm_[halt, resume]_guest

2015-08-07 Thread Eric Auger
Hi Chistoffer, On 07/18/2015 11:18 AM, Christoffer Dall wrote: On Mon, Jul 06, 2015 at 02:49:56PM +0200, Eric Auger wrote: On halt, the guest is forced to exit and prevented from being re-entered. This is synchronous. Those two operations will be needed for IRQ forwarding setting.

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

2015-08-07 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 v4 06/11] KVM: arm/arm64: vgic: Allow dynamic mapping of physical/virtual interrupts

2015-08-07 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 marc.zyng...@arm.com --- arch/arm/kvm/arm.c

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

2015-08-07 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. Reviewed-by: Christoffer Dall

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

2015-08-07 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

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

2015-08-07 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

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

2015-08-07 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

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

2015-08-07 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

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

2015-08-07 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 v4 08/11] KVM: arm/arm64: vgic: Add vgic_{get, set}_phys_irq_active

2015-08-07 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 christoffer.d...@linaro.org Signed-off-by: Marc

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

2015-08-07 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

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

2015-08-07 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. Reviewed-by: Christoffer Dall christoffer.d...@linaro.org Signed-off-by: Marc Zyngier

Re: [PATCH v4 4/5] KVM: introduce kvm_arch functions for IRQ bypass

2015-08-07 Thread Alex Williamson
On Mon, 2015-08-03 at 19:20 +0200, Eric Auger wrote: This patch introduces - kvm_arch_irq_bypass_add_producer - kvm_arch_irq_bypass_del_producer - kvm_arch_irq_bypass_stop - kvm_arch_irq_bypass_start They make possible to specialize the KVM IRQ bypass consumer in case

Re: [PATCH v4 5/5] KVM: eventfd: add irq bypass consumer management

2015-08-07 Thread Alex Williamson
On Mon, 2015-08-03 at 19:20 +0200, Eric Auger wrote: This patch adds the registration/unregistration of an irq_bypass_consumer on irqfd assignment/deassignment. Signed-off-by: Eric Auger eric.au...@linaro.org Signed-off-by: Feng Wu feng...@intel.com --- v2 - v3 (Feng Wu): - Use

Re: [PATCH 1/2] KVM: arm: rename pause into power_off

2015-08-07 Thread Eric Auger
Hi Christoffer, On 07/18/2015 11:09 AM, Christoffer Dall wrote: On Mon, Jul 06, 2015 at 02:49:55PM +0200, Eric Auger wrote: The kvm_vcpu_arch pause field is renamed into power_off to prepare for the introduction of a new pause field. Signed-off-by: Eric Auger eric.au...@linaro.org v4 - v5:

Re: [PATCH 2/2] kvm: arm/arm64: implement kvm_arm_[halt, resume]_guest

2015-08-07 Thread Eric Auger
On 07/18/2015 11:18 AM, Christoffer Dall wrote: On Mon, Jul 06, 2015 at 02:49:56PM +0200, Eric Auger wrote: On halt, the guest is forced to exit and prevented from being re-entered. This is synchronous. Those two operations will be needed for IRQ forwarding setting. Signed-off-by: Eric