Received: by 10.213.65.68 with SMTP id h4csp1790804imn; Mon, 19 Mar 2018 13:21:15 -0700 (PDT) X-Google-Smtp-Source: AG47ELs56cN+B11HubvYEQpFOnay0aK8bHd7cCl5d0OBYXkBFoKDVO2GdZMXqTpgkMdag+4hIdEf X-Received: by 10.98.52.133 with SMTP id b127mr11428770pfa.17.1521490875199; Mon, 19 Mar 2018 13:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521490875; cv=none; d=google.com; s=arc-20160816; b=X9G+1A4a6s9m1og2T3pM+RJGlAjh3zb52iHgsK3Y8O/hcdNbYBjC1vXyEc5U1HYHvr hiZtuEROlRa3QcP8fwyx42+PYYfdH8gJSXBJv+sAgQOB27SdyU8WouK40jzjViw8Snc4 dqeoVrSG/CiERUhYQ5SaBIOkVlE5+Jgo/ibCtlzc/o8khUm9yh4NM/2Umw232IB9n50f QTSTRA7TW4m1Idy0eAtL98ISc5He6Q80LpBqrQGm/nOzj2Im8iFtgu9QFa78ZuWMq+px t4sobxjsjb7a/mrPzdbiW1mbAPQ/TZnsYHplbK+0+0YNbuzF+/HjZsWchVVQzZ2cb0II t08w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aYRB68j0bwXjR+qU4/FS5nJBXk0j6alxvi3x5StNJKc=; b=hiU0PYMREuYYAkMk+Z3h5Tl6RsnCXbp1MJWpj9sYleSe9GCEI2Cv5Hq62e9MdmqAyQ 9gVoU06AVsh7TxEDvEjR0hUNUsH4t84tnVXlSwVjKwHg4tf8nfXKeS9yxBQOWSrsKQ+G U52VBfoQrwyjJhLbguwJtwIj9v7U/UWFBiUACuo4vgmJPWYi9nY0a8X1GPZc5v5Ys69r 2DMP/WWX3VNyR4R3Hm3SQ/AGZitxQzOPRhqPS0ml8Z4umHtZImik1tZ7EPUg5IeTDjiL dTbB9rX1ZLDBtzdXTKpe1SvbiJquBVTDGwC6jgiRdatkCORKp+ZOat7WLais6pa3N7sy /5WQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si3357pgt.480.2018.03.19.13.20.58; Mon, 19 Mar 2018 13:21:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030764AbeCSSPN (ORCPT + 99 others); Mon, 19 Mar 2018 14:15:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44456 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030736AbeCSSPE (ORCPT ); Mon, 19 Mar 2018 14:15:04 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 734C2F88; Mon, 19 Mar 2018 18:15:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Aneesh Kumar K.V" , Michael Ellerman , Sasha Levin Subject: [PATCH 4.4 041/134] powerpc/mm/hugetlb: Filter out hugepage size not supported by page table layout Date: Mon, 19 Mar 2018 19:05:24 +0100 Message-Id: <20180319171855.295206021@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Aneesh Kumar K.V" [ Upstream commit a525108cf1cc14651602d678da38fa627a76a724 ] Without this if firmware reports 1MB page size support we will crash trying to use 1MB as hugetlb page size. echo 300 > /sys/kernel/mm/hugepages/hugepages-1024kB/nr_hugepages kernel BUG at ./arch/powerpc/include/asm/hugetlb.h:19! ..... .... [c0000000e2c27b30] c00000000029dae8 .hugetlb_fault+0x638/0xda0 [c0000000e2c27c30] c00000000026fb64 .handle_mm_fault+0x844/0x1d70 [c0000000e2c27d70] c00000000004805c .do_page_fault+0x3dc/0x7c0 [c0000000e2c27e30] c00000000000ac98 handle_page_fault+0x10/0x30 With fix, we don't enable 1MB as hugepage size. bash-4.2# cd /sys/kernel/mm/hugepages/ bash-4.2# ls hugepages-16384kB hugepages-16777216kB Signed-off-by: Aneesh Kumar K.V Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/mm/hugetlbpage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -828,6 +828,24 @@ static int __init add_huge_page_size(uns if ((mmu_psize = shift_to_mmu_psize(shift)) < 0) return -EINVAL; +#ifdef CONFIG_PPC_BOOK3S_64 + /* + * We need to make sure that for different page sizes reported by + * firmware we only add hugetlb support for page sizes that can be + * supported by linux page table layout. + * For now we have + * Radix: 2M + * Hash: 16M and 16G + */ + if (radix_enabled()) { + if (mmu_psize != MMU_PAGE_2M) + return -EINVAL; + } else { + if (mmu_psize != MMU_PAGE_16M && mmu_psize != MMU_PAGE_16G) + return -EINVAL; + } +#endif + BUG_ON(mmu_psize_defs[mmu_psize].shift != shift); /* Return if huge page size has already been setup */