Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp4342653ybt; Mon, 6 Jul 2020 02:08:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVtTArgPABLk/XzzvacTdGCOBqpQtipN+oRagxWLgUUgaPfjq4UBLibFaHyEqMLtv4AQVf X-Received: by 2002:a17:906:f911:: with SMTP id lc17mr43923129ejb.330.1594026488427; Mon, 06 Jul 2020 02:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594026488; cv=none; d=google.com; s=arc-20160816; b=ylbwD2iQtZvasSwVhJUqOelp1pAn8/SU7NoxTJR5Zcz5oKdr3ZAL3XEg77SGbD36IP pXrCKkWSN7pTj4mskuzDN4p2rp5fzm8ekkANL3YklNvKfPP8s23n7s28iThl1i/pI+Id ANgNjMJ9hjz4o5bYXasDDOFX8JMYgYxbusj+bhHmDnveVb6fL7Tq6E9JUb6QUQcgP26X 1iP056Y0o4dK+FyMDEiVz1dlYm7b8mrjHkHKCNL1rME7P89JBCjjvjD3viqX5NRALhM0 vDi8PODPXtS9j6RA6JyxB975MjDL1Spxk5EyzlxNc62CSwTCP6zQ0yEFI09H34P3cPv4 MpoA== 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=SShJmXGA7atFqGfnITwSEtZ2LmnJMbZjAOdugmKURLE=; b=CWDFYEUCdUchd2i19xvZs0TsWd2iREmQPq7k0NyxNt6Lb2pognegVP5ZpXRgWpB4Sm RNelSDl1yjMXF4znVnF7Wz5kTPYSW/b7zU5rkX+X+QsbZFmwBO8pmhp/+gTj96LAXG27 AqVaa9YWBg+K5TflJGTdPBQi/mrfvz/npyurgK1AXvXP0mzEeR9lBQbP5f6hPvgRRLdq 6amdpkXr24H5dMX6G7WzSKyY+AU7ONDSnLbbRz72KGdlcXXkvoG08+IUUg7q14OM61dq IfGeTwVRFLL5lXRY85A8UXyF/0BJ6tQVe5ippngDdeLSI2cL7sROW2GFFQ6PfurkHV0Q gnVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kt+4EgUF; 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 x27si13986821edi.182.2020.07.06.02.07.46; Mon, 06 Jul 2020 02:08:08 -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=Kt+4EgUF; 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 S1728381AbgGFJHZ (ORCPT + 99 others); Mon, 6 Jul 2020 05:07:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56829 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728024AbgGFJHY (ORCPT ); Mon, 6 Jul 2020 05:07:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594026442; 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=SShJmXGA7atFqGfnITwSEtZ2LmnJMbZjAOdugmKURLE=; b=Kt+4EgUFFzvqe8kIrjQSVzIf4d9vUyUarE26DGlBxUFWsYplHrz10vamLfCs7R4IyB3gT5 FZOeMhs625eT6JwmrsxYRARXLN79DsesMl3z6rkLCVgrZ7B5JMzdXaDmEO8NNRli+8UPqz //88JZ68lu+oHJjwrXWkJ5JPK2PfQaM= 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-193-Zi_68QkjPGSL8uxCZHp9gw-1; Mon, 06 Jul 2020 05:07:20 -0400 X-MC-Unique: Zi_68QkjPGSL8uxCZHp9gw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5970118A0724; Mon, 6 Jul 2020 09:07:18 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A26BD60BF3; Mon, 6 Jul 2020 09:07:10 +0000 (UTC) Date: Mon, 6 Jul 2020 17:07:07 +0800 From: Dave Young To: Hari Bathini Cc: Michael Ellerman , Andrew Morton , kernel test robot , Pingfan Liu , Kexec-ml , Petr Tesarik , Mahesh J Salgaonkar , Mimi Zohar , lkml , linuxppc-dev , Sourabh Jain , Vivek Goyal , Thiago Jung Bauermann , Eric Biederman Subject: Re: [PATCH v2 01/12] kexec_file: allow archs to handle special regions while locating memory hole Message-ID: <20200706090707.GA9048@dhcp-128-65.nay.redhat.com> References: <159371956443.21555.18251597651350106920.stgit@hbathini.in.ibm.com> <159371964681.21555.573193508667543223.stgit@hbathini.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <159371964681.21555.573193508667543223.stgit@hbathini.in.ibm.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/03/20 at 01:24am, Hari Bathini wrote: > Some architectures may have special memory regions, within the given > memory range, which can't be used for the buffer in a kexec segment. > Implement weak arch_kexec_locate_mem_hole() definition which arch code > may override, to take care of special regions, while trying to locate > a memory hole. > > Also, add the missing declarations for arch overridable functions and > and drop the __weak descriptors in the declarations to avoid non-weak > definitions from becoming weak. > > Reported-by: kernel test robot > [lkp: In v1, arch_kimage_file_post_load_cleanup() declaration was missing] > Signed-off-by: Hari Bathini > --- > > Changes in v2: > * Introduced arch_kexec_locate_mem_hole() for override and dropped > weak arch_kexec_add_buffer(). > * Dropped __weak identifier for arch overridable functions. > * Fixed the missing declaration for arch_kimage_file_post_load_cleanup() > reported by lkp. lkp report for reference: > - https://lore.kernel.org/patchwork/patch/1264418/ > > > include/linux/kexec.h | 29 ++++++++++++++++++----------- > kernel/kexec_file.c | 16 ++++++++++++++-- > 2 files changed, 32 insertions(+), 13 deletions(-) > > diff --git a/include/linux/kexec.h b/include/linux/kexec.h > index ea67910..9e93bef 100644 > --- a/include/linux/kexec.h > +++ b/include/linux/kexec.h > @@ -183,17 +183,24 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, > bool get_value); > void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name); > > -int __weak arch_kexec_kernel_image_probe(struct kimage *image, void *buf, > - unsigned long buf_len); > -void * __weak arch_kexec_kernel_image_load(struct kimage *image); > -int __weak arch_kexec_apply_relocations_add(struct purgatory_info *pi, > - Elf_Shdr *section, > - const Elf_Shdr *relsec, > - const Elf_Shdr *symtab); > -int __weak arch_kexec_apply_relocations(struct purgatory_info *pi, > - Elf_Shdr *section, > - const Elf_Shdr *relsec, > - const Elf_Shdr *symtab); > +/* Architectures may override the below functions */ > +int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, > + unsigned long buf_len); > +void *arch_kexec_kernel_image_load(struct kimage *image); > +int arch_kexec_apply_relocations_add(struct purgatory_info *pi, > + Elf_Shdr *section, > + const Elf_Shdr *relsec, > + const Elf_Shdr *symtab); > +int arch_kexec_apply_relocations(struct purgatory_info *pi, > + Elf_Shdr *section, > + const Elf_Shdr *relsec, > + const Elf_Shdr *symtab); > +int arch_kimage_file_post_load_cleanup(struct kimage *image); > +#ifdef CONFIG_KEXEC_SIG > +int arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, > + unsigned long buf_len); > +#endif > +int arch_kexec_locate_mem_hole(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 09cc78d..e89912d 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -636,6 +636,19 @@ int kexec_locate_mem_hole(struct kexec_buf *kbuf) > } > > /** > + * arch_kexec_locate_mem_hole - Find free memory to place the segments. > + * @kbuf: Parameters for the memory search. > + * > + * On success, kbuf->mem will have the start address of the memory region found. > + * > + * Return: 0 on success, negative errno on error. > + */ > +int __weak arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) > +{ > + return kexec_locate_mem_hole(kbuf); > +} > + > +/** > * kexec_add_buffer - place a buffer in a kexec segment > * @kbuf: Buffer contents and memory parameters. > * > @@ -647,7 +660,6 @@ int kexec_locate_mem_hole(struct kexec_buf *kbuf) > */ > int kexec_add_buffer(struct kexec_buf *kbuf) > { > - > struct kexec_segment *ksegment; > int ret; > > @@ -675,7 +687,7 @@ int kexec_add_buffer(struct kexec_buf *kbuf) > kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE); > > /* Walk the RAM ranges and allocate a suitable range for the buffer */ > - ret = kexec_locate_mem_hole(kbuf); > + ret = arch_kexec_locate_mem_hole(kbuf); > if (ret) > return ret; > > Acked-by: Dave Young Thanks Dave