From patchwork Mon Aug 1 17:10:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergej Proskurin X-Patchwork-Id: 9254593 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 BE1396048B for ; Mon, 1 Aug 2016 17:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB0B72843C for ; Mon, 1 Aug 2016 17:13:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FA25284AD; Mon, 1 Aug 2016 17:13:45 +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 930F5284AE for ; Mon, 1 Aug 2016 17:13:44 +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 1bUGkE-0006OV-Qn; Mon, 01 Aug 2016 17:11:14 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUGkD-0006LY-B0 for xen-devel@lists.xenproject.org; Mon, 01 Aug 2016 17:11:13 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 90/31-07858-0B28F975; Mon, 01 Aug 2016 17:11:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsXSPJ+BQ3dD0/x wg28TWCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozvL5cwFqwUrvjRW9jAeJa/i5GLQ0hgI6NE 45pFbBDOckaJQy/WsXQxcnKwCRhITHm9khXEFhFQkri3ajITSBGzQBOjxL3GB2wgCWEBD4nTl xcxgdgsAqoSc7uugjXwCthIXD3QBFYjISAn0XD+PjOIzSlgK9F3eznYAiGgmsVX9zNPYORewM iwilG9OLWoLLVI11QvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyPQvwxAsINx+mX /Q4ySHExKorwJBfPDhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwbm8EygkWpaanVqRl5gADDSYt wcGjJMLbAZLmLS5IzC3OTIdInWJUlBLnTQNJCIAkMkrz4NpgwX2JUVZKmJcR6BAhnoLUotzME lT5V4ziHIxKwrzrQKbwZOaVwE1/BbSYCWhxov0ckMUliQgpqQbGKZwX6sVPLjtiMc++ovFS8z 2115qqa50Y+g8dPvPR2vTZvqRQn7o74rqBe2tNtBe6mm3Tf+MXeTLR9KW9YKJDbWK9CXuvyam DZyZ0ZvcF/WZxsE4s2+Rw+Xm1D9+Gf42P0j+93VPiZRieby5gfNN163Izm6XnXj56lebMkG5l fC46esdDFy0lluKMREMt5qLiRAD98Nx4aQIAAA== X-Env-Sender: proskurin@sec.in.tum.de X-Msg-Ref: server-8.tower-21.messagelabs.com!1470071471!26557097!1 X-Originating-IP: [131.159.0.8] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50574 invoked from network); 1 Aug 2016 17:11:12 -0000 Received: from mail-out1.informatik.tu-muenchen.de (HELO mail-out1.informatik.tu-muenchen.de) (131.159.0.8) by server-8.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Aug 2016 17:11:12 -0000 Received: from files.sec.in.tum.de (files.sec.in.tum.de [131.159.50.1]) by services.sec.in.tum.de (Postfix) with ESMTP id F1E4010100E9D; Mon, 1 Aug 2016 19:11:10 +0200 (CEST) Received: from ker.sec.in.tum.de (ker.sec.in.tum.de [131.159.50.36]) by files.sec.in.tum.de (Postfix) with ESMTP id E57314400; Mon, 1 Aug 2016 19:11:10 +0200 (CEST) From: Sergej Proskurin To: xen-devel@lists.xenproject.org Date: Mon, 1 Aug 2016 19:10:08 +0200 Message-Id: <20160801171028.11615-6-proskurin@sec.in.tum.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160801171028.11615-1-proskurin@sec.in.tum.de> References: <20160801171028.11615-1-proskurin@sec.in.tum.de> Cc: Sergej Proskurin , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH v2 05/25] arm/altp2m: Rename and extend p2m_alloc_table. 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 initially named function "p2m_alloc_table" allocated pages solely required for the host's p2m. The new implementation leaves p2m allocation related parts inside of this function to generally initialize p2m/altp2m tables. This is done generically, as the host's p2m and altp2m tables are allocated similarly. Since this function will be used by the altp2m initialization routines, it is not made static. In addition, this commit provides the overlay function "p2m_table_init" that is used for the host's p2m allocation/initialization. Signed-off-by: Sergej Proskurin --- Cc: Stefano Stabellini Cc: Julien Grall --- v2: Removed altp2m table initialization from "p2m_table_init". --- xen/arch/arm/p2m.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 17f3299..63fe3d9 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1277,11 +1277,11 @@ void guest_physmap_remove_page(struct domain *d, p2m_remove_mapping(d, gfn, (1 << page_order), mfn); } -static int p2m_alloc_table(struct domain *d) +int p2m_alloc_table(struct p2m_domain *p2m) { - struct p2m_domain *p2m = &d->arch.p2m; - struct page_info *page; unsigned int i; + struct page_info *page; + struct vttbr *vttbr = &p2m->vttbr; page = alloc_domheap_pages(NULL, P2M_ROOT_ORDER, 0); if ( page == NULL ) @@ -1293,11 +1293,28 @@ static int p2m_alloc_table(struct domain *d) p2m->root = page; - p2m->vttbr.vttbr = page_to_maddr(p2m->root) | ((uint64_t)p2m->vmid & 0xff) << 48; + /* Initialize the VTTBR associated with the allocated p2m table. */ + vttbr->vttbr = 0; + vttbr->vmid = p2m->vmid & 0xff; + vttbr->baddr = page_to_maddr(p2m->root); + + return 0; +} + +static int p2m_table_init(struct domain *d) +{ + int rc; + struct p2m_domain *p2m = p2m_get_hostp2m(d); + + rc = p2m_alloc_table(p2m); + if ( rc != 0 ) + return -ENOMEM; + + d->arch.altp2m_active = false; /* * Make sure that all TLBs corresponding to the new VMID are flushed - * before using it + * before using it. */ p2m_flush_tlb(p2m); @@ -1440,7 +1457,7 @@ static int p2m_init_hostp2m(struct domain *d) if ( rc ) return rc; - return p2m_alloc_table(d); + return p2m_table_init(d); } int p2m_init(struct domain *d)