Received: by 10.213.65.68 with SMTP id h4csp1767699imn; Mon, 19 Mar 2018 12:42:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELuvLiIsjHlNhEz36rLvDiNizNFcHYKtSrOP/UCrfW9VAII/TiVp9HNCs5RachsI9ZVlZEVU X-Received: by 2002:a17:902:8607:: with SMTP id f7-v6mr9862218plo.11.1521488564633; Mon, 19 Mar 2018 12:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521488564; cv=none; d=google.com; s=arc-20160816; b=j9UPBH5DAKtTjoG0uFRu9KnK5pRuyyD5kpiFk0Q4SfABs4nu1EwgDymflsdHN1PcEj gs8d+vb4y8/WEldAVa8P7Tw6Z/7wVxREP5R3qEwJX22Aabh+L8th1yP2JiLwqrPov2Ws fuzOjnwu4WJ9jxrDWMZgbmkwudhjS38/mxyF3NaPv7bAyekGoCCFmNWyVUCGKzn1pBgD Zbt0HZkVbNk2I44MMTJb9eSx3mCs6N+u3DxYyM0fmUUzV0QC+S82F/fdg28HsDecC0Yj ALLpYc/fatpWGip7QrB+QE1ULeJxm0S5aBwykBvFnZJWdJLLDGH3w2+Muhy2nknEGVl4 ctYw== 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=DuihOIiSaJLsvCUk5iEGIzI8KEgnnBhkTuwYIJ/cA7E=; b=p7DDqFtGTtivT0+up11BpWYtKtFEn/3Ox9QnU2xykIG4oNFo+yLvuNAX3VYGf+HLGy fvWPI5EjfrLueMVNJmY4uOYXjA2n2HD+qzmBjQytD3Kn7gD95RTb7LCq0V09AwtxnGrv S2zjCsoU3AX5PA4sqlY0n4arlAX31hJTUQ2zx1q/CRFO26Ce9U3u85nfKuQVSFZXUCga 1oQKkS/kHAtJRzDLs+uko3OtoOeRLDq8gd6c2ApRWHnQCobsM3eZHZkm6owksNKuiUoa wobGX7cLXjDD3qvON4iCf1McktM/TsXdHe408tx0AbSCFAGQ7TNSyJGZQx0mj1OwLLAy UfIA== 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 v1si479861pfc.5.2018.03.19.12.42.28; Mon, 19 Mar 2018 12:42:44 -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 S1031167AbeCSSV4 (ORCPT + 99 others); Mon, 19 Mar 2018 14:21:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48244 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030442AbeCSSVo (ORCPT ); Mon, 19 Mar 2018 14:21:44 -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 61B9B1279; Mon, 19 Mar 2018 18:21:43 +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.9 086/241] powerpc/mm/hugetlb: Filter out hugepage size not supported by page table layout Date: Mon, 19 Mar 2018 19:05:51 +0100 Message-Id: <20180319180754.771365592@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-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 @@ -765,6 +765,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 */