Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp594654ybt; Wed, 1 Jul 2020 05:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2BR6gm1Uhhyvw/pwLYQ5v/zBygHXuYRPmLZ0SjZvg4VHhswIjCqqUL26gnpEuENC9Unfg X-Received: by 2002:a17:906:d057:: with SMTP id bo23mr9132031ejb.210.1593608080673; Wed, 01 Jul 2020 05:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593608080; cv=none; d=google.com; s=arc-20160816; b=TLjoe92Q/v2LwLiIoWH3XIm004QsBErWCrhKY1WmjwBIUyZPgMMhn2G7N8m+1R2eBa zQbSJ8mVE8ktQk888A6Icf7SP8COL+B02hvc+SvVGzcJLmajWYaxhiHMXZK4I9MgZWCb zNOP8x06CFSkX1kUSuvcfQY4vhcXMV9bdyxxaPTVgKpbT4iepGnT2nq3sbSlj795X4lI fKv6lpyIr8BMNkQW3/1UUz3gh0zKK4Z1JBTlASKd9eFcokxmkWHcQc5E2sE3PJcexEYg E51zqHX521YU3I+RR043GOHRF0zQDrmOSd2I4cJ4dfHxx0DDdBj3unlI0KNMMxfipZD9 84Pg== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=Ylks6ZC4AGq74KjZ8OmBYSrj4mT7YR7HWbuFUZxGUUk=; b=VTcMz+uI6Yiv1tWwXxwjiLcC/7wgleS+QRXV3mZoBTSwm8Av74X6ZZwnEwDzXBtGB8 Q5HnOkr5yrDMsfExfYF3Yjl8175IqxeF7JFfINC1qOZ2UIQv1Fdm7yj3DxhuQvl7WNNe JAGsmm97s03Z1bupAlXXDIto6APk1rE2vpQZo3e0KhGBTut3WmqeTw5GhaBTYCK8s2il W778EaAVoOFstn00X5GaddUsCSS4tJJ8WKYbv+9+3PnYaSsHhcRvI1PLm96Tb09vLGwf CMC7V821gFhhGzsewPh9B8yS/hXGPgTjpQqESAUQQVDRAaAno/H171PADi9/1H1w0r9o 9v2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TVHkz2HN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a20si3640117ejb.361.2020.07.01.05.54.16; Wed, 01 Jul 2020 05:54:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TVHkz2HN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730603AbgGAMxx (ORCPT + 99 others); Wed, 1 Jul 2020 08:53:53 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46131 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730520AbgGAMxx (ORCPT ); Wed, 1 Jul 2020 08:53:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593608031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ylks6ZC4AGq74KjZ8OmBYSrj4mT7YR7HWbuFUZxGUUk=; b=TVHkz2HN7N4Y7aFsvzOT9gyTcx+Js1nd1KxMZNh7OPj5LD3CqN5Zh5j3240U7hQEkFOQAV /GI2sHniWy09q131yLtdUQ0ZZazBPLcCeu8wz4UsL8mpaUA/yttOOg4GCROn7FkedV9Khp SZPZKEY16HAHXT8H5SZrKSx2c7VAR/E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-c3-vNlfMNbWRmerX0_OETA-1; Wed, 01 Jul 2020 08:53:49 -0400 X-MC-Unique: c3-vNlfMNbWRmerX0_OETA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD95DBFC1; Wed, 1 Jul 2020 12:53:47 +0000 (UTC) Received: from [10.72.8.21] (ovpn-8-21.pek2.redhat.com [10.72.8.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A72A10013C0; Wed, 1 Jul 2020 12:53:37 +0000 (UTC) Subject: Re: [PATCH 04/11] ppc64/kexec_file: avoid stomping memory used by special regions To: Dave Young , Hari Bathini References: <159319825403.16351.7253978047621755765.stgit@hbathini.in.ibm.com> <159319831192.16351.17443438699302756548.stgit@hbathini.in.ibm.com> <20200701074012.GA4496@dhcp-128-65.nay.redhat.com> Cc: Thiago Jung Bauermann , Michael Ellerman , Kexec-ml , Mahesh J Salgaonkar , Petr Tesarik , lkml , linuxppc-dev , Sourabh Jain , Vivek Goyal , Andrew Morton , Mimi Zohar , Eric Biederman From: piliu X-Enigmail-Draft-Status: N1110 Message-ID: Date: Wed, 1 Jul 2020 20:53:35 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20200701074012.GA4496@dhcp-128-65.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/01/2020 03:40 PM, Dave Young wrote: > Hi Hari, > On 06/27/20 at 12:35am, Hari Bathini wrote: >> crashkernel region could have an overlap with special memory regions >> like opal, rtas, tce-table & such. These regions are referred to as >> exclude memory ranges. Setup this ranges during image probe in order >> to avoid them while finding the buffer for different kdump segments. >> Implement kexec_locate_mem_hole_ppc64() that locates a memory hole >> accounting for these ranges. Also, override arch_kexec_add_buffer() >> to locate a memory hole & later call __kexec_add_buffer() function >> with kbuf->mem set to skip the generic locate memory hole lookup. >> >> Signed-off-by: Hari Bathini >> --- >> arch/powerpc/include/asm/crashdump-ppc64.h | 10 + >> arch/powerpc/include/asm/kexec.h | 7 - >> arch/powerpc/kexec/elf_64.c | 7 + >> arch/powerpc/kexec/file_load_64.c | 292 ++++++++++++++++++++++++++++ >> 4 files changed, 312 insertions(+), 4 deletions(-) >> create mode 100644 arch/powerpc/include/asm/crashdump-ppc64.h >> > [snip] >> /** >> + * get_exclude_memory_ranges - Get exclude memory ranges. This list includes >> + * regions like opal/rtas, tce-table, initrd, >> + * kernel, htab which should be avoided while >> + * setting up kexec load segments. >> + * @mem_ranges: Range list to add the memory ranges to. >> + * >> + * Returns 0 on success, negative errno on error. >> + */ >> +static int get_exclude_memory_ranges(struct crash_mem **mem_ranges) >> +{ >> + int ret; >> + >> + ret = add_tce_mem_ranges(mem_ranges); >> + if (ret) >> + goto out; >> + >> + ret = add_initrd_mem_range(mem_ranges); >> + if (ret) >> + goto out; >> + >> + ret = add_htab_mem_range(mem_ranges); >> + if (ret) >> + goto out; >> + >> + ret = add_kernel_mem_range(mem_ranges); >> + if (ret) >> + goto out; >> + >> + ret = add_rtas_mem_range(mem_ranges, false); >> + if (ret) >> + goto out; >> + >> + ret = add_opal_mem_range(mem_ranges, false); >> + if (ret) >> + goto out; >> + >> + ret = add_reserved_ranges(mem_ranges); >> + if (ret) >> + goto out; >> + >> + /* exclude memory ranges should be sorted for easy lookup */ >> + sort_memory_ranges(*mem_ranges); >> +out: >> + if (ret) >> + pr_err("Failed to setup exclude memory ranges\n"); >> + return ret; >> +} > > I'm confused about the "overlap with crashkernel memory", does that mean > those normal kernel used memory could be put in crashkernel reserved > memory range? If so why can't just skip those areas while crashkernel > doing the reservation? I raised the same question in another mail. As Hari's answer, "kexec -p" skips these ranges in user space. And the same logic should be done in "kexec -s -p" Regards, Pingfan