Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: introduce mm_forbids_zeropage function

Add a new function stub to allow architectures to disable for
an mm_structthe backing of non-present, anonymous pages with
read-only empty zero pages.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Dominik Dingel and committed by
Martin Schwidefsky
593befa6 a13cff31

+13 -2
+11
include/linux/mm.h
··· 56 56 #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) 57 57 #endif 58 58 59 + /* 60 + * To prevent common memory management code establishing 61 + * a zero page mapping on a read fault. 62 + * This macro should be defined within <asm/pgtable.h>. 63 + * s390 does this to prevent multiplexing of hardware bits 64 + * related to the physical page in case of virtualization. 65 + */ 66 + #ifndef mm_forbids_zeropage 67 + #define mm_forbids_zeropage(X) (0) 68 + #endif 69 + 59 70 extern unsigned long sysctl_user_reserve_kbytes; 60 71 extern unsigned long sysctl_admin_reserve_kbytes; 61 72
+1 -1
mm/huge_memory.c
··· 805 805 return VM_FAULT_OOM; 806 806 if (unlikely(khugepaged_enter(vma))) 807 807 return VM_FAULT_OOM; 808 - if (!(flags & FAULT_FLAG_WRITE) && 808 + if (!(flags & FAULT_FLAG_WRITE) && !mm_forbids_zeropage(mm) && 809 809 transparent_hugepage_use_zero_page()) { 810 810 spinlock_t *ptl; 811 811 pgtable_t pgtable;
+1 -1
mm/memory.c
··· 2640 2640 return VM_FAULT_SIGBUS; 2641 2641 2642 2642 /* Use the zero-page for reads */ 2643 - if (!(flags & FAULT_FLAG_WRITE)) { 2643 + if (!(flags & FAULT_FLAG_WRITE) && !mm_forbids_zeropage(mm)) { 2644 2644 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address), 2645 2645 vma->vm_page_prot)); 2646 2646 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);