From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoffer Dall Subject: Re: [RFC PATCH 07/45] KVM: arm/arm64: vgic-new: Add vgic GICv2 change_affinity Date: Wed, 30 Mar 2016 11:29:42 +0200 Message-ID: <20160330092942.GH4126@cbox> References: <1458871508-17279-1-git-send-email-andre.przywara@arm.com> <1458871508-17279-8-git-send-email-andre.przywara@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Marc Zyngier , Eric Auger , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org To: Andre Przywara Return-path: Received: from mail-wm0-f50.google.com ([74.125.82.50]:34958 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750720AbcC3J3o (ORCPT ); Wed, 30 Mar 2016 05:29:44 -0400 Received: by mail-wm0-f50.google.com with SMTP id 191so81615768wmq.0 for ; Wed, 30 Mar 2016 02:29:44 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1458871508-17279-8-git-send-email-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Mar 25, 2016 at 02:04:30AM +0000, Andre Przywara wrote: > From: Christoffer Dall > > Introduce vgic-v2.c to contain GICv2 specific functions. > Add vgic_v2_irq_change_affinity() to change the target VCPU of a > particular interrupt. > > Signed-off-by: Christoffer Dall > Signed-off-by: Eric Auger > Signed-off-by: Marc Zyngier > Signed-off-by: Andre Przywara > --- > virt/kvm/arm/vgic/vgic-v2.c | 40 ++++++++++++++++++++++++++++++++++++++++ > virt/kvm/arm/vgic/vgic.h | 2 ++ > 2 files changed, 42 insertions(+) > create mode 100644 virt/kvm/arm/vgic/vgic-v2.c > > diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c > new file mode 100644 > index 0000000..0bf6f27 > --- /dev/null > +++ b/virt/kvm/arm/vgic/vgic-v2.c > @@ -0,0 +1,40 @@ > +/* > + * Copyright (C) 2015, 2016 ARM Ltd. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program. If not, see . > + */ > + > +#include > +#include > + > +#include "vgic.h" > + > +void vgic_v2_irq_change_affinity(struct kvm *kvm, u32 intid, u8 new_targets) > +{ > + struct vgic_dist *dist = &kvm->arch.vgic; > + struct vgic_irq *irq; > + int target; > + > + BUG_ON(intid <= VGIC_MAX_PRIVATE); > + BUG_ON(dist->vgic_model != KVM_DEV_TYPE_ARM_VGIC_V2); we can probably get rid of the last BUG_ON here. > + > + irq = vgic_get_irq(kvm, NULL, intid); > + > + spin_lock(&irq->irq_lock); > + irq->targets = new_targets; > + > + target = ffs(irq->targets); > + target = target ? (target - 1) : 0; > + irq->target_vcpu = kvm_get_vcpu(kvm, target); > + spin_unlock(&irq->irq_lock); > +} > diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h > index e9f4aa6..b2faf00 100644 > --- a/virt/kvm/arm/vgic/vgic.h > +++ b/virt/kvm/arm/vgic/vgic.h > @@ -20,4 +20,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, > u32 intid); > bool vgic_queue_irq(struct kvm *kvm, struct vgic_irq *irq); > > +void vgic_v2_irq_change_affinity(struct kvm *kvm, u32 intid, u8 target); > + > #endif > -- > 2.7.3 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: christoffer.dall@linaro.org (Christoffer Dall) Date: Wed, 30 Mar 2016 11:29:42 +0200 Subject: [RFC PATCH 07/45] KVM: arm/arm64: vgic-new: Add vgic GICv2 change_affinity In-Reply-To: <1458871508-17279-8-git-send-email-andre.przywara@arm.com> References: <1458871508-17279-1-git-send-email-andre.przywara@arm.com> <1458871508-17279-8-git-send-email-andre.przywara@arm.com> Message-ID: <20160330092942.GH4126@cbox> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, Mar 25, 2016 at 02:04:30AM +0000, Andre Przywara wrote: > From: Christoffer Dall > > Introduce vgic-v2.c to contain GICv2 specific functions. > Add vgic_v2_irq_change_affinity() to change the target VCPU of a > particular interrupt. > > Signed-off-by: Christoffer Dall > Signed-off-by: Eric Auger > Signed-off-by: Marc Zyngier > Signed-off-by: Andre Przywara > --- > virt/kvm/arm/vgic/vgic-v2.c | 40 ++++++++++++++++++++++++++++++++++++++++ > virt/kvm/arm/vgic/vgic.h | 2 ++ > 2 files changed, 42 insertions(+) > create mode 100644 virt/kvm/arm/vgic/vgic-v2.c > > diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c > new file mode 100644 > index 0000000..0bf6f27 > --- /dev/null > +++ b/virt/kvm/arm/vgic/vgic-v2.c > @@ -0,0 +1,40 @@ > +/* > + * Copyright (C) 2015, 2016 ARM Ltd. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program. If not, see . > + */ > + > +#include > +#include > + > +#include "vgic.h" > + > +void vgic_v2_irq_change_affinity(struct kvm *kvm, u32 intid, u8 new_targets) > +{ > + struct vgic_dist *dist = &kvm->arch.vgic; > + struct vgic_irq *irq; > + int target; > + > + BUG_ON(intid <= VGIC_MAX_PRIVATE); > + BUG_ON(dist->vgic_model != KVM_DEV_TYPE_ARM_VGIC_V2); we can probably get rid of the last BUG_ON here. > + > + irq = vgic_get_irq(kvm, NULL, intid); > + > + spin_lock(&irq->irq_lock); > + irq->targets = new_targets; > + > + target = ffs(irq->targets); > + target = target ? (target - 1) : 0; > + irq->target_vcpu = kvm_get_vcpu(kvm, target); > + spin_unlock(&irq->irq_lock); > +} > diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h > index e9f4aa6..b2faf00 100644 > --- a/virt/kvm/arm/vgic/vgic.h > +++ b/virt/kvm/arm/vgic/vgic.h > @@ -20,4 +20,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, > u32 intid); > bool vgic_queue_irq(struct kvm *kvm, struct vgic_irq *irq); > > +void vgic_v2_irq_change_affinity(struct kvm *kvm, u32 intid, u8 target); > + > #endif > -- > 2.7.3 >