All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm/arm64: VGIC: Kick new VCPU on interrupt migration
@ 2018-04-17 10:23 ` Andre Przywara
  0 siblings, 0 replies; 4+ messages in thread
From: Andre Przywara @ 2018-04-17 10:23 UTC (permalink / raw)
  To: Christoffer Dall, Marc Zyngier
  Cc: linux-arm-kernel, Stefano Stabellini, kvmarm, kvm

When vgic_prune_ap_list() finds an interrupt that needs to be migrated
to a new VCPU, we should notify this VCPU of the pending interrupt,
since it requires immediate action.
Kick this VCPU once we have added the new IRQ to the list, but only
after dropping the locks.

Reported-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 virt/kvm/arm/vgic/vgic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
index e74baec76361..4b6d72939c42 100644
--- a/virt/kvm/arm/vgic/vgic.c
+++ b/virt/kvm/arm/vgic/vgic.c
@@ -594,6 +594,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
 
 	list_for_each_entry_safe(irq, tmp, &vgic_cpu->ap_list_head, ap_list) {
 		struct kvm_vcpu *target_vcpu, *vcpuA, *vcpuB;
+		bool target_vcpu_needs_kick = false;
 
 		spin_lock(&irq->irq_lock);
 
@@ -664,11 +665,18 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
 			list_del(&irq->ap_list);
 			irq->vcpu = target_vcpu;
 			list_add_tail(&irq->ap_list, &new_cpu->ap_list_head);
+			target_vcpu_needs_kick = true;
 		}
 
 		spin_unlock(&irq->irq_lock);
 		spin_unlock(&vcpuB->arch.vgic_cpu.ap_list_lock);
 		spin_unlock_irqrestore(&vcpuA->arch.vgic_cpu.ap_list_lock, flags);
+
+		if (target_vcpu_needs_kick) {
+			kvm_make_request(KVM_REQ_IRQ_PENDING, target_vcpu);
+			kvm_vcpu_kick(target_vcpu);
+		}
+
 		goto retry;
 	}
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] KVM: arm/arm64: VGIC: Kick new VCPU on interrupt migration
@ 2018-04-17 10:23 ` Andre Przywara
  0 siblings, 0 replies; 4+ messages in thread
From: Andre Przywara @ 2018-04-17 10:23 UTC (permalink / raw)
  To: linux-arm-kernel

When vgic_prune_ap_list() finds an interrupt that needs to be migrated
to a new VCPU, we should notify this VCPU of the pending interrupt,
since it requires immediate action.
Kick this VCPU once we have added the new IRQ to the list, but only
after dropping the locks.

Reported-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 virt/kvm/arm/vgic/vgic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
index e74baec76361..4b6d72939c42 100644
--- a/virt/kvm/arm/vgic/vgic.c
+++ b/virt/kvm/arm/vgic/vgic.c
@@ -594,6 +594,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
 
 	list_for_each_entry_safe(irq, tmp, &vgic_cpu->ap_list_head, ap_list) {
 		struct kvm_vcpu *target_vcpu, *vcpuA, *vcpuB;
+		bool target_vcpu_needs_kick = false;
 
 		spin_lock(&irq->irq_lock);
 
@@ -664,11 +665,18 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
 			list_del(&irq->ap_list);
 			irq->vcpu = target_vcpu;
 			list_add_tail(&irq->ap_list, &new_cpu->ap_list_head);
+			target_vcpu_needs_kick = true;
 		}
 
 		spin_unlock(&irq->irq_lock);
 		spin_unlock(&vcpuB->arch.vgic_cpu.ap_list_lock);
 		spin_unlock_irqrestore(&vcpuA->arch.vgic_cpu.ap_list_lock, flags);
+
+		if (target_vcpu_needs_kick) {
+			kvm_make_request(KVM_REQ_IRQ_PENDING, target_vcpu);
+			kvm_vcpu_kick(target_vcpu);
+		}
+
 		goto retry;
 	}
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: arm/arm64: VGIC: Kick new VCPU on interrupt migration
  2018-04-17 10:23 ` Andre Przywara
@ 2018-04-17 11:32   ` Christoffer Dall
  -1 siblings, 0 replies; 4+ messages in thread
From: Christoffer Dall @ 2018-04-17 11:32 UTC (permalink / raw)
  To: Andre Przywara
  Cc: Marc Zyngier, Stefano Stabellini, kvmarm, kvm, linux-arm-kernel

