Received: by 10.223.176.46 with SMTP id f43csp4225141wra; Tue, 23 Jan 2018 06:18:50 -0800 (PST) X-Google-Smtp-Source: AH8x225ATPnzIMAUqtvlb7q7jyqPl7qo8TBIcc0dKzBONlyingEJHU6jogNLJHfHX7batfJiS9Hg X-Received: by 2002:a17:902:2843:: with SMTP id e61-v6mr3518189plb.260.1516717130079; Tue, 23 Jan 2018 06:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516717130; cv=none; d=google.com; s=arc-20160816; b=l5B23xYtq4IEnIIWnnZr+1YYU4r7VbwIMycy01ihQ3s3BAfYt8oOIRRxtgzJw21f1C uoX/OgaeZC6gI+QV2OkfwaHrluO8EAetq2n77qal1tRr17W2HJ2lLeNnjB7Rqx/wyXMW D+L2NT4lQdiJ84Aw54SlI+ZLqgZpDzTxPjwybkyLaW2VjHCxpFGwqm9DvtEKFl2Br3Za ecpmoygCy9/BdYQmh5x/jleaWjVUaTCNpKTLcnxdK7tDxrd/EUSbY87w9WHGkl/XE/MG fkviGcdFL75+dizUmOtLxkzr7wGsH78hxLPJ8j5WVVOV2yEAvdGpp5z98XYM1HYFeEmf K/Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=BV8ObNax3FzU30i+tmGBNpRWaiFMLTiv3GDJP1vUhik=; b=qmsBe8VYNp94z+e0VVL0kwnERaV4iwyxHC/5alv+mA9Tn0+Qb2OwpeOqjAvkIc9TIY pVBxBpezfYm5DgHl0sy3vwSoDTOtgP+8INPlSmywXx0GuLoVyC9Bi9o0K5S0ZYEw00nD V8g2cKxw4KYSgZfdn/jBXFxIjHKF+beaaKSQVHeFqYGUGPp6VGWtXyZHzASk7HSxJP9X IjjBa+fbKz0t2+n7LBihaKuzPg8QoGiBpobfIZ2LCyGx33JKWBn7YIHzkROXJgZJP9sD P0ssR9Py+A3kZs2jRTkCdWJodHOP9xk0Vnuv56HaFIVkJL0VvjbrA6V0bGUFmbmWpM1j vlkg== 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 f192si15368143pgc.27.2018.01.23.06.18.33; Tue, 23 Jan 2018 06:18:50 -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 S1751795AbeAWOSE (ORCPT + 99 others); Tue, 23 Jan 2018 09:18:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:56766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751629AbeAWOSC (ORCPT ); Tue, 23 Jan 2018 09:18:02 -0500 Received: from saruman (jahogan.plus.com [212.159.75.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6AC32178B; Tue, 23 Jan 2018 14:18:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6AC32178B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jhogan@kernel.org Date: Tue, 23 Jan 2018 14:17:57 +0000 From: James Hogan To: Mathieu Malaterre Cc: Marcin Nowakowski , "# v4 . 11" , Ralf Baechle , linux-mips@linux-mips.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] MIPS: fix incorrect mem=X@Y handling Message-ID: <20180123141756.GE22211@saruman> References: <1504609608-7694-1-git-send-email-marcin.nowakowski@imgtec.com> <20171221210100.12002-1-malat@debian.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YkJPYEFdoxh/AXLE" Content-Disposition: inline In-Reply-To: <20171221210100.12002-1-malat@debian.org> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --YkJPYEFdoxh/AXLE Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 21, 2017 at 10:00:59PM +0100, Mathieu Malaterre wrote: > From: Marcin Nowakowski >=20 > Change 73fbc1eba7ff added a fix to ensure that the memory range between Please refer to commits with e.g. commit 73fbc1eba7ff ("MIPS: fix mem=3DX@Y commandline processing"). > PHYS_OFFSET and low memory address specified by mem=3D 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=3D256M@0x0 > mem=3D768M@0x30000000'). >=20 > Change the behaviour to ensure that only the range between PHYS_OFFSET > and the lowest start address of the memories is marked as protected. >=20 > 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. >=20 > Reported-by: Mathieu Malaterre > Signed-off-by: Marcin Nowakowski > Fixes: 73fbc1eba7ff ("MIPS: fix mem=3DX@Y commandline processing") > Cc: # v4.11 I'm guessing that should technically be v4.11+ > --- > v2: Use updated email adress, add tag for stable. > arch/mips/kernel/setup.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) >=20 > 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 =3D ~0UL; > unsigned long bootmap_size; > + phys_addr_t ramstart =3D ~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 =3D false; > int i; > =20 > @@ -395,6 +396,21 @@ static void __init bootmem_init(void) > max_low_pfn =3D 0; > =20 > /* > + * Reserve any memory between the start of RAM and PHYS_OFFSET > + */ > + for (i =3D 0; i < boot_mem_map.nr_map; i++) { > + if (boot_mem_map.map[i].type !=3D BOOT_MEM_RAM) > + continue; > + > + ramstart =3D 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); =2E.. 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 =3D 0; i < boot_mem_map.nr_map; i++) { > @@ -664,9 +680,6 @@ static int __init early_parse_mem(char *p) > =20 > add_memory_region(start, size, BOOT_MEM_RAM); > =20 > - if (start && start > PHYS_OFFSET) > - add_memory_region(PHYS_OFFSET, start - PHYS_OFFSET, > - BOOT_MEM_RESERVED); > return 0; > } > early_param("mem", early_parse_mem); > --=20 > 2.11.0 >=20 --YkJPYEFdoxh/AXLE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEd80NauSabkiESfLYbAtpk944dnoFAlpnRA4ACgkQbAtpk944 dnp22Q/8De+B5OeBDSwCcBMxj10ZQK8NplvIZyNvT4eo/V0myFjVitdj33gWUyAI zSeI1wPi+XwpTbc9ODPTOh9troPXCt4RQ3AjFL28A+L/fCDmsMGpKcWQeT2n4p+H 2pfN9zW4/viVyQoAKdpNYdTW5llMbxiI9n4Hu9y0UgWaSR/2tx9pNDUX2jYVuidM Vu9Ruw4TpPPoxSlGzp3KHwC281UqqNAxq/gV+SM1LW5PxRjln/ZnMlmlyX/kVauS /8qre8JgAPb3gXH1B2GJ9xAnfPK+SnpnaEqTKKzLzs71EjhDoBDuPzrUj1zdJ97q h1f9vdN6ZsuhzSGQt8y4g3RuqQtf5e+NhEdNJwuKnmJomb/5/nCPEKRWPiylH9S/ aPOS7zX0ijdEgg95X6YH/ryNLE/W4RfUl0unxq+qU7A0jWJ9CC8D2bGA0xsEqCeI 7Un0fhF5MmIxXLN2CtnUyKqjpJCr1ocvPPxX5velCja0jxWfZf5eBSFG1hOl/uMP ju/IPPQHacA9C7pGY8Xhhoh8vII2ZvpTXGT07VvZ3xgBWaBZdv0igwptxNIZpeym YaF3tTNfBwPKitpCDLvVa6Yekm3ZWSPAERpNtejtrCGW4nrTHZb3ZKMS8Vknk2XV D5anqso1+FyMhYsyeaom/CgTZQSmC59Nt44Wq2ZNW3IXhHEMEkE= =D+jJ -----END PGP SIGNATURE----- --YkJPYEFdoxh/AXLE--