From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5656DC10F11 for ; Mon, 15 Apr 2019 04:55:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22A9120825 for ; Mon, 15 Apr 2019 04:55:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hEALdW5x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22A9120825 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-Id:In-Reply-To:MIME-Version: References:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LlYEnUIh8Cx2DcRebXsOcwHL6vY45xir50+5TAEoqLk=; b=hEALdW5x3jZLsX XZC82PyAwIXohvcTwtYfpSjxcg7zPPqEn18kGKYG6aiF/v/GyOYxPL6awvcDLnvUAa/nh6dJTxJik CDifHIBD2fHFFiCq8zj5/s+BXeLjZlRo9Fz2eNPv7FnlWxP4IDy7klNkvKgT9mBJQlqcCLnEUOOfd c+mEWEwedR72+fAn7uWWQ4EuVCU8S1fHysUjGE7Q6diwRsiEUvlqyW3hii38DxjyRn6LSvOUoaWT6 IG21zrHX5NqjznIfJEXdLA5udjs2EhBJoS9ZYm4RasdU38eZFX/y3c4sexUV04oEQ3osWCs8gv2SB eQO9YmT/w7laaJixr2Ww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFteZ-0001en-VU; Mon, 15 Apr 2019 04:55:35 +0000 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFteW-0001dg-M9 for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2019 04:55:34 +0000 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3F4nOWR076831 for ; Mon, 15 Apr 2019 00:55:30 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rv85tpbwc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 15 Apr 2019 00:55:30 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Apr 2019 05:55:27 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 15 Apr 2019 05:55:22 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3F4tL3b52428994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Apr 2019 04:55:21 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EB54A4051; Mon, 15 Apr 2019 04:55:21 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F64AA4057; Mon, 15 Apr 2019 04:55:20 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.112]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 15 Apr 2019 04:55:20 +0000 (GMT) Date: Mon, 15 Apr 2019 07:55:18 +0300 From: Mike Rapoport To: Chen Zhou Subject: Re: [PATCH v3 3/4] arm64: kdump: support more than one crash kernel regions References: <20190409102819.121335-1-chenzhou10@huawei.com> <20190409102819.121335-4-chenzhou10@huawei.com> <20190414121315.GD20947@rapoport-lnx> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19041504-0028-0000-0000-00000360CBC8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19041504-0029-0000-0000-0000241FFD0A Message-Id: <20190415045518.GA6167@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-15_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904150032 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190414_215532_830513_681353BB X-CRM114-Status: GOOD ( 34.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wangkefeng.wang@huawei.com, horms@verge.net.au, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, takahiro.akashi@linaro.org, mingo@redhat.com, bp@alien8.de, ebiederm@xmission.com, kexec@lists.infradead.org, tglx@linutronix.de, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 15, 2019 at 10:27:30AM +0800, Chen Zhou wrote: > Hi Mike, > > On 2019/4/14 20:13, Mike Rapoport wrote: > > Hi, > > > > On Tue, Apr 09, 2019 at 06:28:18PM +0800, Chen Zhou wrote: > >> After commit (arm64: kdump: support reserving crashkernel above 4G), > >> there may be two crash kernel regions, one is below 4G, the other is > >> above 4G. > >> > >> Crash dump kernel reads more than one crash kernel regions via a dtb > >> property under node /chosen, > >> linux,usable-memory-range = > > > > Somehow I've missed that previously, but how is this supposed to work on > > EFI systems? > > Whatever the way in which the systems work, there is FDT pointer(__fdt_pointer) > in arm64 kernel and file /sys/firmware/fdt will be created in late_initcall. > > Kexec-tools read and update file /sys/firmware/fdt in EFI systems to support kdump to > boot capture kernel. > > For supporting more than one crash kernel regions, kexec-tools make changes accordingly. > Details are in below: > http://lists.infradead.org/pipermail/kexec/2019-April/022792.html Thanks for the clarification! > Thanks, > Chen Zhou > > > > >> Signed-off-by: Chen Zhou > >> --- > >> arch/arm64/mm/init.c | 66 ++++++++++++++++++++++++++++++++++++++++-------- > >> include/linux/memblock.h | 6 +++++ > >> mm/memblock.c | 7 ++--- > >> 3 files changed, 66 insertions(+), 13 deletions(-) > >> > >> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > >> index 3bebddf..0f18665 100644 > >> --- a/arch/arm64/mm/init.c > >> +++ b/arch/arm64/mm/init.c > >> @@ -65,6 +65,11 @@ phys_addr_t arm64_dma_phys_limit __ro_after_init; > >> > >> #ifdef CONFIG_KEXEC_CORE > >> > >> +/* at most two crash kernel regions, low_region and high_region */ > >> +#define CRASH_MAX_USABLE_RANGES 2 > >> +#define LOW_REGION_IDX 0 > >> +#define HIGH_REGION_IDX 1 > >> + > >> /* > >> * reserve_crashkernel() - reserves memory for crash kernel > >> * > >> @@ -297,8 +302,8 @@ static int __init early_init_dt_scan_usablemem(unsigned long node, > >> const char *uname, int depth, void *data) > >> { > >> struct memblock_region *usablemem = data; > >> - const __be32 *reg; > >> - int len; > >> + const __be32 *reg, *endp; > >> + int len, nr = 0; > >> > >> if (depth != 1 || strcmp(uname, "chosen") != 0) > >> return 0; > >> @@ -307,22 +312,63 @@ static int __init early_init_dt_scan_usablemem(unsigned long node, > >> if (!reg || (len < (dt_root_addr_cells + dt_root_size_cells))) > >> return 1; > >> > >> - usablemem->base = dt_mem_next_cell(dt_root_addr_cells, ®); > >> - usablemem->size = dt_mem_next_cell(dt_root_size_cells, ®); > >> + endp = reg + (len / sizeof(__be32)); > >> + while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { > >> + usablemem[nr].base = dt_mem_next_cell(dt_root_addr_cells, ®); > >> + usablemem[nr].size = dt_mem_next_cell(dt_root_size_cells, ®); > >> + > >> + if (++nr >= CRASH_MAX_USABLE_RANGES) > >> + break; > >> + } > >> > >> return 1; > >> } > >> > >> static void __init fdt_enforce_memory_region(void) > >> { > >> - struct memblock_region reg = { > >> - .size = 0, > >> - }; > >> + int i, cnt = 0; > >> + struct memblock_region regs[CRASH_MAX_USABLE_RANGES]; > >> + > >> + memset(regs, 0, sizeof(regs)); > >> + of_scan_flat_dt(early_init_dt_scan_usablemem, regs); > >> + > >> + for (i = 0; i < CRASH_MAX_USABLE_RANGES; i++) > >> + if (regs[i].size) > >> + cnt++; > >> + else > >> + break; > >> + > >> + if (cnt - 1 == LOW_REGION_IDX) > >> + memblock_cap_memory_range(regs[LOW_REGION_IDX].base, > >> + regs[LOW_REGION_IDX].size); > >> + else if (cnt - 1 == HIGH_REGION_IDX) { > >> + /* > >> + * Two crash kernel regions, cap the memory range > >> + * [regs[LOW_REGION_IDX].base, regs[HIGH_REGION_IDX].end] > >> + * and then remove the memory range in the middle. > >> + */ > >> + int start_rgn, end_rgn, i, ret; > >> + phys_addr_t mid_base, mid_size; > >> + > >> + mid_base = regs[LOW_REGION_IDX].base + regs[LOW_REGION_IDX].size; > >> + mid_size = regs[HIGH_REGION_IDX].base - mid_base; > >> + ret = memblock_isolate_range(&memblock.memory, mid_base, > >> + mid_size, &start_rgn, &end_rgn); > >> > >> - of_scan_flat_dt(early_init_dt_scan_usablemem, ®); > >> + if (ret) > >> + return; > >> > >> - if (reg.size) > >> - memblock_cap_memory_range(reg.base, reg.size); > >> + memblock_cap_memory_range(regs[LOW_REGION_IDX].base, > >> + regs[HIGH_REGION_IDX].base - > >> + regs[LOW_REGION_IDX].base + > >> + regs[HIGH_REGION_IDX].size); > >> + for (i = end_rgn - 1; i >= start_rgn; i--) { > >> + if (!memblock_is_nomap(&memblock.memory.regions[i])) > >> + memblock_remove_region(&memblock.memory, i); > >> + } > >> + memblock_remove_range(&memblock.reserved, mid_base, > >> + mid_base + mid_size); > >> + } > >> } > >> > >> void __init arm64_memblock_init(void) > >> diff --git a/include/linux/memblock.h b/include/linux/memblock.h > >> index 294d5d8..787d252 100644 > >> --- a/include/linux/memblock.h > >> +++ b/include/linux/memblock.h > >> @@ -110,9 +110,15 @@ void memblock_discard(void); > >> > >> phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, > >> phys_addr_t size, phys_addr_t align); > >> +void memblock_remove_region(struct memblock_type *type, unsigned long r); > >> void memblock_allow_resize(void); > >> int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid); > >> int memblock_add(phys_addr_t base, phys_addr_t size); > >> +int memblock_isolate_range(struct memblock_type *type, > >> + phys_addr_t base, phys_addr_t size, > >> + int *start_rgn, int *end_rgn); > >> +int memblock_remove_range(struct memblock_type *type, > >> + phys_addr_t base, phys_addr_t size); > >> int memblock_remove(phys_addr_t base, phys_addr_t size); > >> int memblock_free(phys_addr_t base, phys_addr_t size); > >> int memblock_reserve(phys_addr_t base, phys_addr_t size); > >> diff --git a/mm/memblock.c b/mm/memblock.c > >> index e7665cf..1846e2d 100644 > >> --- a/mm/memblock.c > >> +++ b/mm/memblock.c > >> @@ -357,7 +357,8 @@ phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start, > >> return ret; > >> } > >> > >> -static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r) > >> +void __init_memblock memblock_remove_region(struct memblock_type *type, > >> + unsigned long r) > >> { > >> type->total_size -= type->regions[r].size; > >> memmove(&type->regions[r], &type->regions[r + 1], > >> @@ -724,7 +725,7 @@ int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size) > >> * Return: > >> * 0 on success, -errno on failure. > >> */ > >> -static int __init_memblock memblock_isolate_range(struct memblock_type *type, > >> +int __init_memblock memblock_isolate_range(struct memblock_type *type, > >> phys_addr_t base, phys_addr_t size, > >> int *start_rgn, int *end_rgn) > >> { > >> @@ -784,7 +785,7 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type, > >> return 0; > >> } > >> > >> -static int __init_memblock memblock_remove_range(struct memblock_type *type, > >> +int __init_memblock memblock_remove_range(struct memblock_type *type, > >> phys_addr_t base, phys_addr_t size) > >> { > >> int start_rgn, end_rgn; > >> -- > >> 2.7.4 > >> > > > -- Sincerely yours, Mike. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel