From patchwork Mon May 15 14:05:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9727087 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 4F33660380 for ; Mon, 15 May 2017 14:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 411262074F for ; Mon, 15 May 2017 14:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3417228918; Mon, 15 May 2017 14:08:00 +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 9D6FE288B0 for ; Mon, 15 May 2017 14:07:59 +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 1dAGcr-0004te-EY; Mon, 15 May 2017 14:05:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dAGcr-0004tR-3g for xen-devel@lists.xen.org; Mon, 15 May 2017 14:05:29 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id F6/70-11537-8A5B9195; Mon, 15 May 2017 14:05:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTXf5Vsl IgwV9JhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bH9hNsBVNkKiZ83sbSwPhArIuRi0NIYDOj xOK7V9ghnO2MEiv+9jJ2MXJysAloS0z9PZEZxBYRkJa49vkyI0gRs8B/RoltV3uYuhg5OIQFM iT6l6aA1LAIqEr83fOTDcTmFbCUaH/zhwnElhCQl9jVdpEVxOYUsJJYtPEVO4gtBFTzcfINFo gaSYk9J78zTmDkWcDIsIpRozi1qCy1SNfIXC+pKDM9oyQ3MTNH19DAWC83tbg4MT01JzGpWC8 5P3cTI9Dz9QwMjDsYW/b6HWKU5GBSEuV1fSkeKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCt2CL ZKSQYFFqempFWmYOMARh0hIcPEoivCUgad7igsTc4sx0iNQpRkUpcd6HIAkBkERGaR5cGyzsL zHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5t0MMoUnM68EbvoroMVMQIvDQG7mLS5JREhJNT Ae7615v/f3qye/T20Usgi8fvFKyJbXyQf+Z+X/2yzvwbab9X6t56T3//4mt91Y9Yw3INP2m83 ph2ft0p/1Ldozxe+H1bXZuepLvwafiXYMiyx+3tMTOmu+RYaQTYLV1L3NFlFPqw3UPv3XE1Nb +irlc86zf8Hz+/s28c051czkF98otj225fI/JZbijERDLeai4kQA+8MbsnYCAAA= X-Env-Sender: punit.agrawal@arm.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1494857127!61894542!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 39709 invoked from network); 15 May 2017 14:05:27 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-31.messagelabs.com with SMTP; 15 May 2017 14:05:27 -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 E0FF61516; Mon, 15 May 2017 07:05:26 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.207.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AF4533F41F; Mon, 15 May 2017 07:05:26 -0700 (PDT) From: Punit Agrawal To: xen-devel@lists.xen.org Date: Mon, 15 May 2017 15:05:02 +0100 Message-Id: <20170515140504.6461-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170515140504.6461-1-punit.agrawal@arm.com> References: <20170515140504.6461-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail Cc: sstabellini@kernel.org, wei.liu2@citrix.com, konrad.wil@oracle.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 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 48f74f6e65..082c872c72 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -420,7 +420,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)); @@ -435,7 +435,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 34d57760d7..29f2e2fad3 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1392,7 +1392,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 9e41fb4cd3..eba78f1a3d 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -833,7 +833,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; }