From patchwork Thu Mar 16 11:20:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9627955 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 B08826048C for ; Thu, 16 Mar 2017 11:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4C1B285B5 for ; Thu, 16 Mar 2017 11:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 999E028628; Thu, 16 Mar 2017 11:20:57 +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, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 43C4C285B5 for ; Thu, 16 Mar 2017 11:20:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coTRC-0008Lf-0P; Thu, 16 Mar 2017 11:19:22 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coTRA-0008HB-9z for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 11:19:20 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id EC/41-22382-7B47AC85; Thu, 16 Mar 2017 11:19:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTXd7yak Ig7uTOCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyPreeZCl6KV0x4OJmlgbFFqIuRi0NIYDOj xItNbawQznJGiX1t15i6GDk52AR0JXbcfM0MYosIhErM+fkIzGYWqJS4+GE/WxcjB4ewgLnEv s+KIGEWAVWJ9tYf7CA2r4CNxMm+M6wgtoSAnETD+ftgrZxA8Y6Te9hAbCEBa4nPRz+zT2DkXs DIsIpRvTi1qCy1SNdML6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0LsMQLCDcd4 J/0OMkhxMSqK8WuanIoT4kvJTKjMSizPii0pzUosPMcpwcChJ8FYXA+UEi1LTUyvSMnOAYQaT luDgURLhLQBJ8xYXJOYWZ6ZDpE4xKkqJ864FSQiAJDJK8+DaYKF9iVFWSpiXEegQIZ6C1KLcz BJU+VeM4hyMSsK81iBTeDLzSuCmvwJazAS0+O2HEyCLSxIRUlINjN6VGy5VR37OSSs5YrG2/P viNqagWUdvfLe/9CPhhYj7Nqm5r3S3XIl4vbz+s+Bet5NfjXn9Xn1/0yGWbVCbvT9uj8+KtBl R3jpTKu9m2WSJacYUXWiaeO6BhasAX1JA+ptH2vedmbvbA3q31NfLJe2+Y2B29Py6/9LuDC9f vbI2u7bFh7HkrxJLcUaioRZzUXEiALzOJl9oAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1489663158!87485837!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63584 invoked from network); 16 Mar 2017 11:19:18 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-27.messagelabs.com with SMTP; 16 Mar 2017 11:19:18 -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 6CAF6152D; Thu, 16 Mar 2017 04:19:18 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5FF7C3F5C9; Thu, 16 Mar 2017 04:19:17 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 16 Mar 2017 11:20:26 +0000 Message-Id: <20170316112030.20419-24-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170316112030.20419-1-andre.przywara@arm.com> References: <20170316112030.20419-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Shanker Donthineni , Vijay Kilari Subject: [Xen-devel] [PATCH v2 23/27] ARM: vITS: handle INV command X-BeenThere: xen-devel@lists.xen.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.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The INV command instructs the ITS to update the configuration data for a given LPI by re-reading its entry from the property table. We don't need to care so much about the priority value, but enabling or disabling an LPI has some effect: We remove or push virtual LPIs to their VCPUs, also check the virtual pending bit if an LPI gets enabled. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic-v3-its.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index 21a663e..8af06ac 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -265,6 +265,60 @@ static int its_handle_int(struct virt_its *its, uint64_t *cmdptr) return 0; } +/* + * For a given virtual LPI read the enabled bit from the virtual property + * table and update the virtual IRQ's state. + * This takes care of removing or pushing of virtual LPIs to their VCPUs. + */ +static void update_lpi_enabled_status(struct virt_its* its, + struct vcpu *vcpu, uint32_t vlpi) +{ + struct pending_irq *pirq = lpi_to_pending(vcpu, vlpi, false); + uint8_t property = its->d->arch.vgic.proptable[vlpi - LPI_OFFSET]; + + if ( property & LPI_PROP_ENABLED ) + { + if ( pirq ) + { + unsigned long flags; + + set_bit(GIC_IRQ_GUEST_ENABLED, &pirq->status); + spin_lock_irqsave(&vcpu->arch.vgic.lock, flags); + if ( !list_empty(&pirq->inflight) && + !test_bit(GIC_IRQ_GUEST_VISIBLE, &pirq->status) ) + gic_raise_guest_irq(vcpu, vlpi, property & LPI_PROP_PRIO_MASK); + spin_unlock_irqrestore(&vcpu->arch.vgic.lock, flags); + } + + /* Check whether the LPI has fired while the guest had it disabled. */ + if ( test_and_clear_bit(vlpi - LPI_OFFSET, vcpu->arch.vgic.pendtable) ) + vgic_vcpu_inject_irq(vcpu, vlpi); + } + else + { + if ( pirq ) + { + clear_bit(GIC_IRQ_GUEST_ENABLED, &pirq->status); + gic_remove_from_queues(vcpu, vlpi); + } + } +} + +static int its_handle_inv(struct virt_its *its, uint64_t *cmdptr) +{ + uint32_t devid = its_cmd_get_deviceid(cmdptr); + uint32_t eventid = its_cmd_get_id(cmdptr); + struct vcpu *vcpu; + uint32_t vlpi; + + if ( !read_itte(its, devid, eventid, &vcpu, &vlpi) ) + return -1; + + update_lpi_enabled_status(its, vcpu, vlpi); + + return 0; +} + static int its_handle_mapc(struct virt_its *its, uint64_t *cmdptr) { uint32_t collid = its_cmd_get_collection(cmdptr); @@ -428,6 +482,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, case GITS_CMD_INT: its_handle_int(its, cmdptr); break; + case GITS_CMD_INV: + its_handle_inv(its, cmdptr); + break; case GITS_CMD_MAPC: its_handle_mapc(its, cmdptr); break;