From: Greg Kroah-Hartman Date: Mon, 6 Oct 2014 00:16:44 +0000 (-0700) Subject: 3.14-stable patches X-Git-Tag: v3.10.57~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=284489c3f14779027b54c6135ed509d18db3ce46;p=thirdparty%2Fkernel%2Fstable-queue.git 3.14-stable patches added patches: hugetlb-ensure-hugepage-access-is-denied-if-hugepages-are-not-supported.patch --- diff --git a/queue-3.14/hugetlb-ensure-hugepage-access-is-denied-if-hugepages-are-not-supported.patch b/queue-3.14/hugetlb-ensure-hugepage-access-is-denied-if-hugepages-are-not-supported.patch new file mode 100644 index 00000000000..86e866287b2 --- /dev/null +++ b/queue-3.14/hugetlb-ensure-hugepage-access-is-denied-if-hugepages-are-not-supported.patch @@ -0,0 +1,138 @@ +From 457c1b27ed56ec472d202731b12417bff023594a Mon Sep 17 00:00:00 2001 +From: Nishanth Aravamudan +Date: Tue, 6 May 2014 12:50:00 -0700 +Subject: hugetlb: ensure hugepage access is denied if hugepages are not supported + +From: Nishanth Aravamudan + +commit 457c1b27ed56ec472d202731b12417bff023594a upstream. + +Currently, I am seeing the following when I `mount -t hugetlbfs /none +/dev/hugetlbfs`, and then simply do a `ls /dev/hugetlbfs`. I think it's +related to the fact that hugetlbfs is properly not correctly setting +itself up in this state?: + + Unable to handle kernel paging request for data at address 0x00000031 + Faulting instruction address: 0xc000000000245710 + Oops: Kernel access of bad area, sig: 11 [#1] + SMP NR_CPUS=2048 NUMA pSeries + .... + +In KVM guests on Power, in a guest not backed by hugepages, we see the +following: + + AnonHugePages: 0 kB + HugePages_Total: 0 + HugePages_Free: 0 + HugePages_Rsvd: 0 + HugePages_Surp: 0 + Hugepagesize: 64 kB + +HPAGE_SHIFT == 0 in this configuration, which indicates that hugepages +are not supported at boot-time, but this is only checked in +hugetlb_init(). Extract the check to a helper function, and use it in a +few relevant places. + +This does make hugetlbfs not supported (not registered at all) in this +environment. I believe this is fine, as there are no valid hugepages +and that won't change at runtime. + +[akpm@linux-foundation.org: use pr_info(), per Mel] +[akpm@linux-foundation.org: fix build when HPAGE_SHIFT is undefined] +Signed-off-by: Nishanth Aravamudan +Reviewed-by: Aneesh Kumar K.V +Acked-by: Mel Gorman +Cc: Randy Dunlap +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + fs/hugetlbfs/inode.c | 5 +++++ + include/linux/hugetlb.h | 10 ++++++++++ + mm/hugetlb.c | 13 +++++++++++++ + 3 files changed, 28 insertions(+) + +--- a/fs/hugetlbfs/inode.c ++++ b/fs/hugetlbfs/inode.c +@@ -1017,6 +1017,11 @@ static int __init init_hugetlbfs_fs(void + int error; + int i; + ++ if (!hugepages_supported()) { ++ pr_info("hugetlbfs: disabling because there are no supported hugepage sizes\n"); ++ return -ENOTSUPP; ++ } ++ + error = bdi_init(&hugetlbfs_backing_dev_info); + if (error) + return error; +--- a/include/linux/hugetlb.h ++++ b/include/linux/hugetlb.h +@@ -400,6 +400,16 @@ static inline spinlock_t *huge_pte_lockp + return &mm->page_table_lock; + } + ++static inline bool hugepages_supported(void) ++{ ++ /* ++ * Some platform decide whether they support huge pages at boot ++ * time. On these, such as powerpc, HPAGE_SHIFT is set to 0 when ++ * there is no such support ++ */ ++ return HPAGE_SHIFT != 0; ++} ++ + #else /* CONFIG_HUGETLB_PAGE */ + struct hstate {}; + #define alloc_huge_page_node(h, nid) NULL +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -2071,6 +2071,9 @@ static int hugetlb_sysctl_handler_common + unsigned long tmp; + int ret; + ++ if (!hugepages_supported()) ++ return -ENOTSUPP; ++ + tmp = h->max_huge_pages; + + if (write && h->order >= MAX_ORDER) +@@ -2124,6 +2127,9 @@ int hugetlb_overcommit_handler(struct ct + unsigned long tmp; + int ret; + ++ if (!hugepages_supported()) ++ return -ENOTSUPP; ++ + tmp = h->nr_overcommit_huge_pages; + + if (write && h->order >= MAX_ORDER) +@@ -2149,6 +2155,8 @@ out: + void hugetlb_report_meminfo(struct seq_file *m) + { + struct hstate *h = &default_hstate; ++ if (!hugepages_supported()) ++ return; + seq_printf(m, + "HugePages_Total: %5lu\n" + "HugePages_Free: %5lu\n" +@@ -2165,6 +2173,8 @@ void hugetlb_report_meminfo(struct seq_f + int hugetlb_report_node_meminfo(int nid, char *buf) + { + struct hstate *h = &default_hstate; ++ if (!hugepages_supported()) ++ return 0; + return sprintf(buf, + "Node %d HugePages_Total: %5u\n" + "Node %d HugePages_Free: %5u\n" +@@ -2179,6 +2189,9 @@ void hugetlb_show_meminfo(void) + struct hstate *h; + int nid; + ++ if (!hugepages_supported()) ++ return; ++ + for_each_node_state(nid, N_MEMORY) + for_each_hstate(h) + pr_info("Node %d hugepages_total=%u hugepages_free=%u hugepages_surp=%u hugepages_size=%lukB\n", diff --git a/queue-3.14/series b/queue-3.14/series index b7cecfc758a..70fd3abe568 100644 --- a/queue-3.14/series +++ b/queue-3.14/series @@ -8,3 +8,4 @@ fix-problem-recognizing-symlinks.patch init-kconfig-fix-have_futex_cmpxchg-to-not-break-up-the-expert-menu.patch ring-buffer-fix-infinite-spin-in-reading-buffer.patch cifs-fix-smb2-readdir-error-handling.patch +hugetlb-ensure-hugepage-access-is-denied-if-hugepages-are-not-supported.patch