Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3066810ybt; Mon, 29 Jun 2020 14:24:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyo8oe71pBuAPaFstJO0nEmkvCtIlSrpTC/sx7uTo/8BlBfuOKuFq1/FaZcBIO5v0J7+deS X-Received: by 2002:a17:906:4a44:: with SMTP id a4mr7894526ejv.486.1593465864710; Mon, 29 Jun 2020 14:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593465864; cv=none; d=google.com; s=arc-20160816; b=rpTkEUU8Z9Y5LrY2gNtN2YtmE5hVro7P/8SDlPjTci4AQ3VtI90SW+Sq76cSLkljpi zy4flpTnfJavqLe5fnxkelMOzRXLd4+cw870kjvcsPDA73+zrevJWsmJJMidUjcD995c x9uJCzKxG/lPDJVgegrQKEhrxztUqcaSRadQ7pCY3fhHDv8wdLedYxKiO8lRVfsAAB6p I7644YH/nkeLptw1r9G13iMZmHDLdkFHdMafPguK4TMi7ONrqdgqqHy4xp4mEaofmm8s BzalxbPIZiepEbzn1ov4oudnTdhmnd1MCmFSlSVjeM2clURzlfyZT6EVYNbPCeGqIjQ6 278g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=ToeoLqpT69QFNFSUsgNWNvFvwafaauoCFPizPEil8f8=; b=QsNs/ahLegW/1NzS0pZqXCw+4BLTH+IAYjLUmCXdVoFv1s7CxVHXNpRpE8eNBkmUBj +xJE46YEjrrnsQgyFRzEOxMWDdD3q3EIs3ikwAlXiB1v0Qa5606xaOchpya879v2x8AQ 1SJShkBLEaIEVpkTe8csla57ErZmRf19vjr3rcWvvrJGin423YMkn/hBd0gWv2x1zciT kvo/jGCalY7zDlAP2dG9TIgjBLBy2J2opSjDGkpcddJksUINGngzgr0LfMtcZ32xJZD7 P1eINSyplbveJ07UW8hOLWRfBvcCPZ4nMmTY1lsyAvt5urXVN7sUFzMxAZeaZK+bTdKt TWWg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q28si420005edw.196.2020.06.29.14.24.01; Mon, 29 Jun 2020 14:24:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390633AbgF2VWk (ORCPT + 99 others); Mon, 29 Jun 2020 17:22:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:44784 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729593AbgF2Sv3 (ORCPT ); Mon, 29 Jun 2020 14:51:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4DCA4AD6A; Mon, 29 Jun 2020 11:39:38 +0000 (UTC) Date: Mon, 29 Jun 2020 13:39:33 +0200 From: Petr Tesarik To: Hari Bathini Cc: Michael Ellerman , Andrew Morton , Pingfan Liu , Kexec-ml , Mimi Zohar , Mahesh J Salgaonkar , Sourabh Jain , lkml , linuxppc-dev , Eric Biederman , Thiago Jung Bauermann , Dave Young , Vivek Goyal Subject: Re: [PATCH 01/11] kexec_file: allow archs to handle special regions while locating memory hole Message-ID: <20200629133933.0787f562@ezekiel.suse.cz> In-Reply-To: <159319828304.16351.6990340111766605842.stgit@hbathini.in.ibm.com> References: <159319825403.16351.7253978047621755765.stgit@hbathini.in.ibm.com> <159319828304.16351.6990340111766605842.stgit@hbathini.in.ibm.com> Organization: SUSE Linux, s.r.o. X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/D5Q_Btj.Z_5nJ6kJU141Zr9"; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Sig_/D5Q_Btj.Z_5nJ6kJU141Zr9 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Hari, is there any good reason to add two more functions with a very similar name to an existing function? AFAICS all you need is a way to call a PPC64-specific function from within kexec_add_buffer (PATCH 4/11), so you could add something like this: int __weak arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) { return 0; } Call this function from kexec_add_buffer where appropriate and then override it for PPC64 (it roughly corresponds to your kexec_locate_mem_hole_ppc64() from PATCH 4/11). FWIW it would make it easier for me to follow the resulting code. Petr T On Sat, 27 Jun 2020 00:34:43 +0530 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. >=20 > Signed-off-by: Hari Bathini > --- > include/linux/kexec.h | 5 +++++ > kernel/kexec_file.c | 37 +++++++++++++++++++++++++++++++++---- > 2 files changed, 38 insertions(+), 4 deletions(-) >=20 > 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 purga= tory_info *pi, > const Elf_Shdr *relsec, > const Elf_Shdr *symtab); > =20 > +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); > =20 > 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 =3D ALIGN(kbuf->memsz, PAGE_SIZE); > kbuf->buf_align =3D max(kbuf->buf_align, PAGE_SIZE); > =20 > + return arch_kexec_add_buffer(kbuf); > +} > + > +/** > + * __kexec_add_buffer - arch_kexec_add_buffer would call this function a= fter > + * updating kbuf, to place a buffer in a kexec segm= ent. > + * @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 =3D kexec_locate_mem_hole(kbuf); > if (ret) > @@ -711,6 +726,20 @@ int kexec_add_buffer(struct kexec_buf *kbuf) > return 0; > } > =20 > +/** > + * arch_kexec_add_buffer - Some archs have memory regions within the giv= en > + * range that can't be used to place a kexec seg= ment. > + * Such archs can override this function to take= care > + * of them before trying to locate the memory ho= le. > + * @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) > { >=20 --Sig_/D5Q_Btj.Z_5nJ6kJU141Zr9 Content-Type: application/pgp-signature Content-Description: Digitální podpis OpenPGP -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEHl2YIZkIo5VO2MxYqlA7ya4PR6cFAl750vUACgkQqlA7ya4P R6dpTAf/dLQ6L45/sKP4CXfNn4HbDkmtImkYe5MjG/bvbhQrgLZxll54L0YT2bt/ Xml4Bam2sLd761+VlBcJaQXLojyENgxLEpyAN2XXCFW+8YSipIRrpvmX8RrP+Szr PbYupPmCs8Y7GS6iptYE8nASFVQJm4JS4h/HZCsyUcZUpe+lrlM2BkO42FP+X8L9 KdDubtEyyyWzwXx1PWpfq+I5IDIVKaIaCvXBeOp8OIjnHE4mtRcnMfahD2TBg3LM 2ga/b4txkwuVkrnVuBaAjMmcK95nlth5oc0NFGMvyoLFUiS48fHYhwFWn7gYQW54 08VDEBmerlqmS/Qvkym6ERI2MsuC6A== =M+ug -----END PGP SIGNATURE----- --Sig_/D5Q_Btj.Z_5nJ6kJU141Zr9--