From patchwork Fri Aug 4 07:44:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 9880755 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 7D80E6031B for ; Fri, 4 Aug 2017 07:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C0112899E for ; Fri, 4 Aug 2017 07:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60C24289AB; Fri, 4 Aug 2017 07:44:42 +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,RCVD_IN_DNSWL_NONE 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 D14932899E for ; Fri, 4 Aug 2017 07:44:41 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UxZHW6upPl0TgW7T7NEkg6iQNI5ed6Hcozeley1n7SI=; b=NA+VRBnpMf5uVo R8Tixq5UTR+xZFxRM3YTpVfSB5R4cQlSijrzcEcywUsoVWJLzMHDj9mcMrmOUiL3uVj1oMRIbx7+Y hdXMeibo3/RWCWZvmzWyxXrBAyesncu/8gcmULbCF8IE2V/1p1wAaWIbdDB6h9AonCsNP3bVXyHLB Md90weEUIX8hFHTwjQL3piwrbYeyq5/GzGbIw4Fa5IA95bzkiUrz2XcTmlzkYlH7Kn/odCQBnEZ41 o7DtoQVYXFQSL3k+B7ykD9DG3AOl/hB5WPMUBFD4hkEMhgn2LSQDfFA1ghBNbvaYmYzUEtS/w8Vci D9eEBnkv1kuy7p7A9VDg==; 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 1ddXHe-0000D0-9Z; Fri, 04 Aug 2017 07:44:34 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ddXHb-0000Au-4h for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2017 07:44:32 +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 962C680D; Fri, 4 Aug 2017 00:44:07 -0700 (PDT) Received: from [10.1.207.16] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE76A3F3E1; Fri, 4 Aug 2017 00:44:05 -0700 (PDT) Subject: Re: [PATCH v3 51/59] KVM: arm/arm64: GICv4: Add doorbell interrupt handling To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org References: <20170731172637.29355-1-marc.zyngier@arm.com> <20170731172637.29355-52-marc.zyngier@arm.com> From: Marc Zyngier Organization: ARM Ltd Message-ID: <8a35ee18-85a5-168b-b3d2-b9f51390b475@arm.com> Date: Fri, 4 Aug 2017 08:44:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170731172637.29355-52-marc.zyngier@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170804_004431_188446_1764FA35 X-CRM114-Status: GOOD ( 16.61 ) 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 , Shameerali Kolothum Thodi , Eric Auger , Christoffer Dall , Thomas Gleixner , Shanker Donthineni 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 On 31/07/17 18:26, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier > --- > virt/kvm/arm/vgic/vgic-v4.c | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c > index 534d3051a078..6af3cde6d7d4 100644 > --- a/virt/kvm/arm/vgic/vgic-v4.c > +++ b/virt/kvm/arm/vgic/vgic-v4.c > @@ -21,6 +21,19 @@ > > #include "vgic.h" > > +static irqreturn_t vgic_v4_doorbell_handler(int irq, void *info) > +{ > + struct kvm_vcpu *vcpu = info; > + > + if (!kvm_vgic_vcpu_pending_irq(vcpu)) { > + vcpu->arch.vgic_cpu.vgic_v3.its_vpe.pending_last = true; > + kvm_make_request(KVM_REQ_IRQ_PENDING, vcpu); > + kvm_vcpu_kick(vcpu); > + } This code is so obviously broken that I completely overlooked it. If we have take a doorbell interrupt, then it means nothing was otherwise pending (because we'd have been kicked out of the blocking state, and will have masked the doorbell). So checking for pending interrupts is pointless. Furthermore, calling kvm_vgic_vcpu_pending_irq() takes the ap_list lock. If we take a doorbell interrupt while injecting a virtual interrupt (from userspace, for example) on the same CPU, we end-up in deadlock land. This would be solved by Christoffer's latest crop of timer patches, but there is no point getting there the first place. The patchlet below solves it: and I've queued it for the next round. Thanks, M. diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c index 15feb1151797..48e4d6ebeaa8 100644 --- a/virt/kvm/arm/vgic/vgic-v4.c +++ b/virt/kvm/arm/vgic/vgic-v4.c @@ -94,11 +94,9 @@ static irqreturn_t vgic_v4_doorbell_handler(int irq, void *info) { struct kvm_vcpu *vcpu = info; - if (!kvm_vgic_vcpu_pending_irq(vcpu)) { - vcpu->arch.vgic_cpu.vgic_v3.its_vpe.pending_last = true; - kvm_make_request(KVM_REQ_IRQ_PENDING, vcpu); - kvm_vcpu_kick(vcpu); - } + 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; }