From patchwork Wed Mar 21 16:32:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 132221 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2356131ljb; Wed, 21 Mar 2018 09:35:04 -0700 (PDT) X-Google-Smtp-Source: AG47ELt6vE1YQHnscSJXnaMMoS148HlJlfJfKW1dwZv7GFcjd3c15PdReGX2SaOZS122w5fDEnSX X-Received: by 10.107.130.203 with SMTP id m72mr22409468ioi.250.1521650103927; Wed, 21 Mar 2018 09:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521650103; cv=none; d=google.com; s=arc-20160816; b=suop5Q1bmnJsFbeNcaVEBbRHWOX4b5MkbVa5Hy5oNyU6V7XrxfnDIgywcMFJjII92r OQjCRrm2hQlvRkPGd+GTMTBIAYrV1ykqh9InjzIg/34BMdUBMPOcjZeqFmWjPaqGBq8R N6VfI4II0w2Ri3CDbpxKXOms4NiS/7OkpocQSS7hESDZ5vMDsYBqf2qEi3FgCjhcD2Sf /lzEfxc97LcmWTnOwCFiZhYT/k9Tgif8b4cHCc8wPoArECysCJIp2+fDHxa2L04tuosb xGaxSiQmnFcrxXma0QC6DAUTIziw/4phlT+gTEF8HhHGqim5QbPW9Unx9sioUnc/CC/N /I9A== 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:cc :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=s/PazONAQuNTOteSv1E6VVxFvHNIWnAzQutc2dzTo10=; b=IoP9DquOdRDR5b8oG7uEJ4TURwXNMrIcTL2LzpVnPNw9Mnz5OgqHGzuQyqVruzqb+m GtyxuPjSulHqgo18jGLQuf45HIbFM0Pd71RgaVufmgyXzXec1ra2zjjatIN4lOeTYiK1 9xxM6eUcJLXQQL1sgUKlN5LaHWvwGDbO5hT2hxQKfb4j5t6AGo/5ui/ixFOIpI0o4ph0 D7qAnpj6S1re8RYfdibn9y6dKTmGxIUUnOEtwj6yf6RqCeoB+zOup9TYuySOr7NdZ9A4 alJxXmh5wYvmBDUPHeNBH/NhDhTL1DRkIzuuMOj2P2iL4ab0sDgnsHAeyHJGzbJ6Ssid 1n5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OuTYLMor; 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 y18si4173801ioe.191.2018.03.21.09.35.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 09:35:03 -0700 (PDT) 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=OuTYLMor; 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.89) (envelope-from ) id 1eygfy-0002og-Gt; Wed, 21 Mar 2018 16:33:22 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1eygfv-0002il-Sc for xen-devel@lists.xenproject.org; Wed, 21 Mar 2018 16:33:19 +0000 X-Inumbo-ID: 8688e655-2d25-11e8-9728-bc764e045a96 Received: from mail-wr0-x241.google.com (unknown [2a00:1450:400c:c0c::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 8688e655-2d25-11e8-9728-bc764e045a96; Wed, 21 Mar 2018 17:33:03 +0100 (CET) Received: by mail-wr0-x241.google.com with SMTP id z73so5841475wrb.0 for ; Wed, 21 Mar 2018 09:33:18 -0700 (PDT) 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=0U6ytb7i6kLHObBHSY219Bl8hs7eXE+hSA43dqdBes0=; b=OuTYLMorcuWmAXPHY0njluGYq/khyZ4/qL4C+HTg83bVhYd6wfDHRYpqaMqnaH5UX7 ULajlpS6IKEnNQoyj7ASNZeAl9xIscahWNQEwfAT5em3LinHkUU6GmrhpSbMYp57gL8l qqdOnCdT807RWVpt4c5LR4LmU8kP//NQ/0+Sc= 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=0U6ytb7i6kLHObBHSY219Bl8hs7eXE+hSA43dqdBes0=; b=pLwP2NZYrhGJh8Z6UkX2/hKHqAMICR+g7qDEeEW73RxeVPBo6QLiVYBtQB12pBd4N+ LeDJJgs00l527DkV4XQ2cE+UHs1pF1Nq7B368csNCmx2QaguA2QgzioHuHxtEA4Psder DXScZIpnfu0hQYyZMkHQzKYkmduP/vGcQtItICoqiPOr8QRSzM5byWeC568SRPPLTqZH ZkyE/tfXUv609cQL8OGM60odZz6JFsxtM9KTmnhznVqWnfe2wTuzpIP0K+FlWW1eZUyh YEJguy78Nzs/cd1O/qY/wcuMVIqKmVGU4ykWx3tDB+fuVlmggv855L1Pd7eApW+CR3o+ fMmA== X-Gm-Message-State: AElRT7E2nWy4xYWGwekupwKrwkJ+8Sd2+x7/1n9XpRCpeqBPvHrxXM0N FX2nDZZKyMZ+xDsX+Tzj0g2UZQ== X-Received: by 10.223.225.2 with SMTP id d2mr8562333wri.56.1521649997149; Wed, 21 Mar 2018 09:33:17 -0700 (PDT) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id n64sm4423724wmd.11.2018.03.21.09.33.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 09:33:16 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 21 Mar 2018 16:32:23 +0000 Message-Id: <20180321163235.12529-28-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180321163235.12529-1-andre.przywara@linaro.org> References: <20180321163235.12529-1-andre.przywara@linaro.org> Subject: [Xen-devel] [PATCH v3 27/39] ARM: new VGIC: Handle hardware mapped IRQs 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: xen-devel@lists.xenproject.org, Andre Przywara 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 Reviewed-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/vgic/vgic.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index 90041eb071..07866d7243 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -699,6 +699,77 @@ 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 ) + { + ASSERT(irq->hwintid >= VGIC_NR_PRIVATE_IRQS); + 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 */ + { + if ( desc && irq->hwintid != desc->irq ) + { + ret = -EINVAL; + } + else + { + irq->hw = false; + irq->hwintid = 0; + } + } + + spin_unlock_irqrestore(&irq->irq_lock, flags); + vgic_put_irq(d, irq); + + return ret; +} + static unsigned int translate_irq_type(bool is_level) { return is_level ? IRQ_TYPE_LEVEL_HIGH : IRQ_TYPE_EDGE_RISING;