From patchwork Fri Mar 31 18:05:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9657111 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 F3D1B60350 for ; Fri, 31 Mar 2017 18:06:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8A94286EF for ; Fri, 31 Mar 2017 18:06:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD858286F3; Fri, 31 Mar 2017 18:06:13 +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 90514286EF for ; Fri, 31 Mar 2017 18:06:13 +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 1cu0tq-0005eM-W6; Fri, 31 Mar 2017 18:03:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cu0tp-0005a6-F8 for xen-devel@lists.xenproject.org; Fri, 31 Mar 2017 18:03:49 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 99/D8-13192-40A9ED85; Fri, 31 Mar 2017 18:03:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTZdl1r0 Ig7P7RSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyJD08wFnwVqli+cQprA2MzfxcjJ4eQwCZG ibdf67oYuYDs5YwS/9YcZQZJsAnoSuy4+RrMFhEIlXi64DuQzcHBLFAp0b0IrFdYwFJi2dn9L CA2i4CqxMRtz5lAbF4BG4lpKx+zgtgSAnISDefvg43hBIrP3/WDFWKvtUTDp7vMExi5FzAyrG LUKE4tKkst0jUy00sqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECPQuAxDsYDyzIPA QoyQHk5Io7/fiexFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHg9ZgDlBItS01Mr0jJzgGEGk5bg 4FES4X0AkuYtLkjMLc5Mh0idYlSUEucNAkkIgCQySvPg2mChfYlRVkqYlxHoECGegtSi3MwSV PlXjOIcjErCvKtBpvBk5pXATX8FtJgJaLHF17sgi0sSEVJSDYw7UttkxCv1+/y6wxPtXCUlas /+UfxQzhW+MGaGxpym+bHPHPfdkpoqc68sWzry1v1Ff+zcZr6+0HF6J2dmcdT9/cfWOf67U/Y 2jzlzjYx4ebQzV2uz+i6ByL9Z78S2L6l72Cdf/FJwSrZRToD/4RNzDhjdXP403vQdn7x2nHx/ 4z9pb6OtL5VYijMSDbWYi4oTAYJ2sVtoAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1490983427!55324928!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 14768 invoked from network); 31 Mar 2017 18:03:48 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-21.messagelabs.com with SMTP; 31 Mar 2017 18:03:48 -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 9D59880D; Fri, 31 Mar 2017 11:03:47 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BAB953F59A; Fri, 31 Mar 2017 11:03:46 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Fri, 31 Mar 2017 19:05:14 +0100 Message-Id: <20170331180525.30038-16-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170331180525.30038-1-andre.przywara@arm.com> References: <20170331180525.30038-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Shanker Donthineni , Vijay Kilari Subject: [Xen-devel] [PATCH v3 15/26] ARM: vITS: handle CLEAR 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 This introduces the ITS command handler for the CLEAR command, which clears the pending state of an LPI. This removes a not-yet injected, but already queued IRQ from a VCPU. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic-v3-its.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index d75f404..e49df30 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -181,8 +181,8 @@ static void put_itte(struct virt_its *its, struct vits_itte *itte) * protect the ITTs with their less-than-page-size granularity. * Takes and drops the its_lock. */ -bool read_itte(struct virt_its *its, uint32_t devid, uint32_t evid, - struct vcpu **vcpu, uint32_t *vlpi) +static bool read_itte(struct virt_its *its, uint32_t devid, uint32_t evid, + struct vcpu **vcpu, uint32_t *vlpi) { struct vits_itte *itte; int collid; @@ -267,6 +267,30 @@ static uint64_t its_cmd_mask_field(uint64_t *its_cmd, unsigned int word, #define its_cmd_get_target_addr(cmd) its_cmd_mask_field(cmd, 2, 16, 32) #define its_cmd_get_validbit(cmd) its_cmd_mask_field(cmd, 2, 63, 1) +static int its_handle_clear(struct virt_its *its, uint64_t *cmdptr) +{ + uint32_t devid = its_cmd_get_deviceid(cmdptr); + uint32_t eventid = its_cmd_get_id(cmdptr); + struct pending_irq *p; + struct vcpu *vcpu; + uint32_t vlpi; + + if ( !read_itte(its, devid, eventid, &vcpu, &vlpi) ) + return -1; + + p = lpi_to_pending(its->d, vlpi); + if ( !p ) + return -1; + + clear_bit(GIC_IRQ_GUEST_LPI_PENDING, &p->status); + + /* Remove a pending, but not yet injected guest IRQ. */ + clear_bit(GIC_IRQ_GUEST_QUEUED, &p->status); + gic_remove_from_queues(vcpu, vlpi); + + return 0; +} + #define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12) static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, @@ -304,6 +328,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, switch ( its_cmd_get_command(cmdptr) ) { + case GITS_CMD_CLEAR: + ret = its_handle_clear(its, cmdptr); + break; case GITS_CMD_SYNC: /* We handle ITS commands synchronously, so we ignore SYNC. */ break;