Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1751510ybt; Sat, 27 Jun 2020 19:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuCV1bApFLhZ6vbRmimoDbBVj7ft0C6lBliUCmAjoLFwIPn6kCEeh7gCkx9apoSdAgndfq X-Received: by 2002:a17:906:2851:: with SMTP id s17mr8467356ejc.347.1593311400443; Sat, 27 Jun 2020 19:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593311400; cv=none; d=google.com; s=arc-20160816; b=HIh3+6e6xzPEyx+Yi7W/fPMsxTvJa6GdqQ60HqZv0xlgwhLWUbkp0aXjaG6NuVxB8T q5L3gKFUOrZuNEMKtssDTgyrEXmyb34HPh02EDwUMlHKTrEpDhgjulKmkM4MsPKxA0Uh x26RnNfm0KX2c9WpQLMsChv7ejb31m3ojba8z5sb2UcNXBkXPnke7eCmnQvNMdR/Qu3b ImIZFHNc7MI/jPy8f6zdyqRyhwMRyzADb8Aj+JqjK+HOJZuhBF/ZynQmAo677UatZqEe X/26+t7/emlZsqLWMUZocUHAflfRG0XbauKXoD/rRDukDzn1A0smCnJUKvItqmh2UwgQ Vvew== 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=5ZFRO/u+x4EdsO5u8emjhqCb2/M7dbDUc3NXXTSf+Fs=; b=C2TY39BsKsyG0AIBH6AUnyAYlIVJd46hNH12LuSxY9LTaFmLB5Ms1MrAEgq9Riq3g5 A2e/KE7DsVSIX9DPyuUwqwD7Vxd3C4c2n07VdrdaWuYfk/PsnLaH7sPUyifTqjIbbuty BRvVYpVUcYR2bhFN7DHWqSUkj0nezddKumfhjp+LWpH8YjWpalK3cq84YJM6o4Av/fAq PGPmdfjhObV/Ubm6RsNU3pM6KYGNiYN5curcvffbA/JCsJv7THEgnSWnNW4YiLvJlWEU 43Pabv8mR6szE2BgW/pi4BiB9S3L5vxFnsGNI/XVvf2/lViD+MxsiF+6FIlP3EfgqXwG ZztA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J8SOs+gS; 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 3si9888007ejz.337.2020.06.27.19.29.25; Sat, 27 Jun 2020 19:30:00 -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=J8SOs+gS; 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 S1725937AbgF1C2h (ORCPT + 99 others); Sat, 27 Jun 2020 22:28:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:34910 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725866AbgF1C2g (ORCPT ); Sat, 27 Jun 2020 22:28:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593311314; 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=5ZFRO/u+x4EdsO5u8emjhqCb2/M7dbDUc3NXXTSf+Fs=; b=J8SOs+gSM+bnRPSvmC+aBF7mTKPemUU65QN7KpSjyjXAhTI6zUuaWVHjvBsIqXVVINVd1j 53tBfXAlEUK/kGSMxMIxADs8POHxs39pZr5viJnozeS5IBSAvLC9loVL9jm8Idq5Qd3D8W 1fzFY6m0HBuj/PcQ07VKxJf0NcZmIdo= 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-416-vtl253alMKOLKF33rfYbEg-1; Sat, 27 Jun 2020 22:28:30 -0400 X-MC-Unique: vtl253alMKOLKF33rfYbEg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8343A804002; Sun, 28 Jun 2020 02:28:27 +0000 (UTC) Received: from [10.72.8.17] (ovpn-8-17.pek2.redhat.com [10.72.8.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 768C71C94D; Sun, 28 Jun 2020 02:28:18 +0000 (UTC) Subject: Re: [PATCH 01/11] kexec_file: allow archs to handle special regions while locating memory hole To: Hari Bathini , Michael Ellerman , Andrew Morton References: <159319825403.16351.7253978047621755765.stgit@hbathini.in.ibm.com> <159319828304.16351.6990340111766605842.stgit@hbathini.in.ibm.com> Cc: Kexec-ml , Petr Tesarik , Mahesh J Salgaonkar , Sourabh Jain , lkml , linuxppc-dev , Mimi Zohar , Vivek Goyal , Dave Young , Thiago Jung Bauermann , Eric Biederman From: piliu Message-ID: Date: Sun, 28 Jun 2020 10:28:15 +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: <159319828304.16351.6990340111766605842.stgit@hbathini.in.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hari, If in [4/11], get_exclude_memory_ranges() turns out to be unnecessary ,then this patch is abundant either. As my understanding, memblock has already helped to achieved the purpose that get_exclude_memory_ranges() wants. Thanks, Pingfan On 06/27/2020 03:04 AM, Hari Bathini wrote: > Some archs can have special memory regions, within the given memory > range, which can't be used for the buffer in a kexec segment. As > kexec_add_buffer() function is being called from generic code as well, > add weak arch_kexec_add_buffer definition for archs to override & take > care of special regions before trying to locate a memory hole. > > Signed-off-by: Hari Bathini > --- > include/linux/kexec.h | 5 +++++ > kernel/kexec_file.c | 37 +++++++++++++++++++++++++++++++++---- > 2 files changed, 38 insertions(+), 4 deletions(-) > > diff --git a/include/linux/kexec.h b/include/linux/kexec.h > index 1776eb2..1237682 100644 > --- a/include/linux/kexec.h > +++ b/include/linux/kexec.h > @@ -195,6 +195,11 @@ int __weak arch_kexec_apply_relocations(struct purgatory_info *pi, > const Elf_Shdr *relsec, > const Elf_Shdr *symtab); > > +extern int arch_kexec_add_buffer(struct kexec_buf *kbuf); > + > +/* arch_kexec_add_buffer calls this when it is ready */ > +extern int __kexec_add_buffer(struct kexec_buf *kbuf); > + > extern int kexec_add_buffer(struct kexec_buf *kbuf); > int kexec_locate_mem_hole(struct kexec_buf *kbuf); > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index bb05fd5..a0b4f7f 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -669,10 +669,6 @@ int kexec_locate_mem_hole(struct kexec_buf *kbuf) > */ > int kexec_add_buffer(struct kexec_buf *kbuf) > { > - > - struct kexec_segment *ksegment; > - int ret; > - > /* Currently adding segment this way is allowed only in file mode */ > if (!kbuf->image->file_mode) > return -EINVAL; > @@ -696,6 +692,25 @@ int kexec_add_buffer(struct kexec_buf *kbuf) > kbuf->memsz = ALIGN(kbuf->memsz, PAGE_SIZE); > kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE); > > + return arch_kexec_add_buffer(kbuf); > +} > + > +/** > + * __kexec_add_buffer - arch_kexec_add_buffer would call this function after > + * updating kbuf, to place a buffer in a kexec segment. > + * @kbuf: Buffer contents and memory parameters. > + * > + * This function assumes that kexec_mutex is held. > + * On successful return, @kbuf->mem will have the physical address of > + * the buffer in memory. > + * > + * Return: 0 on success, negative errno on error. > + */ > +int __kexec_add_buffer(struct kexec_buf *kbuf) > +{ > + struct kexec_segment *ksegment; > + int ret; > + > /* Walk the RAM ranges and allocate a suitable range for the buffer */ > ret = kexec_locate_mem_hole(kbuf); > if (ret) > @@ -711,6 +726,20 @@ int kexec_add_buffer(struct kexec_buf *kbuf) > return 0; > } > > +/** > + * arch_kexec_add_buffer - Some archs have memory regions within the given > + * range that can't be used to place a kexec segment. > + * Such archs can override this function to take care > + * of them before trying to locate the memory hole. > + * @kbuf: Buffer contents and memory parameters. > + * > + * Return: 0 on success, negative errno on error. > + */ > +int __weak arch_kexec_add_buffer(struct kexec_buf *kbuf) > +{ > + return __kexec_add_buffer(kbuf); > +} > + > /* Calculate and store the digest of segments */ > static int kexec_calculate_store_digests(struct kimage *image) > { > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec >