From patchwork Mon Nov 13 09:17:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10055405 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 2CDB860586 for ; Mon, 13 Nov 2017 09:28:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1802029338 for ; Mon, 13 Nov 2017 09:28:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C7462933E; Mon, 13 Nov 2017 09:28:37 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED 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 8D34B29338 for ; Mon, 13 Nov 2017 09:28:36 +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=LGv5FlIcdMPMCv5VmTirajzV4zvsdQ1lK5XYDW3BN/M=; b=GF26IASb2BAJ31ZxwujDYJibpB tjJa6xYxjjTuIBjHIaiTcXIG2s9XRSsGYMJJe4IanB3x6Ljf9ZBgjz79TiJW5+aPhewMfJPxzrkdF iI4jqlKnOFrhiSac0AvoRRHOE9+jMkp9F1Pi2KHdKSMSfftayd/JSAmAswba1l/7HHubTP4cZ+FPB zj+TbbveyPuyBx1TWDS6CmlB3RjpPfhbrP7OgE6+r5lxZMX1obrmuOUnTVtZs+HAEYJh8/k2EZnX2 +3uL9PXHnVskccE33N5W2cUMX9OzW9Nd46wHRayu2NZa+CQsgQJOXbQoz8jFlpKVsR/IP4TBf5wrh dVRfFLow==; 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 1eEB2h-0004lJ-R4; Mon, 13 Nov 2017 09:28:35 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEAt5-0002Hm-EJ for linux-arm-kernel@lists.infradead.org; Mon, 13 Nov 2017 09:18:45 +0000 Received: by mail-wm0-x241.google.com with SMTP id y80so13215303wmd.0 for ; Mon, 13 Nov 2017 01:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GwVIPb+xK09LQy8xYazsmkofUNAklb6kbYgqrGrbd9Q=; b=gEHNzTolPeL9pVMV4V/DQUpZI4H8HeSPGOY7rPjskPNnL1SonvQ9wniPuG5AtKg8Me XvlLE2JiYXhNVCg1qvmJjf6X6bSm8OtZzjIM75sllDz5ckb38wUzNZ1Z48YSAN15+8O0 D/1PbwrUlpkNET4jJrtccqOx9e02Fj0D1nO10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GwVIPb+xK09LQy8xYazsmkofUNAklb6kbYgqrGrbd9Q=; b=g5eQd+HHpP4oh48BWZIGn5b8ZG6sODOnh2eWVKweGPCKupLjk5u+qOTbVHJsvPipBO 50+NUG462p78SAs/UZv7FoUFHgFTz9JxuohTNPXjIydPtqDmg0qWRW3yqXGVA0RhGYXI NZYhE5Se26bMEcNmMUF7kzY5KSfxxe/zZM84m8fc8PMZCicAnMEx46GEMTxXiOQAYFfs gCnbV/svoyNCh5+sbljv8vkCc+bPUyXtOTPT+Ge7bj96xCrK2Mvz/0agdU2G/w0MqA9t 4Rs3PKd67OMnC3omHTFQ3/v29Yj+YldezZ0TnsQWjCUyiLVSM72XRmrEXLPTqlA/nfF7 UGIA== X-Gm-Message-State: AJaThX4rjWaCnrAQo4+tPqUlSxnAfCcUbexdXiuasvHBVQrARImKEhtu ed9Nh+0shNZhVwxN/fjaWhFudQ== X-Google-Smtp-Source: AGs4zMYdj3bcpyHwYyVt8oJVwYaOm1SONqNnx0ehwqTqQYYabQZ1tIYEhyKIqIq7fKQWfdV6sHC2Gg== X-Received: by 10.28.66.215 with SMTP id k84mr6197089wmi.143.1510564699936; Mon, 13 Nov 2017 01:18:19 -0800 (PST) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id x63sm9651399wma.39.2017.11.13.01.18.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Nov 2017 01:18:19 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 18/27] KVM: arm/arm64: GICv4: Add doorbell interrupt handling Date: Mon, 13 Nov 2017 10:17:43 +0100 Message-Id: <20171113091752.10663-19-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171113091752.10663-1-christoffer.dall@linaro.org> References: <20171113091752.10663-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171113_011840_042430_A135E9D2 X-CRM114-Status: GOOD ( 14.82 ) 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: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org 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 From: Marc Zyngier When a vPE is not running, a VLPI being made pending results in a doorbell interrupt being delivered. Let's handle this interrupt and update the pending_last flag that indicates that VLPIs are pending. The corresponding vcpu is also kicked into action. Special care is taken to prevent the doorbell from being enabled at request time (this is controlled separately), and to make the disabling on the interrupt non-lazy. Reviewed-by: Christoffer Dall Reviewed-by: Eric Auger Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-v4.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c index 2edfe23c8238..796e00c77903 100644 --- a/virt/kvm/arm/vgic/vgic-v4.c +++ b/virt/kvm/arm/vgic/vgic-v4.c @@ -16,12 +16,24 @@ */ #include +#include #include #include #include #include "vgic.h" +static irqreturn_t vgic_v4_doorbell_handler(int irq, void *info) +{ + struct kvm_vcpu *vcpu = info; + + vcpu->arch.vgic_cpu.vgic_v3.its_vpe.pending_last = true; + kvm_make_request(KVM_REQ_IRQ_PENDING, vcpu); + kvm_vcpu_kick(vcpu); + + return IRQ_HANDLED; +} + /** * vgic_v4_init - Initialize the GICv4 data structures * @kvm: Pointer to the VM being initialized @@ -61,6 +73,33 @@ int vgic_v4_init(struct kvm *kvm) return ret; } + kvm_for_each_vcpu(i, vcpu, kvm) { + int irq = dist->its_vm.vpes[i]->irq; + + /* + * Don't automatically enable the doorbell, as we're + * flipping it back and forth when the vcpu gets + * blocked. Also disable the lazy disabling, as the + * doorbell could kick us out of the guest too + * early... + */ + irq_set_status_flags(irq, IRQ_NOAUTOEN | IRQ_DISABLE_UNLAZY); + ret = request_irq(irq, vgic_v4_doorbell_handler, + 0, "vcpu", vcpu); + if (ret) { + kvm_err("failed to allocate vcpu IRQ%d\n", irq); + /* + * Trick: adjust the number of vpes so we know + * how many to nuke on teardown... + */ + dist->its_vm.nr_vpes = i; + break; + } + } + + if (ret) + vgic_v4_teardown(kvm); + return ret; } @@ -73,10 +112,19 @@ int vgic_v4_init(struct kvm *kvm) void vgic_v4_teardown(struct kvm *kvm) { struct its_vm *its_vm = &kvm->arch.vgic.its_vm; + int i; if (!its_vm->vpes) return; + for (i = 0; i < its_vm->nr_vpes; i++) { + struct kvm_vcpu *vcpu = kvm_get_vcpu(kvm, i); + int irq = its_vm->vpes[i]->irq; + + irq_clear_status_flags(irq, IRQ_NOAUTOEN | IRQ_DISABLE_UNLAZY); + free_irq(irq, vcpu); + } + its_free_vcpu_irqs(its_vm); kfree(its_vm->vpes); its_vm->nr_vpes = 0;