arm64: mm: add set_memory_valid()
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Mon, 3 Apr 2017 02:24:33 +0000 (11:24 +0900)
committerAKASHI Takahiro <takahiro.akashi@linaro.org>
Mon, 19 Jun 2017 06:09:03 +0000 (15:09 +0900)
This function validates and invalidates PTE entries, and will be utilized
in kdump to protect loaded crash dump kernel image.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Conflicts:
arch/arm64/mm/pageattr.c
due to missing commit 83863f25e4b8 ("arm64: Add support for
ARCH_SUPPORTS_DEBUG_PAGEALLOC")

arch/arm64/include/asm/cacheflush.h
arch/arm64/mm/pageattr.c

index 22dda613f9c91bd3bcfe3a8aad435f7384795401..22aabdeacc24757f6833ae7f45096e517828bafb 100644 (file)
@@ -155,5 +155,6 @@ int set_memory_ro(unsigned long addr, int numpages);
 int set_memory_rw(unsigned long addr, int numpages);
 int set_memory_x(unsigned long addr, int numpages);
 int set_memory_nx(unsigned long addr, int numpages);
+int set_memory_valid(unsigned long addr, unsigned long size, int enable);
 
 #endif
index ca6d268e3313229b0941ce7d33439c7a4c861120..f4e39dbdd36b0f098a143d50568420ac133789e4 100644 (file)
@@ -125,6 +125,19 @@ int set_memory_x(unsigned long addr, int numpages)
 }
 EXPORT_SYMBOL_GPL(set_memory_x);
 
+
+int set_memory_valid(unsigned long addr, int numpages, int enable)
+{
+       if (enable)
+               return __change_memory_common(addr, PAGE_SIZE * numpages,
+                                       __pgprot(PTE_VALID),
+                                       __pgprot(0));
+       else
+               return __change_memory_common(addr, PAGE_SIZE * numpages,
+                                       __pgprot(0),
+                                       __pgprot(PTE_VALID));
+}
+
 #ifdef CONFIG_DEBUG_PAGEALLOC
 void __kernel_map_pages(struct page *page, int numpages, int enable)
 {