From patchwork Wed Sep 28 18:24:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9354565 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 E7F8660757 for ; Wed, 28 Sep 2016 18:27:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBB37297A3 for ; Wed, 28 Sep 2016 18:27:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D07FC297A4; Wed, 28 Sep 2016 18:27:14 +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 8455E297A5 for ; Wed, 28 Sep 2016 18:27: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 1bpJXi-0002M2-58; Wed, 28 Sep 2016 18:25:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpJXg-0002FX-9J for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 18:25:16 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 5D/42-11175-A0B0CE75; Wed, 28 Sep 2016 18:25:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTZeL+02 4wYcfTBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bz9c+YCz4LVhy9eJm1gfEHbxcjJ4eQwCZG idv/I7sYuYDs5YwS1xoPMYEk2AR0JXbcfM0MYosIhEo8XfAdzGYWUJLYf/YaYxcjB4ewgKXEt sfFIGEWAVWJhomz2UBsXgEbiYUTroHZEgJyEg3n74O1cgLFV7f0skPstZZYunQ+6wRG7gWMDK sYNYpTi8pSi3QNTfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQK9ywAEOxi/LQs 4xCjJwaQkyttx+3W4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQleUc434UKCRanpqRVpmTnAMINJ S3DwKInwRoCkeYsLEnOLM9MhUqcYFaXEefVBEgIgiYzSPLg2WGhfYpSVEuZlBDpEiKcgtSg3s wRV/hWjOAejkjBvMMgUnsy8Erjpr4AWMwEtXnriBcjikkSElFQDo9Hrw0GPPu25O2/fotgS/9 nKraW/Jyd6HmiXnTG7MJG5IbBN9PbN3N0tD13zD7GZmXY8uNaxcsFa+UsBonuiXvh1mMrNrwl 1Uki3fbz0oOu5Lu0F8y7KdupuzGLj5onauyfVu2eKj+CaDNXK12kzHxiq6vXq2HiE+MVbqxzt +zojNi7Z5E6uEktxRqKhFnNRcSIAVD+vo2gCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1475087113!27549904!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 57190 invoked from network); 28 Sep 2016 18:25:13 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-21.messagelabs.com with SMTP; 28 Sep 2016 18:25:13 -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 2281622E; Wed, 28 Sep 2016 11:25:13 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F4F53F21A; Wed, 28 Sep 2016 11:25:12 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 28 Sep 2016 19:24:49 +0100 Message-Id: <20160928182457.12433-17-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 16/24] ARM: vITS: handle MAPD 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 MAPD command maps a device by associating a memory region for storing ITTEs with a certain device ID. We just store the given guest physical address in the device table. We don't map the device tables permanently, as their alignment requirement is only 256 Bytes, thus making mapping of several tables complicated. We map the device tables on demand when we need them later. Also we propagate the MAPD request to the hardware ITS, as the device ID is only meaningful there. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic-its.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/xen/arch/arm/vgic-its.c b/xen/arch/arm/vgic-its.c index caad320..83d47e1 100644 --- a/xen/arch/arm/vgic-its.c +++ b/xen/arch/arm/vgic-its.c @@ -250,6 +250,34 @@ static int its_handle_mapc(struct virt_its *its, uint64_t *cmdptr) return ret; } +static int its_handle_mapd(struct virt_its *its, uint64_t *cmdptr) +{ + uint32_t devid = its_cmd_get_deviceid(cmdptr); + int size = its_cmd_get_size(cmdptr); + bool valid = its_cmd_get_validbit(cmdptr); + paddr_t itt_addr = its_cmd_mask_field(cmdptr, 2, 0, 52) & GENMASK(51, 8); + + if ( !its->dev_table ) + return -1; + + spin_lock(&its->its_lock); + if ( valid ) + its->dev_table[devid] = DEV_TABLE_ENTRY(itt_addr, size + 1); + else + its->dev_table[devid] = 0; + + spin_unlock(&its->its_lock); + + /* DomUs (will later) have their ITTs allocated at domain creation time, + * when Dom0 configures the passthrough. + */ + if ( its->hw_its ) + return gicv3_its_map_device(its->hw_its, + its->d, devid, size + 1, valid); + + 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, @@ -279,6 +307,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, case GITS_CMD_MAPC: its_handle_mapc(its, cmdptr); break; + case GITS_CMD_MAPD: + its_handle_mapd(its, cmdptr); + break; case GITS_CMD_SYNC: /* We handle ITS commands synchronously, so we ignore SYNC. */ break;