From patchwork Fri Feb 9 14:39:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127845 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679905ljc; Fri, 9 Feb 2018 06:42:16 -0800 (PST) X-Google-Smtp-Source: AH8x225+XbEmlo7v1BcOzo9fD2Hgq8E/ZzXKfdUzyGRXsFlmcgLNlBS3iPvuylduemDysElorXjV X-Received: by 10.107.180.70 with SMTP id d67mr3468115iof.73.1518187336680; Fri, 09 Feb 2018 06:42:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187336; cv=none; d=google.com; s=arc-20160816; b=XG+HfA8H58iU6Ix3Yj1I3hDJdr8B8P5iue7cF75LUdD8pswQKw0IIswHZs2d4dp9rA riCrAZZQrnwKN3s4iW6NlHgERmJz4pZC9xrxpmFG0VRqmKMve9UtcR5XlMtUH90mE5cB 0C2VN4Ig1XmjbBtmv5nG0iO0NFWsY1snzsWavdHCQkL04XOwwcrPkSJxe/Gk6rk2P0pk /VSLOcP2HfDB5wF2t8F5V5pJFXzi1/KI0xxrxLQySGLIBGPllgNzZ3l9n5v9XZ6fmiew BVy2+XpZQDzFKXdDmWeIJ/jDWoKRmkxSXi1iBMxg4lk/uOgpbrFvBaLHaswUJNCNrGYb ZkJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=K826P+ibaYSPT9xiH18JQxLGU+c/1G7+d0BHQ8kRCWc=; b=J5qD6Ee9Y6+B0PwR1PeSBZQNkCqWE8fN6+7GkyRjmyZNKMY7o+fO3o9Rj1mNZz0+y6 KgMnj+worG0pq7Et16f1rbVato/LhljyWLZz+PwcpmJ0zjUWS3DZ/M6Kdm9yzc+EcGVm h5cuJCaH9V+tRKnuF7nLvXhS7H8O40HODiA4GAqj+M/dRFYBwYKBFQ/74A63DCYuMy9/ 22TqVdhH9PIJKRLtxKYj/lLFMslQrM9m+CBYfPEW0ugIXZOa1z03lRtTVWKkRGvR0V5E R31TYlDJeCC7Ri+y30F3QZqs5Pf29cZU0hrLH2SwP+qimtHQCbyYOnkIkn8Zgg1mbfic 0tSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QxILZv6K; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 129si1755480itq.113.2018.02.09.06.42.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:42:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QxILZv6K; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ek9qn-0001aS-3G; Fri, 09 Feb 2018 14:40:29 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ek9ql-0001UU-D4 for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:27 +0000 X-Inumbo-ID: 197f6f7b-0da7-11e8-ba59-bc764e045a96 Received: from mail-wr0-x243.google.com (unknown [2a00:1450:400c:c0c::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 197f6f7b-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:58 +0100 (CET) Received: by mail-wr0-x243.google.com with SMTP id s5so8496874wra.0 for ; Fri, 09 Feb 2018 06:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Ym9Wfsw/FNNV0xyLO2ND4vDfE16IBoMMDwb3zPyHtQ0=; b=QxILZv6KBCVJL+7DDuqrks40EG6bCmOzj7L3VBaWRZ2kDn2DDIw9rlskMSMgBWdqvi H8tMU/aI/+4CHLn2sQWa4HDlMBKC3GzNAjpPfYS7wusO9Uosm3TYKqVZ02wCWDzIKkej vbT3puBm5pG0AyoT3X3qL5Hymg4TYJ0e0HCGg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Ym9Wfsw/FNNV0xyLO2ND4vDfE16IBoMMDwb3zPyHtQ0=; b=KtWrz1LNLYTY6zv/kv0xkUEBR5YizRQyc5YsgyoQuRDE3s3igpCuvxo24vzsoEL8ok Ql9hwLNmoPrRF29c7rQVXimSNLI3c9Iiqs30Ii+aL4/KMoM9LDPjV83wJTFgnHGdKQ5L z1PUfqDTdMKBM6U7jrX5wZEYOFZIJA1hoTJ9dJN229KrmamO3erJlZly4hcOzr9b4J+8 i4A+x6r4EbYPjc4woW3qURxXrTRUa/+7QBh4eBVFav4AxgoWXGPklEghK3m193Z2RdV9 E3oMk2F7JTi5g+C1H04Swt2BeBJvdFs57qpGRht/2jt+5cDPBB7UXO6kbFfuJkOMqe1S HVow== X-Gm-Message-State: APf1xPAchGvWbzVmAceCi6LO1XUD4lR7jnZ3r4iUM2/InMs0nUFdgHCl 11AOKGuj6XofrfUXzDaLpyOi5Q== X-Received: by 10.223.196.129 with SMTP id m1mr2544037wrf.256.1518187225136; Fri, 09 Feb 2018 06:40:25 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id b35sm2552229wra.13.2018.02.09.06.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:24 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:26 +0000 Message-Id: <20180209143937.28866-39-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180209143937.28866-1-andre.przywara@linaro.org> References: <20180209143937.28866-1-andre.przywara@linaro.org> Subject: [Xen-devel] [RFC PATCH 38/49] ARM: new VGIC: handle hardware mapped IRQs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The VGIC supports virtual IRQs to be connected to a hardware IRQ, so when a guest EOIs the virtual interrupt, it affects the state of that corresponding interrupt on the hardware side at the same time. Implement the interface that the Xen arch/core code expects to connect the virtual and the physical world. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic/vgic.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index dc5e011fa3..8d5260a7db 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -693,6 +693,69 @@ void vgic_kick_vcpus(struct domain *d) } } +struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v, + unsigned int virq) +{ + struct irq_desc *desc = NULL; + struct vgic_irq *irq = vgic_get_irq(d, v, virq); + unsigned long flags; + + if ( !irq ) + return NULL; + + spin_lock_irqsave(&irq->irq_lock, flags); + if ( irq->hw ) + desc = irq_to_desc(irq->hwintid); + spin_unlock_irqrestore(&irq->irq_lock, flags); + + vgic_put_irq(d, irq); + + return desc; +} + +/* + * was: + * int kvm_vgic_map_phys_irq(struct vcpu *vcpu, u32 virt_irq, u32 phys_irq) + * int kvm_vgic_unmap_phys_irq(struct vcpu *vcpu, unsigned int virt_irq) + */ +int vgic_connect_hw_irq(struct domain *d, struct vcpu *vcpu, + unsigned int virt_irq, struct irq_desc *desc, + bool connect) +{ + struct vgic_irq *irq = vgic_get_irq(d, vcpu, virt_irq); + unsigned long flags; + int ret = 0; + + if ( !irq ) + return -EINVAL; + + spin_lock_irqsave(&irq->irq_lock, flags); + + if ( connect ) /* assign a mapped IRQ */ + { + /* The VIRQ should not be already enabled by the guest */ + if ( !irq->hw && !irq->enabled ) + { + irq->hw = true; + irq->hwintid = desc->irq; + } + else + { + ret = -EBUSY; + } + } + else /* remove a mapped IRQ */ + { + irq->hw = false; + irq->hwintid = 0; + } + + spin_unlock_irqrestore(&irq->irq_lock, flags); + vgic_put_irq(d, irq); + + return ret; +} + /* * Local variables: * mode: C