From patchwork Fri Jun 9 17:41:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9778979 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 3BF7260318 for ; Fri, 9 Jun 2017 17:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 284FE286E0 for ; Fri, 9 Jun 2017 17:43:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19910286F6; Fri, 9 Jun 2017 17:43:50 +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 7403B286E0 for ; Fri, 9 Jun 2017 17:43:49 +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 1dJNvV-0004Og-N6; Fri, 09 Jun 2017 17:42:25 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJNvU-0004Io-L3 for xen-devel@lists.xenproject.org; Fri, 09 Jun 2017 17:42:24 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id B7/CF-03620-00EDA395; Fri, 09 Jun 2017 17:42:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTff/Xat Ig6sdmhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aUmT3MBW3SFZN2/mBsYNwu0sXIxSEksJlR Yv3FXiYIZzmjxI4NP5i7GDk52AR0JXbcfA1miwiESjxd8J0ZpIhZ4DqjxOkd89lAEsIClhKn1 +1hB7FZBFQllv3/BmbzClhLnF02kQnElhCQk2g4fx9sECdQfNuetWC9QgJWEi2HLrNPYORewM iwilGjOLWoLLVI19BAL6koMz2jJDcxMwfIM9PLTS0uTkxPzUlMKtZLzs/dxAj0MQMQ7GC8tyz gEKMkB5OSKO+0AqtIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8r+4A5QSLUtNTK9Iyc4DBBpOW 4OBREuF9cRIozVtckJhbnJkOkTrFqCglzrsRpE8AJJFRmgfXBgvwS4yyUsK8jECHCPEUpBblZ pagyr9iFOdgVBLm3QUyhSczrwRu+iugxUxAi5e8swBZXJKIkJJqYOQQ18z/ofgg647fg5ADZd fPPZD/3+p/3cXi4KnNvjsXNJY2TWZ3FGw/4sVRc5bDsp7jv4eRvUPp4d5e/cN9vOq2zAW8TDf 2uenYtma8iFgQpXPbWfGhrbsgx6/dLEpLzVe89bZnsHpmuV1u3rRWqaDH322bVv5wsz60fdv7 RTuDxHsaPVnSlFiKMxINtZiLihMBz8fSJmsCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1497030143!102356302!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3505 invoked from network); 9 Jun 2017 17:42:23 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-27.messagelabs.com with SMTP; 9 Jun 2017 17:42:23 -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 C3A871596; Fri, 9 Jun 2017 10:42:22 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 78BE83F578; Fri, 9 Jun 2017 10:42:21 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Fri, 9 Jun 2017 18:41:35 +0100 Message-Id: <20170609174141.5068-29-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170609174141.5068-1-andre.przywara@arm.com> References: <20170609174141.5068-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni , Manish Jaggi Subject: [Xen-devel] [PATCH v11 28/34] ARM: vITS: handle MOVI 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 MOVI command moves the interrupt affinity from one redistributor (read: VCPU) to another. For now migration of "live" LPIs is not yet implemented, but we store the changed affinity in our virtual ITTE and the pending_irq. Signed-off-by: Andre Przywara Acked-by: Julien Grall --- xen/arch/arm/vgic-v3-its.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index ada3040..49969e4 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -652,6 +652,69 @@ out_remove_mapping: return ret; } +static int its_handle_movi(struct virt_its *its, uint64_t *cmdptr) +{ + uint32_t devid = its_cmd_get_deviceid(cmdptr); + uint32_t eventid = its_cmd_get_id(cmdptr); + uint16_t collid = its_cmd_get_collection(cmdptr); + unsigned long flags; + struct pending_irq *p; + struct vcpu *ovcpu, *nvcpu; + uint32_t vlpi; + int ret = -1; + + spin_lock(&its->its_lock); + /* Check for a mapped LPI and get the LPI number. */ + if ( !read_itte(its, devid, eventid, &ovcpu, &vlpi) ) + goto out_unlock; + + if ( vlpi == INVALID_LPI ) + goto out_unlock; + + /* Check the new collection ID and get the new VCPU pointer */ + nvcpu = get_vcpu_from_collection(its, collid); + if ( !nvcpu ) + goto out_unlock; + + p = gicv3_its_get_event_pending_irq(its->d, its->doorbell_address, + devid, eventid); + if ( unlikely(!p) ) + goto out_unlock; + + /* + * TODO: This relies on the VCPU being correct in the ITS tables. + * This can be fixed by either using a per-IRQ lock or by using + * the VCPU ID from the pending_irq instead. + */ + spin_lock_irqsave(&ovcpu->arch.vgic.lock, flags); + + /* Update our cached vcpu_id in the pending_irq. */ + p->lpi_vcpu_id = nvcpu->vcpu_id; + + spin_unlock_irqrestore(&ovcpu->arch.vgic.lock, flags); + + /* + * TODO: Investigate if and how to migrate an already pending LPI. This + * is not really critical, as these benign races happen in hardware too + * (an affinity change may come too late for a just fired IRQ), but may + * simplify the code if we can keep the IRQ's associated VCPU in sync, + * so that we don't have to deal with special cases anymore. + * Migrating those LPIs is not easy to do at the moment anyway, but should + * become easier with the introduction of a per-IRQ lock. + */ + + /* Now store the new collection in the translation table. */ + if ( !write_itte(its, devid, eventid, collid, vlpi) ) + goto out_unlock; + + ret = 0; + +out_unlock: + spin_unlock(&its->its_lock); + + return ret; +} + #define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12) #define ITS_CMD_OFFSET(reg) ((reg) & GENMASK(19, 5)) @@ -704,6 +767,12 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its) case GITS_CMD_MAPTI: ret = its_handle_mapti(its, command); break; + case GITS_CMD_MOVALL: + gdprintk(XENLOG_G_INFO, "vGITS: ignoring MOVALL command\n"); + break; + case GITS_CMD_MOVI: + ret = its_handle_movi(its, command); + break; case GITS_CMD_SYNC: /* We handle ITS commands synchronously, so we ignore SYNC. */ break;