From patchwork Mon Apr 3 20:28:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9660579 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 DC6106032D for ; Mon, 3 Apr 2017 20:29:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE7F328403 for ; Mon, 3 Apr 2017 20:29:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2E7B2841C; Mon, 3 Apr 2017 20:29: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 75FCF28403 for ; Mon, 3 Apr 2017 20:29:21 +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 1cv8Yv-000597-D8; Mon, 03 Apr 2017 20:26:53 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cv8Yu-00057P-Mg for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 20:26:52 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 71/CF-12861-B00B2E85; Mon, 03 Apr 2017 20:26:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTZd7w6M Ig/cXhC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxDn1cyF3wVrnjYNY+xgXEZfxcjF4eQwCZG iesbO9ggnOWMEqvXfmPqYuTkYBPQldhx8zUziC0iECrxdMF3MJtZQEli/9lrjCC2sICFxI7J/ 8DiLAKqEqt372IHsXkFrCXmnXnJBmJLCMhJNJy/D1bDCRRv/XgUrFdIwEpiwsMmpgmM3AsYGV YxahSnFpWlFukaGuslFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgR6mAEIdjBu2+5 5iFGSg0lJlFd90qMIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8x9YB5QSLUtNTK9Iyc4ChBpOW 4OBREuHdDJLmLS5IzC3OTIdInWJUlBLnzQBJCIAkMkrz4Npg4X2JUVZKmJcR6BAhnoLUotzME lT5V4ziHIxKwryh64Gm8GTmlcBNfwW0mAlo8ZM7D0EWlyQipKQaGJ2/f/7KW3R4baJed0bLWc X/12czP/PZeurRH187kQ3PyxicfvfwJBs+1Zo49TP7/HmvDU5fENyxx/riPrH5f083mS9ILPl blVKu3Nd/cqHt8umRgmaKB329OhbubHb0f3nr9x0+hsy7VxbMvq1TWG3t/qqi0ui04E/jBRsm dRmUzLR3OhY77asSS3FGoqEWc1FxIgCZ9X4GagIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1491251210!89834710!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 31450 invoked from network); 3 Apr 2017 20:26:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-31.messagelabs.com with SMTP; 3 Apr 2017 20:26:51 -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 8E78780D; Mon, 3 Apr 2017 13:26:50 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE2113F4FF; Mon, 3 Apr 2017 13:26:49 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 3 Apr 2017 21:28:20 +0100 Message-Id: <20170403202829.7278-19-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170403202829.7278-1-andre.przywara@arm.com> References: <20170403202829.7278-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v4 18/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 --- xen/arch/arm/vgic-v3-its.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index dd43eaf..639fbbf 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -87,6 +87,26 @@ static paddr_t get_baser_phys_addr(uint64_t reg) return reg & GENMASK_ULL(47, 12); } +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); + uint16_t *coll_table; + + if ( collid >= its->max_collections ) + return -ENOENT; + + coll_table = map_one_guest_page(its->d, addr + collid * sizeof(uint16_t)); + if ( !coll_table ) + return -EFAULT; + + *coll_table = vcpu_id; + + unmap_one_guest_page(coll_table); + + return 0; +} + /* Must be called with the ITS lock held. */ static struct vcpu *get_vcpu_from_collection(struct virt_its *its, uint16_t collid) @@ -324,6 +344,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) static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, @@ -367,6 +410,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its, case GITS_CMD_INT: ret = its_handle_int(its, cmdptr); break; + case GITS_CMD_MAPC: + ret = its_handle_mapc(its, cmdptr); + break; case GITS_CMD_SYNC: /* We handle ITS commands synchronously, so we ignore SYNC. */ break;