From patchwork Wed Jun 28 15:04:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 9814779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3FC82603D7 for ; Wed, 28 Jun 2017 15:54:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D3EC284FE for ; Wed, 28 Jun 2017 15:54:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DD09285DA; Wed, 28 Jun 2017 15:54:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B72D2284FE for ; Wed, 28 Jun 2017 15:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+kV4UztujbrdEOhS0hu4nId9VdsA5ZGTLzKpXbFsbyY=; b=kpnHbLdXh0zL5pNefa+fjbUKqC YSPsbbqslLDAb3U29TaIfYs06x39Wgs0LyQm06n8Orkj0Vl7R8cym3+POKVbma70nqeYYBud9DHtn CJW/uhyTM8L7DF+I2b3wAZXYyKQT1ONN7OB5fD0Fw2LQT4+5vZ/Y9KKShup9B0LQRERXJBl/RWGdU CAE3GTCevWRu+oAjXarPe+nfeNb58bk0DqiFUIoLGpzKzLi7WvzHyyZITNHhoJizHN6bV6CMegheM EoHr/ZgTkuE/ZlL2QK2zBqLfBAWSe+qDfv8Nxa0I6W+ESYB2oLI97gtGGgmQGvdkuH+KAJUpV2Y9K rHlxvNqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQFIg-0007SM-EH; Wed, 28 Jun 2017 15:54:42 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQFBG-0001fS-92 for linux-arm-kernel@bombadil.infradead.org; Wed, 28 Jun 2017 15:47:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=euR2mAscn9qckwWd7Xb9dxj5dZZH3/wXQ1ZjTd/Z/+E=; b=EjTu/DqAtFF+2N1rIh41mQBud zrmqlTz9AUP62cR7uD4x6CFVhStO8QmRCEw2EWMK+CyD9Eleik5S+wwObk5CMsVdlDt0KTLJznMdA 2+d3ghC2KsPQWm6zlRqqoJ+BJbtVH7YX2Zm140PqK4nCC246FYEIm2KQkjwRrAEQ/9hYeHNOpYAiS oHQ18GQB1tMb4oOWhQjMh89iUw81wigFV0ZF1GMSQefnFKYMRqSkDz3aLf7XRSBQVC5vm5/lLw752 OZ9ZjMXZ1xvoc/nRsDe2PsaTv9AdZrK2oT6tagUiQx1x6wdJgEbef65HxIe0oq2YgL2FpMdyuxrEE RlTX8uBCA==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQEXt-0000Fy-Cm for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 15:06:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C88D215AD; Wed, 28 Jun 2017 08:06:00 -0700 (PDT) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.207.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6016A3F4FF; Wed, 28 Jun 2017 08:05:59 -0700 (PDT) From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 49/52] KVM: arm/arm64: GICv4: Hook vPE scheduling into vgic flush/sync Date: Wed, 28 Jun 2017 16:04:08 +0100 Message-Id: <20170628150411.15846-50-marc.zyngier@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170628150411.15846-1-marc.zyngier@arm.com> References: <20170628150411.15846-1-marc.zyngier@arm.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Jason Cooper , Eric Auger , Christoffer Dall , Thomas Gleixner , Shanker Donthineni MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The redistributor needs to be told which vPE is about to be run, and tells us whether there is any pending VLPI on exit. Let's add the scheduling calls to the vgic flush/sync functions, allowing the VLPIs to be delivered to the guest. Signed-off-by: Marc Zyngier --- virt/kvm/arm/vgic/vgic-v4.c | 23 +++++++++++++++++++++++ virt/kvm/arm/vgic/vgic.c | 4 ++++ virt/kvm/arm/vgic/vgic.h | 1 + 3 files changed, 28 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c index fe0d0a8ed469..6ede64be94f1 100644 --- a/virt/kvm/arm/vgic/vgic-v4.c +++ b/virt/kvm/arm/vgic/vgic-v4.c @@ -88,6 +88,29 @@ void vgic_v4_teardown(struct kvm *kvm) kfree(its_vm->vpes); } +int vgic_v4_schedule(struct kvm_vcpu *vcpu, bool on) +{ + if (!(kvm_vgic_global_state.has_gicv4 && vgic_has_its(vcpu->kvm))) + return 0; + + /* + * Before making the VPE resident, make sure the redistributor + * expects us here. + */ + if (on) { + int irq = vcpu->arch.vgic_cpu.vgic_v3.its_vpe.irq; + int err; + + err = irq_set_affinity(irq, cpumask_of(smp_processor_id())); + if (err) { + kvm_err("failed irq_set_affinity IRQ%d (%d)\n", irq, err); + return err; + } + } + + return its_schedule_vpe(&vcpu->arch.vgic_cpu.vgic_v3.its_vpe, on); +} + static struct vgic_its *vgic_get_its(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *irq_entry) { diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index a96e566905d2..2106e4c06a12 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -721,6 +721,8 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + WARN_ON(vgic_v4_schedule(vcpu, false)); + /* An empty ap_list_head implies used_lrs == 0 */ if (list_empty(&vcpu->arch.vgic_cpu.ap_list_head)) return; @@ -733,6 +735,8 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) /* Flush our emulation state into the GIC hardware before entering the guest. */ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) { + WARN_ON(vgic_v4_schedule(vcpu, true)); + /* * If there are no virtual interrupts active or pending for this * VCPU, then there is no work to do and we can bail out without diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index 974e382297f9..3ebb6c4443a7 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h @@ -233,5 +233,6 @@ int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, int vgic_v4_init(struct kvm *kvm); void vgic_v4_teardown(struct kvm *kvm); +int vgic_v4_schedule(struct kvm_vcpu *vcpu, bool on); #endif