arm64: mm: add set_memory_valid()
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Mon, 3 Apr 2017 02:24:33 +0000 (11:24 +0900)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 5 Apr 2017 17:27:53 +0000 (18:27 +0100)
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>
arch/arm64/include/asm/cacheflush.h
arch/arm64/mm/pageattr.c

index 5a2a6ee65f65517559c7f444dacf3052fe5f8b9d..728f933cef8c90daa98209fb4431fdb265f66ce1 100644 (file)
@@ -154,5 +154,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 8def55e7249b12054e6a6218896d90438c4a7316..3212ee0558f6e0ca3113b4ad9db157911085a768 100644 (file)
@@ -125,20 +125,23 @@ int set_memory_x(unsigned long addr, int numpages)
 }
 EXPORT_SYMBOL_GPL(set_memory_x);
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
-void __kernel_map_pages(struct page *page, int numpages, int enable)
+int set_memory_valid(unsigned long addr, int numpages, int enable)
 {
-       unsigned long addr = (unsigned long) page_address(page);
-
        if (enable)
-               __change_memory_common(addr, PAGE_SIZE * numpages,
+               return __change_memory_common(addr, PAGE_SIZE * numpages,
                                        __pgprot(PTE_VALID),
                                        __pgprot(0));
        else
-               __change_memory_common(addr, PAGE_SIZE * numpages,
+               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)
+{
+       set_memory_valid((unsigned long)page_address(page), numpages, enable);
+}
 #ifdef CONFIG_HIBERNATION
 /*
  * When built with CONFIG_DEBUG_PAGEALLOC and CONFIG_HIBERNATION, this function