From patchwork Wed Sep 28 18:24:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9354577 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 B43EB60757 for ; Wed, 28 Sep 2016 18:27:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8213297A3 for ; Wed, 28 Sep 2016 18:27:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C7A5297A5; Wed, 28 Sep 2016 18:27:25 +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 11D88297A3 for ; Wed, 28 Sep 2016 18:27:25 +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 1bpJXl-0002TY-3S; Wed, 28 Sep 2016 18:25:21 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpJXj-0002OV-Do for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 18:25:19 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 64/6E-12967-E0B0CE75; Wed, 28 Sep 2016 18:25:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTZeb+02 4wfx33Bbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aVpX+YC04IV+y8f5ilgfEOXxcjF4eQwEZG iQsLrrFCOMsZJaacA3E4OdgEdCV23HzNDGKLCIRKPF3wHcxmFlCS2H/2GiOILSxgJXHpSTcbi M0ioCrx4PNXJhCbV8BGYvXalWD1EgJyEg3n74PZnCDxll52EFtIwFpi6dL5rBMYuRcwMqxi1C hOLSpLLdI1MtNLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAj0cD0DA+MOxoa9foc YJTmYlER5O26/DhfiS8pPqcxILM6ILyrNSS0+xCjDwaEkwdvK+SZcSLAoNT21Ii0zBxhqMGkJ Dh4lEV5BLqA0b3FBYm5xZjpE6hSjopQ4LytIQgAkkVGaB9cGC+9LjLJSwryMDAwMQjwFqUW5m SWo8q8YxTkYlYR5hUCm8GTmlcBNfwW0mAlo8dITL0AWlyQipKQaGNMr/33QvMlpmyHeYGCvHZ TozKx1lf3qB0bzgGaLO0UP5rz8/T3swOa+O6KpjUrVMmoXbaMX6B4MPX9s4+UNLmUFm1c0VtQ 7XSzMZC3a8jWe7+Cc/8ynJJ792X/x2Kab0/vjy5aUZ7zfdTOdwzOZ+blUqt4/3T1RCazZTwRP lzPXT1FQfWX4QomlOCPRUIu5qDgRAC+OrPxqAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1475087114!55742381!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50004 invoked from network); 28 Sep 2016 18:25:15 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-31.messagelabs.com with SMTP; 28 Sep 2016 18:25:15 -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 664FE15; Wed, 28 Sep 2016 11:25:14 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8CD793F21A; Wed, 28 Sep 2016 11:25:13 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 28 Sep 2016 19:24:50 +0100 Message-Id: <20160928182457.12433-18-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160928182457.12433-1-andre.przywara@arm.com> References: <20160928182457.12433-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [RFC PATCH 17/24] ARM: vITS: handle MAPTI 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 MAPTI commands associates a DeviceID/EventID pair with a LPI/CPU pair and actually instantiates LPI interrupts. We allocate a new host LPI and connect that one to this virtual LPI, so that any triggering IRQ on the host can be quickly forwarded to a guest. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic-its.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/xen/arch/arm/vgic-its.c b/xen/arch/arm/vgic-its.c index 83d47e1..70897dd 100644 --- a/xen/arch/arm/vgic-its.c +++ b/xen/arch/arm/vgic-its.c @@ -278,6 +278,55 @@ static int its_handle_mapd(struct virt_its *its, uint64_t *cmdptr) return 0; } +static int its_handle_mapti(struct virt_its *its, uint64_t *cmdptr) +{ + uint32_t devid = its_cmd_get_deviceid(cmdptr); + uint32_t eventid = its_cmd_get_id(cmdptr); + uint32_t intid = its_cmd_get_physical_id(cmdptr); + int collid = its_cmd_get_collection(cmdptr); + struct vits_itte *itte; + uint32_t host_lpi; + struct vcpu *vcpu; + int ret = -1; + + if ( its_cmd_get_command(cmdptr) == GITS_CMD_MAPI ) + intid = eventid; + + if ( collid >= its->max_collections ) + return -1; + + spin_lock(&its->its_lock); + vcpu = get_vcpu_from_collection(its, collid); + if ( !vcpu ) + goto out_unlock; + + itte = get_devid_evid(its, devid, eventid); + if ( !itte ) + goto out_unlock; + + if ( itte->hlpi ) + goto out_unmap; + + host_lpi = gicv3_lpi_allocate_host_lpi(its->hw_its, + devid, eventid, + vcpu, intid); + if ( host_lpi >= 0 ) + itte->hlpi = host_lpi; + + itte->vlpi = intid; + itte->collection = collid; + + ret = 0; + +out_unmap: + put_devid_evid(its, itte); + +out_unlock: + spin_unlock(&its->its_lock); + + return ret; +} + #define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12) static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, @@ -310,6 +359,10 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, case GITS_CMD_MAPD: its_handle_mapd(its, cmdptr); break; + case GITS_CMD_MAPI: + case GITS_CMD_MAPTI: + its_handle_mapti(its, cmdptr); + break; case GITS_CMD_SYNC: /* We handle ITS commands synchronously, so we ignore SYNC. */ break;