From patchwork Thu Mar 16 11:20:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9627941 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 4D40460522 for ; Thu, 16 Mar 2017 11:20:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41631285B5 for ; Thu, 16 Mar 2017 11:20:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3620728604; Thu, 16 Mar 2017 11:20:48 +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 CFB11285B8 for ; Thu, 16 Mar 2017 11:20:47 +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 1coTR3-00081y-4l; Thu, 16 Mar 2017 11:19:13 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coTR1-0007xd-FN for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 11:19:11 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id A8/F0-00609-EA47AC85; Thu, 16 Mar 2017 11:19:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXddyak IgyXHhC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oz7netYCu6IVJybuYi1gXGVQBcjF4eQwGZG iZn3pzNCOMsZJX6cmQHkcHKwCehK7Lj5mhnEFhEIlZjz8xGYzSxQKXHxw362LkYODmEBS4n2K bYgYRYBVYlJ80+zgNi8AjYSx2+0g5VLCMhJNJy/D2ZzAsU7Tu5hA7GFBKwlPh/9zD6BkXsBI8 MqRo3i1KKy1CJdQ1O9pKLM9IyS3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYxA/zIAwQ7GNds 9DzFKcjApifKqCJ6IEOJLyk+pzEgszogvKs1JLT7EKMPBoSTBO6sWKCdYlJqeWpGWmQMMNJi0 BAePkgivFkiat7ggMbc4Mx0idYpRUUqcdyFIQgAkkVGaB9cGC+5LjLJSwryMQIcI8RSkFuVml qDKv2IU52BUEuZNAZnCk5lXAjf9FdBiJqDFiT+PgCwuSURISTUwli1oePuzxlk4sI3vmKVi4t 3G28ox/YzHNHzead0+E9Dg8ux7/yG+CD3R//elLXy8lpxLitHZYT3zkKjG5Fu+z6QN9GYqez/ 7J8r9pPdPfMD+yWyrdDatm30n6HB0XMDqhUILmPiM8ybrnuB5eWi9ro742h1uG5ZtVzXZ7+cX pT5bMnN58//pSizFGYmGWsxFxYkAX4BlIWkCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1489663149!89867011!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 20072 invoked from network); 16 Mar 2017 11:19:10 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-31.messagelabs.com with SMTP; 16 Mar 2017 11:19:10 -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 87D81150C; Thu, 16 Mar 2017 04:19:09 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 83A983F5C9; Thu, 16 Mar 2017 04:19:08 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 16 Mar 2017 11:20:19 +0000 Message-Id: <20170316112030.20419-17-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 16/27] 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 | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index 267a573..e808f43 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -131,8 +131,8 @@ static void put_devid_evid(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; @@ -216,6 +216,34 @@ static uint64_t its_cmd_mask_field(uint64_t *its_cmd, #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 *pirq; + struct vcpu *vcpu; + uint32_t vlpi; + + if ( !read_itte(its, devid, eventid, &vcpu, &vlpi) ) + return -1; + + /* Remove a pending, but not yet injected guest IRQ. */ + pirq = lpi_to_pending(vcpu, vlpi, false); + if ( pirq ) + { + clear_bit(GIC_IRQ_GUEST_QUEUED, &pirq->status); + gic_remove_from_queues(vcpu, vlpi); + + /* Mark this pending IRQ struct as availabe again. */ + if ( !test_bit(GIC_IRQ_GUEST_VISIBLE, &pirq->status) ) + pirq->irq = 0; + } + + clear_bit(vlpi - LPI_OFFSET, vcpu->arch.vgic.pendtable); + + 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, @@ -236,6 +264,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, cmdptr = its->cmdbuf + (its->creadr / sizeof(*its->cmdbuf)); switch (its_cmd_get_command(cmdptr)) { + case GITS_CMD_CLEAR: + its_handle_clear(its, cmdptr); + break; case GITS_CMD_SYNC: /* We handle ITS commands synchronously, so we ignore SYNC. */ break;