From patchwork Fri Nov 15 20:10:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 11247085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED1376C1 for ; Fri, 15 Nov 2019 20:12:11 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3EAA206D9 for ; Fri, 15 Nov 2019 20:12:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3EAA206D9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dornerworks.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iVhvr-0006xA-AX; Fri, 15 Nov 2019 20:11:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iVhvq-0006wp-0L for xen-devel@lists.xenproject.org; Fri, 15 Nov 2019 20:11:02 +0000 X-Inumbo-ID: 0417c844-07e4-11ea-b678-bc764e2007e4 Received: from webmail.dornerworks.com (unknown [12.207.209.150]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 0417c844-07e4-11ea-b678-bc764e2007e4; Fri, 15 Nov 2019 20:10:49 +0000 (UTC) From: Stewart Hildebrand To: Date: Fri, 15 Nov 2019 15:10:34 -0500 Message-ID: <20191115201037.44982-4-stewart.hildebrand@dornerworks.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191115200115.44890-1-stewart.hildebrand@dornerworks.com> References: <20191115200115.44890-1-stewart.hildebrand@dornerworks.com> MIME-Version: 1.0 X-Originating-IP: [172.27.14.58] X-ClientProxiedBy: Mcbain.dw.local (172.27.1.45) To Mcbain.dw.local (172.27.1.45) X-spam-status: No, score=-2.9 required=3.5 tests=ALL_TRUSTED, BAYES_00, MAILSHELL_SCORE_0_4 X-Spam-Flag: NO Subject: [Xen-devel] [RFC XEN PATCH v3 08/11] xen: arm: vgic: don't fail if IRQ is already connected X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Volodymyr Babchuk , Stefano Stabellini , Julien Grall Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" There are some IRQs that happen to have multiple "interrupts = < ... >;" properties with the same IRQ in the device tree. For example: interrupts = <0 123 4>, <0 123 4>, <0 123 4>, <0 123 4>, <0 123 4>; In this case it seems that we are invoking vgic_connect_hw_irq multiple times for the same IRQ. Rework the checks to allow booting in this scenario. I have not seen any cases where the pre-existing p->desc is any different from the new desc, so BUG() out if they're different for now. Signed-off-by: Stewart Hildebrand --- v3: new patch I tested on Xilinx Zynq UltraScale+ with the old vGIC. I have not fully tested with CONFIG_NEW_VGIC. This hack only became necessary after introducing the PPI series, and I'm not entirely sure what the reason is for that. I'm also unsure if BUG()ing out is the right thing to do in case of desc != p->desc, or what conditions would even trigger this? Is this function exposed to guests? --- xen/arch/arm/gic-vgic.c | 9 +++++++-- xen/arch/arm/vgic/vgic.c | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index 2c66a8fa92..5c16e66b32 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -460,9 +460,14 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq, if ( connect ) { /* The VIRQ should not be already enabled by the guest */ - if ( !p->desc && - !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) ) + if ( !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) ) + { + if (p->desc && p->desc != desc) + { + BUG(); + } p->desc = desc; + } else ret = -EBUSY; } diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index f0f2ea5021..aa775f7668 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -882,6 +882,10 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *vcpu, irq->hw = true; irq->hwintid = desc->irq; } + else if ( irq->hw && !irq->enabled && irq->hwintid == desc->irq ) + { + /* The IRQ was already connected. No action is necessary. */ + } else ret = -EBUSY; }