From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751228AbdAaJMB (ORCPT ); Tue, 31 Jan 2017 04:12:01 -0500 Received: from ozlabs.org ([103.22.144.67]:54249 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750906AbdAaJLq (ORCPT ); Tue, 31 Jan 2017 04:11:46 -0500 From: Michael Ellerman To: Rui Teng , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: "Aneesh Kumar K.V" , Boqun Feng , jia he , Rui Teng Subject: Re: [PATCH] powerpc/mm: fix a hardcode on memory boundary checking In-Reply-To: <20170112090906.17864-1-rui.teng@linux.vnet.ibm.com> References: <20170112090906.17864-1-rui.teng@linux.vnet.ibm.com> User-Agent: Notmuch/0.21 (https://notmuchmail.org) Date: Tue, 31 Jan 2017 20:11:41 +1100 Message-ID: <877f5bvbjm.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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