On Tue, Apr 17, 2018 at 11:23:49AM +0100, Andre Przywara wrote:
> When vgic_prune_ap_list() finds an interrupt that needs to be migrated
> to a new VCPU, we should notify this VCPU of the pending interrupt,
> since it requires immediate action.
> Kick this VCPU once we have added the new IRQ to the list, but only
> after dropping the locks.
> 
> Reported-by: Stefano Stabellini <sstabellini@kernel.org>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>

Reviewed-by: Christoffer Dall <christoffer.dall@arm.com>

> ---
>  virt/kvm/arm/vgic/vgic.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
> index e74baec76361..4b6d72939c42 100644
> --- a/virt/kvm/arm/vgic/vgic.c
> +++ b/virt/kvm/arm/vgic/vgic.c
> @@ -594,6 +594,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
>  
>  	list_for_each_entry_safe(irq, tmp, &vgic_cpu->ap_list_head, ap_list) {
>  		struct kvm_vcpu *target_vcpu, *vcpuA, *vcpuB;
> +		bool target_vcpu_needs_kick = false;
>  
>  		spin_lock(&irq->irq_lock);
>  
> @@ -664,11 +665,18 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
>  			list_del(&irq->ap_list);
>  			irq->vcpu = target_vcpu;
>  			list_add_tail(&irq->ap_list, &new_cpu->ap_list_head);
> +			target_vcpu_needs_kick = true;
>  		}
>  
>  		spin_unlock(&irq->irq_lock);
>  		spin_unlock(&vcpuB->arch.vgic_cpu.ap_list_lock);
>  		spin_unlock_irqrestore(&vcpuA->arch.vgic_cpu.ap_list_lock, flags);
> +
> +		if (target_vcpu_needs_kick) {
> +			kvm_make_request(KVM_REQ_IRQ_PENDING, target_vcpu);
> +			kvm_vcpu_kick(target_vcpu);
> +		}
> +
>  		goto retry;
>  	}
>  
> -- 
> 2.14.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] KVM: arm/arm64: VGIC: Kick new VCPU on interrupt migration
@ 2018-04-17 11:32   ` Christoffer Dall
  0 siblings, 0 replies; 4+ messages in thread
From: Christoffer Dall @ 2018-04-17 11:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 17, 2018 at 11:23:49AM +0100, Andre Przywara wrote:
> When vgic_prune_ap_list() finds an interrupt that needs to be migrated
> to a new VCPU, we should notify this VCPU of the pending interrupt,
> since it requires immediate action.
> Kick this VCPU once we have added the new IRQ to the list, but only
> after dropping the locks.
> 
> Reported-by: Stefano Stabellini <sstabellini@kernel.org>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>

Reviewed-by: Christoffer Dall <christoffer.dall@arm.com>

> ---
>  virt/kvm/arm/vgic/vgic.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
> index e74baec76361..4b6d72939c42 100644
> --- a/virt/kvm/arm/vgic/vgic.c
> +++ b/virt/kvm/arm/vgic/vgic.c
> @@ -594,6 +594,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
>  
>  	list_for_each_entry_safe(irq, tmp, &vgic_cpu->ap_list_head, ap_list) {
>  		struct kvm_vcpu *target_vcpu, *vcpuA, *vcpuB;
> +		bool target_vcpu_needs_kick = false;
>  
>  		spin_lock(&irq->irq_lock);
>  
> @@ -664,11 +665,18 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)
>  			list_del(&irq->ap_list);
>  			irq->vcpu = target_vcpu;
>  			list_add_tail(&irq->ap_list, &new_cpu->ap_list_head);
> +			target_vcpu_needs_kick = true;
>  		}
>  
>  		spin_unlock(&irq->irq_lock);
>  		spin_unlock(&vcpuB->arch.vgic_cpu.ap_list_lock);
>  		spin_unlock_irqrestore(&vcpuA->arch.vgic_cpu.ap_list_lock, flags);
> +
> +		if (target_vcpu_needs_kick) {
> +			kvm_make_request(KVM_REQ_IRQ_PENDING, target_vcpu);
> +			kvm_vcpu_kick(target_vcpu);
> +		}
> +
>  		goto retry;
>  	}
>  
> -- 
> 2.14.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-17 11:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-17 10:23 [PATCH] KVM: arm/arm64: VGIC: Kick new VCPU on interrupt migration Andre Przywara
2018-04-17 10:23 ` Andre Przywara
2018-04-17 11:32 ` Christoffer Dall
2018-04-17 11:32   ` Christoffer Dall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.