From patchwork Fri Apr 7 22:08:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9670533 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 C7B2660365 for ; Fri, 7 Apr 2017 22:12:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8FB628645 for ; Fri, 7 Apr 2017 22:12:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADDB528669; Fri, 7 Apr 2017 22:12:10 +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 4850A28668 for ; Fri, 7 Apr 2017 22:12:10 +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 1cwc5j-0001Ag-VS; Fri, 07 Apr 2017 22:10:51 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwc5i-00017N-Lk for xen-devel@lists.xenproject.org; Fri, 07 Apr 2017 22:10:50 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 57/8C-00609-A6E08E85; Fri, 07 Apr 2017 22:10:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTTeT70W Ewe3Dshbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aXE0uYCg5LVsyYfI6xgfGkcBcjF4eQwCZG iWPNqxkhnL2MErfPL2LtYuTkYBPQldhx8zUziC0iECox5+cjZpAiZoE1jBLtn56CFQkLmEu8m 7ELzGYRUJXoW9YP1sAr4C5x8uJNti5GDg4JATmJK/8SQMKcQOFDU5axgdhCAm4SN9pXsUxg5F 7AyLCKUb04tagstUjXUi+pKDM9oyQ3MTNH19DAWC83tbg4MT01JzGpWC85P3cTI9C/9QwMjDs YX/90OsQoycGkJMqr4PMkQogvKT+lMiOxOCO+qDQntfgQowwHh5IE73ueFxFCgkWp6akVaZk5 wECDSUtw8CiJ8CaCpHmLCxJzizPTIVKnGBWlxHnPgSQEQBIZpXlwbbDgvsQoKyXMy8jAwCDEU 5BalJtZgir/ilGcg1FJmFeEF2gKT2ZeCdz0V0CLmYAW+9x6CrK4JBEhJdXA2Gx6unuO8MX2Lc 82n0+xvHaK9anlkYsiX1r31OysFzl2reH3kYaCw+VbLnsfdotatCVKZmPwf7ZLDP8jm1du1jw 0eUtgZNCDGGPNn4efbikXcVte3J+24st29wdWsS1LPvez354b/uDH08XpXhdYJm+Nkc5VKFoo 5L/7o8h0h3Y+poQ2ns+bnimxFGckGmoxFxUnAgBFD/mkaQIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1491603048!87230501!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.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1460 invoked from network); 7 Apr 2017 22:10:49 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-31.messagelabs.com with SMTP; 7 Apr 2017 22:10:49 -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 A8161B16; Fri, 7 Apr 2017 15:10:48 -0700 (PDT) Received: from slackpad.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 17B2A3F3E1; Fri, 7 Apr 2017 15:10:46 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Fri, 7 Apr 2017 23:08:23 +0100 Message-Id: <1491602906-10587-32-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1491602906-10587-1-git-send-email-andre.przywara@arm.com> References: <1491602906-10587-1-git-send-email-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni Subject: [Xen-devel] [PATCH v7 31/34] 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 | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index f163c09..7634a63 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -398,6 +398,70 @@ static int update_lpi_property(struct domain *d, uint32_t vlpi, return 0; } +/* + * For a given virtual LPI read the enabled bit and priority 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. + * Also check if this LPI is due to be injected and do it, if needed. + */ +static int update_lpi_enabled_status(struct domain *d, + struct vcpu *vcpu, uint32_t vlpi) +{ + struct pending_irq *p = d->arch.vgic.handler->lpi_to_pending(d, vlpi); + unsigned long flags; + int ret; + + if ( !p ) + return -EINVAL; + + spin_lock_irqsave(&vcpu->arch.vgic.lock, flags); + ret = update_lpi_property(d, vlpi, p); + if ( ret ) { + spin_unlock_irqrestore(&vcpu->arch.vgic.lock, flags); + return ret; + } + + if ( test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) ) + { + if ( !list_empty(&p->inflight) && + !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) ) + gic_raise_guest_irq(vcpu, vlpi, p->lpi_priority); + spin_unlock_irqrestore(&vcpu->arch.vgic.lock, flags); + + vgic_vcpu_inject_irq(vcpu, vlpi); + } + else + { + clear_bit(GIC_IRQ_GUEST_ENABLED, &p->status); + spin_unlock_irqrestore(&vcpu->arch.vgic.lock, flags); + + gic_remove_from_queues(vcpu, vlpi); + } + + return 0; +} + +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; + + /* Translate the event into a vCPU/vLPI pair. */ + if ( !read_itte(its, devid, eventid, &vcpu, &vlpi) ) + return -1; + + /* + * Now read the property table and update our cached status. This + * also takes care if this LPI now needs to be injected or removed. + */ + if ( update_lpi_enabled_status(its->d, vcpu, vlpi) ) + return -1; + + return 0; +} + static int its_handle_mapc(struct virt_its *its, uint64_t *cmdptr) { uint32_t collid = its_cmd_get_collection(cmdptr); @@ -638,6 +702,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its) case GITS_CMD_INT: ret = its_handle_int(its, command); break; + case GITS_CMD_INV: + ret = its_handle_inv(its, command); + break; case GITS_CMD_MAPC: ret = its_handle_mapc(its, command); break;