From patchwork Mon May 15 14:10:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9727103 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 B945D60386 for ; Mon, 15 May 2017 14:12:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAC8D289A7 for ; Mon, 15 May 2017 14:12:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F3BC289A6; Mon, 15 May 2017 14:12:57 +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 2FFD828992 for ; Mon, 15 May 2017 14:12:57 +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 1dAGi8-00066U-7h; Mon, 15 May 2017 14:10:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dAGi7-000666-5I for xen-devel@lists.xen.org; Mon, 15 May 2017 14:10:55 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 51/FF-03371-EE6B9195; Mon, 15 May 2017 14:10:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTffdNsl Ig64njBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bH9hNsBVNkKiZ83sbSwPhArIuRi0NIYDOj xKnHmxkhnO2MEqv/rmPrYuTkYBPQlpj6eyIziC0iIC1x7fNlRhCbWaCBSeLjMhMQW1ggX+Jk0 z1WEJtFQFViwrLN7CA2r4ClxI0Li8HiEgLyErvaLoLZnAJWEhc/nQabIwRU07rqGhNEjaTEnp PfGScw8ixgZFjFqF6cWlSWWqRrqJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJEeh 3BiDYwbjzudMhRkkOJiVRXteX4pFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjvb5WMFBIsSk1P rUjLzAEGIExagoNHSYR3EUiat7ggMbc4Mx0idYpRUUqc1xckIQCSyCjNg2uDBf0lRlkpYV5Go EOEeApSi3IzS1DlXzGKczAqCfMuBpnCk5lXAjf9FdBiJqDFYSA38xaXJCKkpBoYPYW/t3K4dj zYFmA2m/n6Tp8vmflnlO37z11fEtEaUlfwre+Z/rOiHqEbeZePt8TY24XPN5zeLZ8UOmESl/S jhXY+5mc251Y2dwfIMjFflumYPF84bFLy18eX9OY9z5+ZMkVu+Qx918tNM1I/bHA7NXXus4vm iTN6r6vVuO+pl6n6eoNdNPGuEktxRqKhFnNRcSIAZpiQanUCAAA= X-Env-Sender: punit.agrawal@arm.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1494857453!62486024!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 47834 invoked from network); 15 May 2017 14:10:53 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-21.messagelabs.com with SMTP; 15 May 2017 14:10:53 -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 2709A1435; Mon, 15 May 2017 07:10:53 -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 E7C4A3F41F; Mon, 15 May 2017 07:10:52 -0700 (PDT) From: Punit Agrawal To: xen-devel@lists.xen.org Date: Mon, 15 May 2017 15:10:10 +0100 Message-Id: <20170515141012.6612-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170515141012.6612-1-punit.agrawal@arm.com> References: <20170515141012.6612-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 Resend 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 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 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; }