Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1412016ybt; Thu, 2 Jul 2020 04:56:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/H6r8pZC3SGsNoSPzmEDY069f+4wyLrBKYNve1GCg5yLsU8l7REIz3h7jC2svND+qVsAg X-Received: by 2002:aa7:c305:: with SMTP id l5mr28973142edq.163.1593690998461; Thu, 02 Jul 2020 04:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593690998; cv=none; d=google.com; s=arc-20160816; b=Nnd5g3AIU121M6EvrtFMN2TTOwXzuE1otAykA0jtv2V51gKtFk6WTw8gAqq6UOIRW+ 9G7F0tYBpN1FCnPoqOzbQo8rT3Jpxe3ORESMmX3iSAT6k7Z+cZyXbJYnOW5eLe8oq4Bo 2oL80LSz7vStvM9F7f6YxUl+ZaDbzh7PjbuZesINILYASkSscMEu2smA3U4JWn38gquI q13VDbK7YJDu3d8PP1U9LNo8kSY2p5/SlORBs5U1BvhQNAAlNhsGfftn0OK1UYo3WQ+2 nYDf/tLe9Jvqkr4WtDi8Z484vuq+72HZMZnH79dMO78eQXM+FGc82OaULMt4OqyEE5kn lAIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8JPhHiGcfmRUjF2RngOoA4i4u5ZYB74t5T3BzZF3YsY=; b=Cu5Y49T0uNLpaaBKjbdEL8JIV3LUim3yffBku4dVriFvsmnt97EssoHpLiCvqttM3S Yxwwrf6TKSapwckJ3fxaV4u10kGLMk7bQuX+8NLwL3DUXc/eDyODzoMVc4nGpLE+Q8vU 7tE8iu1phLyOjXju3pTTfQ/Fsc2Fgao9zJ7v85d6b8kLSbG4gVbrQ0PolOX9Xo6UUJa+ d7sAeKDu79CLcjqkT0NrDHnQexIYahW8HB2gOOBQW4viiwTA4bFo1Uelv4oGL60tMzi+ +w6CPKv+hdtofs6pB/0yi3C0xVwM8sbR+X5C1iOsx+3Z2XqlTspMN+bGsbFZg9wByjWe ZkUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RYIi0Nhc; 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 c25si5864185ejb.6.2020.07.02.04.56.15; Thu, 02 Jul 2020 04:56:38 -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=RYIi0Nhc; 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 S1728719AbgGBLzT (ORCPT + 99 others); Thu, 2 Jul 2020 07:55:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54870 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726475AbgGBLzT (ORCPT ); Thu, 2 Jul 2020 07:55:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593690917; 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: in-reply-to:in-reply-to:references:references; bh=8JPhHiGcfmRUjF2RngOoA4i4u5ZYB74t5T3BzZF3YsY=; b=RYIi0NhcbN4LVHJ9wBLsv3qmaPyUomD5Yd5VdJUtX+ZBI1dYUV8kGYltV2otNxu1l3SUf+ Ib8B/ihI4elXUCn4J1cMQhRt9e3KkM/njB1bIXXTAH/r1OVB64Hx5zCoVK+c0zQVHgDT+g lKWW4j+TeqdMpJM8ZQpWPlYI+Z2OsUE= 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-229-BA7ob32uNSm1XA_QXqBcFg-1; Thu, 02 Jul 2020 07:55:12 -0400 X-MC-Unique: BA7ob32uNSm1XA_QXqBcFg-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 02CC719200CF; Thu, 2 Jul 2020 11:55:03 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-13-96.pek2.redhat.com [10.72.13.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E08F10027B5; Thu, 2 Jul 2020 11:54:57 +0000 (UTC) Date: Thu, 2 Jul 2020 19:54:54 +0800 From: Dave Young To: Hari Bathini Cc: Pingfan Liu , Kexec-ml , Petr Tesarik , lkml , Sourabh Jain , Mahesh J Salgaonkar , linuxppc-dev , Vivek Goyal , Andrew Morton , Mimi Zohar , Thiago Jung Bauermann , Eric Biederman Subject: Re: [PATCH 04/11] ppc64/kexec_file: avoid stomping memory used by special regions Message-ID: <20200702115454.GB21026@dhcp-128-65.nay.redhat.com> 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> <6e96ae5a-91fd-726e-1eda-314f2317d8b4@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6e96ae5a-91fd-726e-1eda-314f2317d8b4@linux.ibm.com> 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/20 at 11:48pm, Hari Bathini wrote: > > > On 01/07/20 1:10 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 > > There are regions that could overlap with crashkernel region but they are > not normal kernel used memory though. These are regions that kernel and/or > f/w chose to place at a particular address for real mode accessibility > and/or memory layout between kernel & f/w kind of thing. > > > memory range? If so why can't just skip those areas while crashkernel > > doing the reservation? > > crashkernel region has a dependency to be in the first memory block for it > to be accessible in real mode. Accommodating this requirement while addressing > other requirements would mean something like what we have now. A list of > possible special memory regions in crashkernel region to take care of. > > I have plans to split crashkernel region into low & high to have exclusive > regions for crashkernel, even if that means to have two of them. But that > is for another day with its own set of complexities to deal with... Ok, I was not aware the powerpc crashkernel reservation is not dynamically reserved. But seems powerpc need those tricks at least for the time being like you said. Thanks Dave