From patchwork Thu Sep 15 11:28:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 76292 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp2387432qgf; Thu, 15 Sep 2016 04:31:08 -0700 (PDT) X-Received: by 10.107.197.69 with SMTP id v66mr19134361iof.119.1473939068424; Thu, 15 Sep 2016 04:31:08 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 141si3279053itu.31.2016.09.15.04.31.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2016 04:31:08 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkUr1-0005FT-Pu; Thu, 15 Sep 2016 11:29:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkUqz-0005AY-VU for xen-devel@lists.xen.org; Thu, 15 Sep 2016 11:29:18 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 9C/CA-19721-D068AD75; Thu, 15 Sep 2016 11:29:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTZen7Va 4wZpv6hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bdzu3sBb0yFYu3X2FpYFwi0sXIxSEksIlR 4snS+UwQzmlGic7Nz9m6GDk52AQ0Je58/sQEYosISEtc+3yZEaSIWWALo8TPm5fZuxg5OIQFY iUenHcBqWERUJV4s/8MWD2vgKvErx/HGEFsCQE5iZPHJrOClHMCxZc8FwUJCwm4SBw7sZNtAi P3AkaGVYwaxalFZalFuobGeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgf5lAII djP+2eR5ilORgUhLldUu7FS7El5SfUpmRWJwRX1Sak1p8iFGGg0NJgndfC1BOsCg1PbUiLTMH GGgwaQkOHiURXnaQNG9xQWJucWY6ROoUo6KUOESfAEgiozQPrg0W3JcYZaWEeRmBDhHiKUgty s0sQZV/xSjOwagkzNsFMoUnM68EbvoroMVMQIu3rLkOsrgkESEl1cCYHdjD1PFDdppO1aT8qY 6PHVNV5KxWPgtqvC9xp/9qf4ibeEHioVl1oVeSK9Nmyy32buOeeWPqkplPorZFyBgkzjR9aMr 29udMO/P59QH1pyUOuy1U68/6pzEpvp9PbGfgNGP7OIVvpkzP3yo0CiyrMPgefLEiVdbixI8T xuILXN+tCb4gvEmJpTgj0VCLuag4EQDwhjUDaQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1473938956!42550209!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 1930 invoked from network); 15 Sep 2016 11:29:16 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-206.messagelabs.com with SMTP; 15 Sep 2016 11:29:16 -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 B4FA3C0A; Thu, 15 Sep 2016 04:29:15 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8E1493F251; Thu, 15 Sep 2016 04:29:14 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 15 Sep 2016 12:28:38 +0100 Message-Id: <1473938919-31976-23-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473938919-31976-1-git-send-email-julien.grall@arm.com> References: <1473938919-31976-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, steve.capper@arm.com, proskurin@sec.in.tum.de, Julien Grall , Stefano Stabellini , wei.chen@linaro.org Subject: [Xen-devel] [for-4.8][PATCH v2 22/23] xen/arm: p2m: Do not handle shattering in p2m_create_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" The helper p2m_create_table is only called to create a brand new table. Signed-off-by: Julien Grall Reviewd-by: Stefano Stabellini Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/p2m.c | 56 ++++++------------------------------------------------ 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index aa740c2..c1dac09 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -278,8 +278,7 @@ static p2m_access_t p2m_mem_access_radix_get(struct p2m_domain *p2m, gfn_t gfn) #define GUEST_TABLE_SUPER_PAGE 1 #define GUEST_TABLE_NORMAL_PAGE 2 -static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry, - int level_shift); +static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry); /* * Take the currently mapped table, find the corresponding GFN entry, @@ -310,7 +309,7 @@ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, if ( read_only ) return GUEST_TABLE_MAP_FAILED; - ret = p2m_create_table(p2m, entry, /* not used */ ~0); + ret = p2m_create_table(p2m, entry); if ( ret ) return GUEST_TABLE_MAP_FAILED; } @@ -575,25 +574,14 @@ static inline void p2m_remove_pte(lpae_t *p, bool clean_pte) p2m_write_pte(p, pte, clean_pte); } -/* - * Allocate a new page table page and hook it in via the given entry. - * apply_one_level relies on this returning 0 on success - * and -ve on failure. - * - * If the existing entry is present then it must be a mapping and not - * a table and it will be shattered into the next level down. - * - * level_shift is the number of bits at the level we want to create. - */ -static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry, - int level_shift) +/* Allocate a new page table page and hook it in via the given entry. */ +static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) { struct page_info *page; lpae_t *p; lpae_t pte; - int splitting = p2m_valid(*entry); - BUG_ON(p2m_table(*entry)); + ASSERT(!p2m_valid(*entry)); page = alloc_domheap_page(NULL, 0); if ( page == NULL ) @@ -602,39 +590,7 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry, page_list_add(page, &p2m->pages); p = __map_domain_page(page); - if ( splitting ) - { - mfn_t mfn = _mfn(entry->p2m.base); - int i; - - /* - * We are either splitting a first level 1G page into 512 second level - * 2M pages, or a second level 2M page into 512 third level 4K pages. - */ - for ( i=0 ; i < LPAE_ENTRIES; i++ ) - { - /* - * Use the content of the superpage entry and override - * the necessary fields. So the correct permissions are - * kept. - */ - pte = *entry; - pte.p2m.base = mfn_x(mfn_add(mfn, - i << (level_shift - LPAE_SHIFT))); - - /* - * First and second level super pages set p2m.table = 0, but - * third level entries set table = 1. - */ - pte.p2m.table = !(level_shift - LPAE_SHIFT); - - write_pte(&p[i], pte); - } - - page->u.inuse.p2m_refcount = LPAE_ENTRIES; - } - else - clear_page(p); + clear_page(p); if ( p2m->clean_pte ) clean_dcache_va_range(p, PAGE_SIZE);