From patchwork Mon Jan 30 18:31:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9545875 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 07C51604DE for ; Mon, 30 Jan 2017 18:32:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F31DA27F7F for ; Mon, 30 Jan 2017 18:32:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E804A27F82; Mon, 30 Jan 2017 18:32:58 +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 9618D2818B for ; Mon, 30 Jan 2017 18:32:58 +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 1cYGjL-0008O4-VM; Mon, 30 Jan 2017 18:31:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYGjK-0008I5-DR for xen-devel@lists.xenproject.org; Mon, 30 Jan 2017 18:31:06 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id EF/C5-29440-9668F885; Mon, 30 Jan 2017 18:31:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTTezrT/ CYO5abovvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP0n/9sBS/FK/raRBsYW4S6GLk4hAQ2M0rc WLedFcJZzijxtwHE4eRgE9CV2HHzNTOILSIQKjHn5yMgm4ODWcBL4st7b5CwsICJxNWdM5lAb BYBVYmj586wg9i8AjYSP35eBbMlBOQkGs7fBxvDCRSfvfk3WL2QgLXEv57ljBMYuRcwMqxiVC 9OLSpLLdI11EsqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECPQtAxDsYNz53OkQoyQ Hk5Iob9/HvgghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxdrf0RQoJFqempFWmZOcAgg0lLcPAo ifB+bgFK8xYXJOYWZ6ZDpE4xKkqJ8+aB9AmAJDJK8+DaYIF9iVFWSpiXEegQIZ6C1KLczBJU+ VeM4hyMSsK8N0HG82TmlcBNfwW0mAlosfurPpDFJYkIKakGRhX5cr3fRgbbvn7eNmV68//qxd M5OR3cK/a5a1dpKi1RrxSdeby5+Etcyttqpu8xO/RtDzAmy0zTNCm+0iltz1Mgqs+nWC7Jb3N /848992pXlDVKyqm8ZjyqL3514vaIHff+z6n/stF2c2hT3sZ5ESs2Rn1tjVMLdPz95vSTw43G JX1HBV8dUGIpzkg01GIuKk4EADEUUtxnAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1485801064!84643231!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.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26765 invoked from network); 30 Jan 2017 18:31:04 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-27.messagelabs.com with SMTP; 30 Jan 2017 18:31:04 -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 76C4C1595; Mon, 30 Jan 2017 10:31:04 -0800 (PST) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 96FD83F24D; Mon, 30 Jan 2017 10:31:03 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Mon, 30 Jan 2017 18:31:49 +0000 Message-Id: <20170130183153.28566-25-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170130183153.28566-1-andre.przywara@arm.com> References: <20170130183153.28566-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijay Kilari Subject: [Xen-devel] [PATCH 24/28] 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 8747890..82f7bcc 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -262,6 +262,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); @@ -405,6 +459,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;