From patchwork Thu May 11 17:53:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9722627 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 7CEED6031B for ; Thu, 11 May 2017 17:53:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A779286D0 for ; Thu, 11 May 2017 17:53:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F319286E5; Thu, 11 May 2017 17:53:21 +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 F019B286D0 for ; Thu, 11 May 2017 17:53:20 +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 1d8sFk-0000iK-50; Thu, 11 May 2017 17:51:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8sFi-0000ez-GA for xen-devel@lists.xenproject.org; Thu, 11 May 2017 17:51:50 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 59/E0-01870-5B4A4195; Thu, 11 May 2017 17:51:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTXfrEpF Ig55/PBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bHJ+dZClaKVuxZn9rA2CrQxcjFISSwmVHi xJ+d7BDOckaJfYsamLoYOTnYBHQldtx8zQxiiwiESjxd8J0ZpIhZYA2jxLlFP9lAEsICFhIfF 79lBbFZBFQlfvybAWbzClhLPG18zQJiSwjISTScvw82iBMovmT6LLC4kICVxK7dp1knMHIvYG RYxahRnFpUllqka2ygl1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kR6OF6BgbGHYy dJ/wOMUpyMCmJ8jJOFIkU4kvKT6nMSCzOiC8qzUktPsQow8GhJMEbuRgoJ1iUmp5akZaZAww1 mLQEB4+SCO/mRUBp3uKCxNzizHSI1ClGRSlxXh6QPgGQREZpHlwbLLwvMcpKCfMyMjAwCPEUp BblZpagyr9iFOdgVBLm3QkyhSczrwRu+iugxUxAi/v/CIMsLklESEk1MCpcYqnXiUxR37r2f8 cp21a3rQsNF2fPtYgIuvXj85Z1R3YL5FXpp8s8YdT7+bAwXOVFVolOV12A85mgAPmMcjXervl 5qpeFtKJu5yXvqpkZvXf2qehy3uuSC3qfzwrxW8CxwkZRa/bDb2s9Hrjv2rP3olH83FWNem9f 9PieXKy8kf9toELkJCWW4oxEQy3mouJEACr0OYxqAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-5.tower-31.messagelabs.com!1494525108!96792834!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8256 invoked from network); 11 May 2017 17:51:49 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-31.messagelabs.com with SMTP; 11 May 2017 17:51:49 -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 6B1371A3B; Thu, 11 May 2017 10:51:48 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 446013F4FF; Thu, 11 May 2017 10:51:47 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Thu, 11 May 2017 18:53:29 +0100 Message-Id: <20170511175340.8448-18-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170511175340.8448-1-andre.przywara@arm.com> References: <20170511175340.8448-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni Subject: [Xen-devel] [PATCH v9 17/28] ARM: vITS: handle MAPC 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 MAPC command associates a given collection ID with a given redistributor, thus mapping collections to VCPUs. We just store the vcpu_id in the collection table for that. Signed-off-by: Andre Przywara Acked-by: Julien Grall --- xen/arch/arm/vgic-v3-its.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index f9379c9..8f1c217 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -118,6 +118,27 @@ static paddr_t get_baser_phys_addr(uint64_t reg) */ /* Must be called with the ITS lock held. */ +static int its_set_collection(struct virt_its *its, uint16_t collid, + coll_table_entry_t vcpu_id) +{ + paddr_t addr; + + /* The collection table entry must be able to store a VCPU ID. */ + BUILD_BUG_ON(BIT(sizeof(coll_table_entry_t) * 8) < MAX_VIRT_CPUS); + + addr = get_baser_phys_addr(its->baser_coll); + + ASSERT(spin_is_locked(&its->its_lock)); + + if ( collid >= its->max_collections ) + return -ENOENT; + + return vgic_access_guest_memory(its->d, + addr + collid * sizeof(coll_table_entry_t), + &vcpu_id, sizeof(vcpu_id), true); +} + +/* Must be called with the ITS lock held. */ static struct vcpu *get_vcpu_from_collection(struct virt_its *its, uint16_t collid) { @@ -318,6 +339,29 @@ static int its_handle_int(struct virt_its *its, uint64_t *cmdptr) return 0; } +static int its_handle_mapc(struct virt_its *its, uint64_t *cmdptr) +{ + uint32_t collid = its_cmd_get_collection(cmdptr); + uint64_t rdbase = its_cmd_mask_field(cmdptr, 2, 16, 44); + + if ( collid >= its->max_collections ) + return -1; + + if ( rdbase >= its->d->max_vcpus ) + return -1; + + spin_lock(&its->its_lock); + + if ( its_cmd_get_validbit(cmdptr) ) + its_set_collection(its, collid, rdbase); + else + its_set_collection(its, collid, UNMAPPED_COLLECTION); + + spin_unlock(&its->its_lock); + + return 0; +} + #define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12) #define ITS_CMD_OFFSET(reg) ((reg) & GENMASK(19, 5)) @@ -350,6 +394,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its) case GITS_CMD_INT: ret = its_handle_int(its, command); break; + case GITS_CMD_MAPC: + ret = its_handle_mapc(its, command); + break; case GITS_CMD_SYNC: /* We handle ITS commands synchronously, so we ignore SYNC. */ break;