From: Khalid Aziz Date: Mon, 8 May 2017 22:17:43 +0000 (-0600) Subject: sparc64: Allow enabling ADI on hugepages only X-Git-Tag: v4.1.12-98.0.20170517_2143~22 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0ecb6b7e46300e29e08ed21531f3484ad05c00db;p=users%2Fjedix%2Flinux-maple.git 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 --- diff --git a/mm/mprotect.c b/mm/mprotect.c index cc28ae26da399..65b60af38842f 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)