linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM64: Kernel managed pages are only flushed
@ 2014-03-05 11:20 Bharat Bhushan
  2014-03-06  6:53 ` Catalin Marinas
  0 siblings, 1 reply; 11+ messages in thread
From: Bharat Bhushan @ 2014-03-05 11:20 UTC (permalink / raw)
  To: linux-arm-kernel

Kernel can only access pages which maps to managed memory.
So flush only valid kernel pages.

I observed kernel crash direct assigning a device using VFIO
and found that it was caused because of accessing invalid page

Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
---
 arch/arm64/mm/flush.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c
index e4193e3..2b4e8b0 100644
--- a/arch/arm64/mm/flush.c
+++ b/arch/arm64/mm/flush.c
@@ -72,7 +72,18 @@ void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
 
 void __sync_icache_dcache(pte_t pte, unsigned long addr)
 {
-	struct page *page = pte_page(pte);
+	struct page *page;
+
+#ifdef CONFIG_HAVE_ARCH_PFN_VALID
+	/*
+	 * We can only access pages that the kernel maps
+	 * as memory. Bail out for unmapped ones.
+	 */
+	if (!pfn_valid(pfn))
+		return;
+
+#endif
+	page = pte_page(pte);
 
 	/* no flushing needed for anonymous pages */
 	if (!page_mapping(page))
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-03-27 10:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-05 11:20 [PATCH] ARM64: Kernel managed pages are only flushed Bharat Bhushan
2014-03-06  6:53 ` Catalin Marinas
2014-03-06  9:33   ` Bharat.Bhushan at freescale.com
2014-03-12 14:41   ` Bharat.Bhushan at freescale.com
2014-03-12 14:56     ` Will Deacon
2014-03-12 16:03       ` Catalin Marinas
2014-03-12 17:26         ` Catalin Marinas
2014-03-12 20:12           ` Laura Abbott
2014-03-13 11:00           ` Bharat.Bhushan at freescale.com
2014-03-26  3:16           ` Bharat.Bhushan at freescale.com
2014-03-27 10:55             ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).