@@ -34,6 +34,9 @@
#include <linux/mm_types.h>
#include <linux/sched.h>
+int set_pgtable_ro(void *addr);
+int set_pgtable_rw(void *addr);
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
@@ -153,6 +153,20 @@ int set_memory_valid(unsigned long addr, int numpages, int enable)
__pgprot(PTE_VALID));
}
+int set_pgtable_ro(void *addr)
+{
+ return __change_memory_common((u64)addr, PAGE_SIZE,
+ __pgprot(PTE_RDONLY),
+ __pgprot(PTE_WRITE));
+}
+
+int set_pgtable_rw(void *addr)
+{
+ return __change_memory_common((u64)addr, PAGE_SIZE,
+ __pgprot(PTE_WRITE),
+ __pgprot(PTE_RDONLY));
+}
+
int set_direct_map_invalid_noflush(struct page *page)
{
struct page_change_data data = {
Add a couple of helpers to remap a single page read-only or read-write via its linear address. This will be used for mappings of page table pages in the linear region. Note that set_memory_ro/set_memory_rw operate on addresses in the vmalloc space only, so they cannot be used here. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- arch/arm64/include/asm/pgtable.h | 3 +++ arch/arm64/mm/pageattr.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+)