From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-800753-1517407419-2-12425125697035725033 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.001, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='com', MailFrom='org', XOriginatingCountry='UNK' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1517407419; b=cP0u/DafViDeyOIPkPa5fBtM/lCoiZ0/B9Wmo2bbgKauTqz lJFwX/gpdcIa5RyQ+az5KNTcyqEjTWzXRoJYY4B1IDBosFMFjz+vvhEfFmzT8DSN /RLHosKiEun8loqwP7ZOqgCte6mx0UbsQtRXoqfLG3YOOhUNoMEtVIB9jsbmsmUR tvQF0VYOH70JNPz3JlQk3gwPxi4r1eLNOIHx32FT8+P2JEAu9DOESR74EFowaWw4 DWxag79QsCW3rSqUTAC7nCsleHiHehDHSjGcVtOayEzSOdfGgLSoW9nXOR7/+yyG 0rZ5+4+VaqglVMzcp8WkBVOiKkLTG+/x0LeFnqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:to:cc:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1517407419; bh=DUK2ceMGU9BfjwT+MhIPhwd9W1jGDMYY1uWZFnvsSWc=; b=Y YJlAEnPBPz0Vk4fNnu1WUpOTcb5np0w0FnWH5kOs+wczlANWSInz2/8Th85b4qRG ffZWXhvoF7MueeQ1Wo6GJKGA2WUfKcHE94BaAk9IA8+zaTbICkvXZNvMezBY7F1j lXjr9yLWWNG6tk3gZAaWbA6g+1dUBLZcoBO+KoCWfPyl7piGunE6rHWX10kl0nu+ +UF7Fla6tlwKnzYpXeDWcns+jFHPjIvZTbztGVYXbbw057tTw4tcCwU9khcLsRnH huG93F3uRxdS1EAkfx8pMSFz6Jr+zzSYyy5ae2iWM2lq1fbwm8CA8+NO3rG2gJPU D61zYU688z5+jEXlFQbVw== ARC-Authentication-Results: i=1; mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=mips.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=mips.com header.result=pass header_is_org_domain=yes Authentication-Results: mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=mips.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=mips.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752404AbeAaODg (ORCPT ); Wed, 31 Jan 2018 09:03:36 -0500 Received: from 9pmail.ess.barracuda.com ([64.235.154.211]:40568 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751842AbeAaODf (ORCPT ); Wed, 31 Jan 2018 09:03:35 -0500 Subject: Re: [PATCH v2] MIPS: fix incorrect mem=X@Y handling To: Mathieu Malaterre CC: "# v4 . 11" , James Hogan , Ralf Baechle , , References: <1504609608-7694-1-git-send-email-marcin.nowakowski@imgtec.com> <20171221210100.12002-1-malat@debian.org> <20180123141756.GE22211@saruman> From: Marcin Nowakowski Message-ID: <63726aa5-543d-8297-2e63-f767a3ba6be1@mips.com> Date: Wed, 31 Jan 2018 14:58:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.159.182] X-BESS-ID: 1517407400-452059-5836-145013-1 X-BESS-VER: 2018.1.1-r1801291958 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.189550 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: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Hi Mathieu, On 31.01.2018 08:47, Mathieu Malaterre wrote: > 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 ? I'll prepare an updated patch that includes James' suggestions - I think they will lead to an overall cleaner (and probably slightly smaller) code. Marcin > 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 >>>