From patchwork Fri Mar 31 10:24:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9655883 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 CA2BE60350 for ; Fri, 31 Mar 2017 10:27:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB35024DA2 for ; Fri, 31 Mar 2017 10:27:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFA5126E39; Fri, 31 Mar 2017 10:27:15 +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 3E27624DA2 for ; Fri, 31 Mar 2017 10:27:15 +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 1cttk1-0002Ax-CP; Fri, 31 Mar 2017 10:25:13 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cttk0-0002Ah-F1 for xen-devel@lists.xen.org; Fri, 31 Mar 2017 10:25:12 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 60/42-13192-78E2ED85; Fri, 31 Mar 2017 10:25:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTbdd716 EwbMuLoslHxezODB6HN39mymAMYo1My8pvyKBNWPZ5SlMBZNkKv6tmMvawPhArIuRi0NIYBOj xP4vT1m6GDmBnO2MEjs3OILYbALaElN/T2QGsUUEpCWufb7MCNLALNDAJNE0rZsRJCEskCPRt mgzO4jNIqAq8X5BH1icV8BK4vqGuUwgtoSAvMSutousIDangLXEo63NbBDLrCQenjjMOoGRew EjwypG9eLUorLUIl0LvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MQP8yAMEOxtm X/Q8xSnIwKYnyfn98N0KILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO9/3XsRQoJFqempFWmZOcBA g0lLcPAoifAGg6R5iwsSc4sz0yFSpxgVpcR5C0ASAiCJjNI8uDZYcF9ilJUS5mUEOkSIpyC1K DezBFX+FaM4B6OSMO8MkCk8mXklcNNfAS1mAlps8fUuyOKSRISUVANjn1es7Nlr6/IrXvf9uv ufv3PvLCUrBu6WMu8v58TjOTba96yruX/jx8WYSx/mSsmbaS+b3GQW9fbfDu2iBXcTWJM5lTr a3/olmmqdSrW3OSojV+xpl5Vhe4dj/uXq0M9sMVkst4qiJpyYt2/mxkwJ533v7Ar+zbQ65rXy rtn/2mrt2f2VQleVWIozEg21mIuKEwGnwggeaQIAAA== X-Env-Sender: punit.agrawal@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1490955910!42342732!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 20456 invoked from network); 31 Mar 2017 10:25:10 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 31 Mar 2017 10:25:10 -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 13A1680D; Fri, 31 Mar 2017 03:25:10 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.195.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D67873F59A; Fri, 31 Mar 2017 03:25:09 -0700 (PDT) From: Punit Agrawal To: xen-devel@lists.xen.org Date: Fri, 31 Mar 2017 11:24:22 +0100 Message-Id: <20170331102424.11869-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170331102424.11869-1-punit.agrawal@arm.com> References: <20170331102424.11869-1-punit.agrawal@arm.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Punit Agrawal , tim@xen.org, julien.grall@arm.com, jbeulich@suse.com, ian.jackson@eu.citrix.com Subject: [Xen-devel] [For Xen-4.10 RFC PATCH 1/3] Allow control of icache invalidations when calling flush_page_to_ram() 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 flush_page_to_ram() unconditionally drops the icache. In certain situations this leads to execessive icache flushes when flush_page_to_ram() ends up being repeatedly called in a loop. Introduce a parameter to allow callers of flush_page_to_ram() to take responsibility of synchronising the icache. This is in preparations for adding logic to make the callers perform the necessary icache maintenance operations. Signed-off-by: Punit Agrawal --- xen/arch/arm/mm.c | 5 +++-- xen/arch/arm/p2m.c | 2 +- xen/common/page_alloc.c | 2 +- xen/include/asm-arm/page.h | 2 +- xen/include/asm-x86/flushtlb.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index f0a2eddaaf..e1ab5f8694 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -383,7 +383,7 @@ unsigned long domain_page_map_to_mfn(const void *ptr) } #endif -void flush_page_to_ram(unsigned long mfn) +void flush_page_to_ram(unsigned long mfn, bool sync_icache) { void *v = map_domain_page(_mfn(mfn)); @@ -398,7 +398,8 @@ void flush_page_to_ram(unsigned long mfn) * I-Cache (See D4.9.2 in ARM DDI 0487A.k_iss10775). Instead of using flush * by VA on select platforms, we just flush the entire cache here. */ - invalidate_icache(); + if (sync_icache) + invalidate_icache(); } void __init arch_init_memory(void) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 626376090d..76cd1c34f3 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1400,7 +1400,7 @@ int p2m_cache_flush(struct domain *d, gfn_t start, unsigned long nr) /* XXX: Implement preemption */ while ( gfn_x(start) < gfn_x(next_gfn) ) { - flush_page_to_ram(mfn_x(mfn)); + flush_page_to_ram(mfn_x(mfn), true); start = gfn_add(start, 1); mfn = mfn_add(mfn, 1); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 42c20cb201..15450a3b6d 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -838,7 +838,7 @@ static struct page_info *alloc_heap_pages( /* Ensure cache and RAM are consistent for platforms where the * guest can control its own visibility of/through the cache. */ - flush_page_to_ram(page_to_mfn(&pg[i])); + flush_page_to_ram(page_to_mfn(&pg[i]), true); } spin_unlock(&heap_lock); diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 4b46e8831c..497b4c86ad 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -407,7 +407,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, } /* Flush the dcache for an entire page. */ -void flush_page_to_ram(unsigned long mfn); +void flush_page_to_ram(unsigned long mfn, bool sync_icache); /* * Print a walk of a page table or p2m diff --git a/xen/include/asm-x86/flushtlb.h b/xen/include/asm-x86/flushtlb.h index 8b7adef7c5..bd2be7e482 100644 --- a/xen/include/asm-x86/flushtlb.h +++ b/xen/include/asm-x86/flushtlb.h @@ -118,7 +118,7 @@ void flush_area_mask(const cpumask_t *, const void *va, unsigned int flags); #define flush_tlb_one_all(v) \ flush_tlb_one_mask(&cpu_online_map, v) -static inline void flush_page_to_ram(unsigned long mfn) {} +static inline void flush_page_to_ram(unsigned long mfn, bool sync_icache) {} static inline int invalidate_dcache_va_range(const void *p, unsigned long size) { return -EOPNOTSUPP; }