From patchwork Fri May 26 11:14:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9750399 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 46B8F60249 for ; Fri, 26 May 2017 11:18:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F45427C2D for ; Fri, 26 May 2017 11:18:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34074283CF; Fri, 26 May 2017 11:18:38 +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 C2F7028380 for ; Fri, 26 May 2017 11:18:37 +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 1dEDEL-0006C2-IE; Fri, 26 May 2017 11:16:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEDEJ-0006Bi-RC for xen-devel@lists.xen.org; Fri, 26 May 2017 11:16:27 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 57/CF-03058-B8E08295; Fri, 26 May 2017 11:16:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTbeLTyP SoHuanMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnH54j2Wgu8yFZv2XGdpYNwt3sXIySEksJlR 4u4R5i5GLiB7O6PEhH13mEASbALaElN/T2QGsUUEpCWufb7MCFLELNDAJNE0rZsRJCEskC3RM WEvmM0ioCox8d4WsAZeASuJPc37wOISAvISu9ousoLYnALWEo8ezWaB2Gwl0fT4NytEjaTEnp PfGScw8ixgZFjFqFGcWlSWWqRrZKSXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iRH oeQYg2MG4Zn7gIUZJDiYlUd7p69QjhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwPuLRiBQSLEpN T61Iy8wBhiBMWoKDR0mEdxtImre4IDG3ODMdInWKUVFKnFeQFyghAJLIKM2Da4OF/SVGWSlhX kagQ4R4ClKLcjNLUOVfMYpzMCoJ89aDjOfJzCuBm/4KaDET0GLfc+ogi0sSEVJSDYwaL6Jydl 5Su5Ir1b/pZXbLx5fZTse/qdh+bL7W66zcejbgXDvTrxC+iUpaL6POfZGTyLTM79mz7u+1j+Z 5kYcbOYX3rRZj2doqVf1HI2pNjKZen9Ay1h+PNHcJb9tbG3uiKpfd4PVz086DDN6HH144drYv 6tLkadHT+DUYt2QEzvhVsjBQnFGJpTgj0VCLuag4EQD7SX/0dgIAAA== X-Env-Sender: punit.agrawal@arm.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1495797385!95037380!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7821 invoked from network); 26 May 2017 11:16:26 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-27.messagelabs.com with SMTP; 26 May 2017 11:16:26 -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 818D41596; Fri, 26 May 2017 04:16:25 -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 4E7773F41F; Fri, 26 May 2017 04:16:25 -0700 (PDT) From: Punit Agrawal To: xen-devel@lists.xen.org Date: Fri, 26 May 2017 12:14:05 +0100 Message-Id: <20170526111407.13537-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170526111407.13537-1-punit.agrawal@arm.com> References: <20170526111407.13537-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail 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 PATCH v2 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 Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini --- 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 752e948070..291998938e 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1398,7 +1398,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; }