Received: by 10.223.176.5 with SMTP id f5csp1024607wra; Tue, 30 Jan 2018 23:48:40 -0800 (PST) X-Google-Smtp-Source: AH8x2247gu9UUE4L80BEtbCn3JiF28Do7Syl75h/Yyy0lc2YaQzZfFIPshX0vcCevCSchwb6/ONO X-Received: by 10.98.62.69 with SMTP id l66mr33128725pfa.20.1517384919925; Tue, 30 Jan 2018 23:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517384919; cv=none; d=google.com; s=arc-20160816; b=LAwSj3wUZG0YyOY34Z7TxJAKnxkgVNIgTB/hHtogp/OxdD5k+YigHs6ZREFT2guNUK rev/m81vuvXvlRw2CSR9sNnDcRqtwqELQVgI5sGnVmUgIBZmCH6eE/LbfW+2UmKKmsmZ 7q6r9dW4miBJEV68S2XvLUaKLeufPfaRrh0LsK5kQ8nANGg/Z4ER3BVbtP0FGBJF7DsI FnXBAW4F8tqYDFB1nNQGmUrt2lwzEKnpDpIIbeXIiFFpOTWSnDddvQjYt/78upRuXETZ Alr4CXYOZNm0u5Rgm8y/kJb7qZs1u6Jd2rAXh00Jzvq/NwUZg6ZFw3z1GLMwXih1jc5r IPpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=RR4Cyl2bqWx4SXhL+b6aXeeeDGEW+Ibrj7NyT5ep3oc=; b=0lVDHuoLp2xjmSci5I60kJi4Pu/xkq9GO+fg+9P7SZSBiIBMw++Or45RF7kduSqGm4 3C5uG9wbVptzouokG04riI0150dZRJroeQQ8k6EhnkBWGGPrN04O8Wa6k4Un+HqRF3gV 3qVzruAIEbQSSbzh9guf0ttNXNLqPlFc0uvSYoL9o4j8+hgzIe3z2zbnI+L0agxqXtrT mnoPHWsbHQleIOrsX5j/RNPTT7IaIqBvFg8eCsdOUEIC5VT0jaXfT21CCSYAp5DqBVvK lQyLkcQl+XWTg+rN2Jowp2DkbeUk0i5dMsvO5L5n6qDX8TzESqMXXTtzT1K4XvLOgnt7 mNKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Bw9NuCvc; 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 z12si10671251pgp.788.2018.01.30.23.48.24; Tue, 30 Jan 2018 23:48:39 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Bw9NuCvc; 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 S1752869AbeAaHr7 (ORCPT + 99 others); Wed, 31 Jan 2018 02:47:59 -0500 Received: from mail-vk0-f68.google.com ([209.85.213.68]:41341 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751454AbeAaHr4 (ORCPT ); Wed, 31 Jan 2018 02:47:56 -0500 Received: by mail-vk0-f68.google.com with SMTP id g186so8464285vkd.8; Tue, 30 Jan 2018 23:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=RR4Cyl2bqWx4SXhL+b6aXeeeDGEW+Ibrj7NyT5ep3oc=; b=Bw9NuCvcweO5exYheP28Y29WxQgb4/dqUIObXkwZc6L4Afz5T+sSbVnNZqYcWqcX7L V6aw4BHrCaleHm/voN6oEvVxFrjZz+0wL9bD/q+SA++ge4NfFAUZU/L1ygBDXDKCjoT1 eD6n12twOBUDuJnfo4RXqfwPvcQaT2PVN1u0ROc+iYGt+fAlyYFk8+fjDx2+F1lxNOiV L3R+HPAO4ocf8rWR5wCLaTcrVTo1ps+j48gabNH6NPJxtgBz2cWZeZq0UGu+NgucA7Du 4ecrpAchSooykueB5TtuCDTN+578fK9vY3ea6xYLLzZ76YGGS+8tfjuE7nlPKCJoWBi3 U2XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=RR4Cyl2bqWx4SXhL+b6aXeeeDGEW+Ibrj7NyT5ep3oc=; b=hegZtZLHogNESpwxP5VE1oAYRduEn9t+wK9d69o7aEyuwzrNhYKnG6HhZX982zGW3C bUd/AXngGDQXk+llKiYIE51IDeNcHUrxLticAwBp/Y8BepTGBx8luWysKyXGn35izGQO GSOtmlmFKvsXb39sIn2A2ZTMobFXFNa+mXkHhRI5laLahOK0Bi/RApsszC0Anj95aNCV ZfHmKefZn/EQ51VQ3GhUcls1KLUUc5pYfOhXpzCevcCa1KzJ3zwcUrlo/GPiDtsMDAEw kRqgglRDH2upyXmwATD/R1WBVRZYnlkHvU9bbtK4I9YiBvDTAgaRTibJ6ii7MQJP7xf0 tE3Q== X-Gm-Message-State: AKwxytdfddxgL8/zQbwK9ptCIz4MhswjIzkwF5ni/ULqu51MlcmtOGXI LcweBwnTzkJDDh3tah5M1JKCdLvE99YRWT9Tdy0fCw== X-Received: by 10.31.188.72 with SMTP id m69mr23601892vkf.86.1517384875932; Tue, 30 Jan 2018 23:47:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.78.22 with HTTP; Tue, 30 Jan 2018 23:47:35 -0800 (PST) In-Reply-To: <20180123141756.GE22211@saruman> References: <1504609608-7694-1-git-send-email-marcin.nowakowski@imgtec.com> <20171221210100.12002-1-malat@debian.org> <20180123141756.GE22211@saruman> From: Mathieu Malaterre Date: Wed, 31 Jan 2018 08:47:35 +0100 X-Google-Sender-Auth: Ov7EhWba16yjvR4p8DwQTiMpvgk Message-ID: Subject: Re: [PATCH v2] MIPS: fix incorrect mem=X@Y handling To: Marcin Nowakowski Cc: "# v4 . 11" , James Hogan , Ralf Baechle , linux-mips@linux-mips.org, linux-kernel@vger.kernel.org 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 Hi Marcin, Since it's been a week, could you confirm the patch is ok as-is or do you think some comment(s) from James should be incorporated ? On Tue, Jan 23, 2018 at 3:17 PM, James Hogan wrote: > On Thu, Dec 21, 2017 at 10:00:59PM +0100, Mathieu Malaterre wrote: >> From: Marcin Nowakowski >> >> Change 73fbc1eba7ff added a fix to ensure that the memory range between > > Please refer to commits with e.g. commit 73fbc1eba7ff ("MIPS: fix > mem=X@Y commandline processing"). > >> PHYS_OFFSET and low memory address specified by mem= cmdline argument is >> not later processed by free_all_bootmem. >> This change was incorrect for systems where the commandline specifies >> more than 1 mem argument, as it will cause all memory between >> PHYS_OFFSET and each of the memory offsets to be marked as reserved, >> which results in parts of the RAM marked as reserved (Creator CI20's >> u-boot has a default commandline argument 'mem=256M@0x0 >> mem=768M@0x30000000'). >> >> Change the behaviour to ensure that only the range between PHYS_OFFSET >> and the lowest start address of the memories is marked as protected. >> >> This change also ensures that the range is marked protected even if it's >> only defined through the devicetree and not only via commandline >> arguments. >> >> Reported-by: Mathieu Malaterre >> Signed-off-by: Marcin Nowakowski >> Fixes: 73fbc1eba7ff ("MIPS: fix mem=X@Y commandline processing") >> Cc: # v4.11 > > I'm guessing that should technically be v4.11+ My fault, if this is the only change, I can re-submit. >> --- >> v2: Use updated email adress, add tag for stable. >> arch/mips/kernel/setup.c | 19 ++++++++++++++++--- >> 1 file changed, 16 insertions(+), 3 deletions(-) >> >> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c >> index 702c678de116..f19d61224c71 100644 >> --- a/arch/mips/kernel/setup.c >> +++ b/arch/mips/kernel/setup.c >> @@ -375,6 +375,7 @@ static void __init bootmem_init(void) >> unsigned long reserved_end; >> unsigned long mapstart = ~0UL; >> unsigned long bootmap_size; >> + phys_addr_t ramstart = ~0UL; > > Although practically it might not matter, technically phys_addr_t may be > 64-bits (CONFIG_PHYS_ADDR_T_64BIT) even on a 32-bit kernels, in which > case ~0UL may not be sufficiently large. > > Maybe that should be ~(phys_addr_t)0, or perhaps (phys_addr_t)ULLONG_MAX > to match add_memory_region(). > >> bool bootmap_valid = false; >> int i; >> >> @@ -395,6 +396,21 @@ static void __init bootmem_init(void) >> max_low_pfn = 0; >> >> /* >> + * Reserve any memory between the start of RAM and PHYS_OFFSET >> + */ >> + for (i = 0; i < boot_mem_map.nr_map; i++) { >> + if (boot_mem_map.map[i].type != BOOT_MEM_RAM) >> + continue; >> + >> + ramstart = min(ramstart, boot_mem_map.map[i].addr); > > Is it worth incorporating this into the existing loop below ... > >> + } >> + >> + if (ramstart > PHYS_OFFSET) >> + add_memory_region(PHYS_OFFSET, ramstart - PHYS_OFFSET, >> + BOOT_MEM_RESERVED); > > ... and this then placed below that loop? > > Otherwise I can't find fault with this patch, though i'm not intimately > familiar with bootmem. > > Cheers > James > >> + >> + >> + /* >> * Find the highest page frame number we have available. >> */ >> for (i = 0; i < boot_mem_map.nr_map; i++) { >> @@ -664,9 +680,6 @@ static int __init early_parse_mem(char *p) >> >> add_memory_region(start, size, BOOT_MEM_RAM); >> >> - if (start && start > PHYS_OFFSET) >> - add_memory_region(PHYS_OFFSET, start - PHYS_OFFSET, >> - BOOT_MEM_RESERVED); >> return 0; >> } >> early_param("mem", early_parse_mem); >> -- >> 2.11.0 >>