From 0ecb6b7e46300e29e08ed21531f3484ad05c00db Mon Sep 17 00:00:00 2001 From: Khalid Aziz Date: Mon, 8 May 2017 16:17:43 -0600 Subject: [PATCH] sparc64: Allow enabling ADI on hugepages only Since kernel provides only limted support for ADI on regular pages, mprotect() should not allow enabling ADI on any pages other than hugepages until rest of the support is complete. Orabug: 25969377 Signed-off-by: Khalid Aziz Signed-off-by: Allen Pais --- mm/mprotect.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/mprotect.c b/mm/mprotect.c index cc28ae26da39..65b60af38842 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -370,6 +370,18 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len, error = -ENOMEM; if (!vma) goto out; + +#ifdef CONFIG_SPARC64 + /* This is a hack until ADI is supported for swappable pages. + * Remove this code when that happens. + */ + if (unlikely((prot & PROT_ADI) && + (!is_vm_hugetlb_page(vma)))) { + error = -EINVAL; + goto out; + } +#endif + prev = vma->vm_prev; if (unlikely(grows & PROT_GROWSDOWN)) { if (vma->vm_start >= end) -- 2.50.1