Received: by 10.223.176.46 with SMTP id f43csp4199626wra; Tue, 23 Jan 2018 05:59:25 -0800 (PST) X-Google-Smtp-Source: AH8x226qnh08MELK2ThNRH6e049YfoeKLGGsoNMURn/CXW8AT0sx7N3ld5GMVBHGLiglxnnTXlxq X-Received: by 10.99.114.30 with SMTP id n30mr8705432pgc.178.1516715965450; Tue, 23 Jan 2018 05:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715965; cv=none; d=google.com; s=arc-20160816; b=TVlCghNuEj7EjHQr/mdeqFovA9QF0NAEOjJethuBREPBp0+mVfjHsWzWjrc0I28rCC BvsMIjg2VbfdOgW1Q0VRFbSE7fD8OAu5O1FjiBDtF3UTW2QOlr2hgux8266jlSIWS9RO qkDn2mUl7HVHzUTPdFcuC8ybwESLuRVeUTkC6V5GnxYzvNBXmgeYlgJXFS/iUQHJUYmW KILooSOLM22ezsQYOnmmanMJFtORemUyoqaPkjFMnfmDs93a7CZftfb7Ug40uVdWNG5e WdIaAyNhK4/1nV2UxelF7jH0ijzHmHOBGtreaFx1aTkq3pa7LdOdyfvfACJ4bXa8SD73 4RzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=uriyBFVH+0hCEJS7Hk9oRaMharEuga3AJp083i4IQYk=; b=cYmQBnRAOudc7jNlRce2oyzq5grOkc0n3s1+JgkgR6hjuSGyohUhZiLkgTtRTX8J59 1vWboWQkkEo4TiD2tcy9JPc90rVJGQNHs+9AO2Xw2P16VO0EfCuRDXM0e2TvIseIAtJe yiDdwrCZ/7tYv8ozkj6VY2fNNsBFZfvmltC9dGscGOWJIOoxAyBFiYVsofMMrOQgUsKF HrAstZ88X1IbUn63uGVjgUXHjNDLRdT0OAeBepSkc2L6S5TJaz0m7qgubnt/6sWKbic6 OKJgA4qfm61DRwyPGGSFyRgaPmzvzN9s78yZRPtzOR6Cw3O6hpSpwhPEjeIZCxhcGHDd RKFg== 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 94-v6si4790779plb.807.2018.01.23.05.59.11; Tue, 23 Jan 2018 05:59:25 -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; 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 S1751828AbeAWN6Y (ORCPT + 99 others); Tue, 23 Jan 2018 08:58:24 -0500 Received: from 9pmail.ess.barracuda.com ([64.235.154.210]:44769 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbeAWN6W (ORCPT ); Tue, 23 Jan 2018 08:58:22 -0500 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1402.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Tue, 23 Jan 2018 13:58:09 +0000 Received: from [10.150.130.83] (10.150.130.83) by MIPSMAIL01.mipstec.com (10.20.43.31) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 23 Jan 2018 05:58:09 -0800 Subject: Re: [PATCH v2] MIPS: fix incorrect mem=X@Y handling To: Mathieu Malaterre , James Hogan CC: Marcin Nowakowski , "# v4 . 11" , Ralf Baechle , , References: <1504609608-7694-1-git-send-email-marcin.nowakowski@imgtec.com> <20171221210100.12002-1-malat@debian.org> From: Matt Redfearn Message-ID: <9e00cd68-ff9a-37e1-3e38-f0e58ae4a400@mips.com> Date: Tue, 23 Jan 2018 13:58:06 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171221210100.12002-1-malat@debian.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.150.130.83] X-BESS-ID: 1516715889-321458-4594-39390-1 X-BESS-VER: 2017.17-r1801171719 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.20 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.189273 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.20 PR0N_SUBJECT META: Subject has letters around special characters (pr0n) X-BESS-Outbound-Spam-Status: SCORE=0.20 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, PR0N_SUBJECT X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On 21/12/17 21:00, Mathieu Malaterre wrote: > From: Marcin Nowakowski > > Change 73fbc1eba7ff added a fix to ensure that the memory range between > 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 Tested on: Creator Ci20 Creator Ci40 MIPS Boston UTM8 (Cavium Octeon III) It certainly fixes the ci20 when it's factory default command line args of "mem=256M@0x0 mem=768M@0x30000000" are passed. Though those arguments appear redundant since without them both memory regions are detected through device tree instead, and there is no problem. Tested-by: Matt Redfearn > --- > 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; > 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); > + } > + > + if (ramstart > PHYS_OFFSET) > + add_memory_region(PHYS_OFFSET, ramstart - PHYS_OFFSET, > + BOOT_MEM_RESERVED); > + > + > + /* > * 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); >