arm: provision page alloc debug support
Equip arm to support ARCH_SUPPORTS_DEBUG_PAGEALLOC and
enable it by default.
Having this support means all pages freed at buddy level
would be marked as read-only and would help catch any
scribbling over free page area. Allocated pages mapping
attributes is restored to read/write.
ARCH_SUPPORTS_DEBUG_PAGEALLOC needs FORCE_PAGES which
ensures all kernel mapping are populated with page
granularity and it would ensure page level accesses can
be rightly configured.
Change-Id: I9b23d1fb0b9594cc148b082c104da9a773c26057
Signed-off-by: Shiraz Hashim <shashim@codeaurora.org>
diff --git a/arch/arm/mm/pageattr.c b/arch/arm/mm/pageattr.c
index 0b26a84..47b1f478 100644
--- a/arch/arm/mm/pageattr.c
+++ b/arch/arm/mm/pageattr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014,2017 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -97,3 +97,19 @@
__pgprot(0),
__pgprot(L_PTE_XN));
}
+
+#ifdef CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC
+void __kernel_map_pages(struct page *page, int numpages, int enable)
+{
+ unsigned long addr;
+
+ if (PageHighMem(page))
+ return;
+
+ addr = (unsigned long) page_address(page);
+ if (enable)
+ set_memory_rw(addr, numpages);
+ else
+ set_memory_ro(addr, numpages);
+}
+#endif