From patchwork Wed Apr 12 00:44:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9676259 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 3958060383 for ; Wed, 12 Apr 2017 00:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FED728550 for ; Wed, 12 Apr 2017 00:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14DF32856B; Wed, 12 Apr 2017 00:48:30 +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 BEE5228550 for ; Wed, 12 Apr 2017 00:48:29 +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 1cy6Qf-0000qT-Re; Wed, 12 Apr 2017 00:46:37 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cy6Qe-0000nc-3E for xen-devel@lists.xenproject.org; Wed, 12 Apr 2017 00:46:36 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 48/60-27545-BE87DE85; Wed, 12 Apr 2017 00:46:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTfdVxds Ig/3LdS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox9LdOYCl4LVyyf3cjUwNjD38XIxSEksJlR YnXDMRYIZy+jxP6zPUxdjJwcbAK6EjtuvmYGsUUEQiXm/HzEDFLELLCGUaL901NWkISwgIXEz 8lzgLo5OFgEVCU2PjYEMXkF3CU+PpIHMSUE5CSu/EsAKeYEim7fPRGsUUjATWLrtMXMExi5Fz AyrGLUKE4tKkst0jWy0EsqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECPQuAxDsYDy /NvAQoyQHk5Io72WFtxFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHijy4FygkWp6akVaZk5wDCD SUtw8CiJ8CqCpHmLCxJzizPTIVKnGBWlxHlLQRICIImM0jy4NlhoX2KUlRLmZQQ6RIinILUoN 7MEVf4VozgHo5IwxHaezLwSuOmvgBYzAS0+s+slyOKSRISUVAOjf+Gt1CfH/lSwhmUWeN28a2 ctNT3660/JDX/EubakLLVb6HxIc4/DppftQnu9b/DGHGuf7VU+YU6Ayez5SjbGxyTP2N3T+nQ uIrN14ptAz7f5m/i7H+zIuPiud2vbtU/dtlnFZyTNKzVDpBS1pbVXCf+uPr5ju6eSyL99Igu6 ptxKPJGltEtbiaU4I9FQi7moOBEAJaNg2GgCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1491957994!44402918!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 35315 invoked from network); 12 Apr 2017 00:46:34 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 12 Apr 2017 00:46:34 -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 0B85415A1; Tue, 11 Apr 2017 17:46:34 -0700 (PDT) Received: from slackpad.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6AC733F575; Tue, 11 Apr 2017 17:46:32 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Wed, 12 Apr 2017 01:44:24 +0100 Message-Id: <1491957874-31600-18-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1491957874-31600-1-git-send-email-andre.przywara@arm.com> References: <1491957874-31600-1-git-send-email-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni Subject: [Xen-devel] [PATCH v8 17/27] 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 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index eeb1306..6e505cb 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -116,6 +116,21 @@ static paddr_t get_baser_phys_addr(uint64_t reg) #define COLL_TABLE_ENTRY_SIZE 2UL /* Must be called with the ITS lock held. */ +static int its_set_collection(struct virt_its *its, uint16_t collid, + uint16_t vcpu_id) +{ + paddr_t 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(uint16_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) { @@ -360,6 +375,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)) @@ -395,6 +433,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;