From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753315AbdBFCua (ORCPT ); Sun, 5 Feb 2017 21:50:30 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56435 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753193AbdBFCu1 (ORCPT ); Sun, 5 Feb 2017 21:50:27 -0500 Subject: Re: [PATCH] powerpc/mm: fix a hardcode on memory boundary checking To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20170112090906.17864-1-rui.teng@linux.vnet.ibm.com> <877f5bvbjm.fsf@concordia.ellerman.id.au> Cc: "Aneesh Kumar K.V" , Boqun Feng , jia he From: Rui Teng Date: Mon, 6 Feb 2017 10:50:21 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <877f5bvbjm.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020602-0056-0000-0000-000002AE621E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006564; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000201; SDB=6.00817784; UDB=6.00399553; IPR=6.00595243; BA=6.00005115; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014191; XFM=3.00000011; UTC=2017-02-06 02:50:20 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020602-0057-0000-0000-000006E36B84 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-06_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702060026 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31/01/2017 5:11 PM, Michael Ellerman wrote: > Rui Teng writes: > >> The offset of hugepage block will not be 16G, if the expected >> page is more than one. Calculate the totol size instead of the >> hardcode value. > > I assume you found this by code inspection and not by triggering an > actual bug? Yes, I found this problem only by code inspection. We were finding the ways to enable 16G huge page besides changing the device tree. For example, provide a new interface to set these size and pages parameters. So that I think it may cause problem here. > > cheers > >> diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c >> index 8033493..b829f8e 100644 >> --- a/arch/powerpc/mm/hash_utils_64.c >> +++ b/arch/powerpc/mm/hash_utils_64.c >> @@ -506,7 +506,7 @@ static int __init htab_dt_scan_hugepage_blocks(unsigned long node, >> printk(KERN_INFO "Huge page(16GB) memory: " >> "addr = 0x%lX size = 0x%lX pages = %d\n", >> phys_addr, block_size, expected_pages); >> - if (phys_addr + (16 * GB) <= memblock_end_of_DRAM()) { >> + if (phys_addr + block_size * expected_pages <= memblock_end_of_DRAM()) { >> memblock_reserve(phys_addr, block_size * expected_pages); >> add_gpage(phys_addr, block_size, expected_pages); >> } >> -- >> 2.9.0 >