From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9DBCC433E1 for ; Thu, 16 Jul 2020 05:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFF232070E for ; Thu, 16 Jul 2020 05:58:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726593AbgGPF6X (ORCPT ); Thu, 16 Jul 2020 01:58:23 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:6048 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbgGPF6W (ORCPT ); Thu, 16 Jul 2020 01:58:22 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06G5WHrT001936; Thu, 16 Jul 2020 01:58:15 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32792wvxy7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jul 2020 01:58:15 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06G5WL6S002191; Thu, 16 Jul 2020 01:58:15 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 32792wvxxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jul 2020 01:58:15 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06G5tdPD001596; Thu, 16 Jul 2020 05:58:13 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma04dal.us.ibm.com with ESMTP id 327529r05p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jul 2020 05:58:13 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06G5wCS117105226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jul 2020 05:58:12 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC6C5C605B; Thu, 16 Jul 2020 05:58:11 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8083C6057; Thu, 16 Jul 2020 05:58:08 +0000 (GMT) Received: from morokweng.localdomain (unknown [9.163.73.114]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTPS; Thu, 16 Jul 2020 05:58:08 +0000 (GMT) References: <159466074408.24747.10036072269371204890.stgit@hbathini.in.ibm.com> <159466088775.24747.1248185448154277951.stgit@hbathini.in.ibm.com> <87365t8pse.fsf@morokweng.localdomain> User-agent: mu4e 1.2.0; emacs 26.3 From: Thiago Jung Bauermann To: Hari Bathini Cc: Pingfan Liu , Nayna Jain , Kexec-ml , Mahesh J Salgaonkar , Mimi Zohar , lkml , linuxppc-dev , Sourabh Jain , Petr Tesarik , Andrew Morton , Dave Young , Vivek Goyal , Eric Biederman Subject: Re: [PATCH v3 04/12] ppc64/kexec_file: avoid stomping memory used by special regions In-reply-to: <87365t8pse.fsf@morokweng.localdomain> Date: Thu, 16 Jul 2020 02:58:04 -0300 Message-ID: <87pn8w80ib.fsf@morokweng.localdomain> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-15_12:2020-07-15,2020-07-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 clxscore=1015 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007160038 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thiago Jung Bauermann writes: > Hari Bathini writes: > >> diff --git a/arch/powerpc/include/asm/crashdump-ppc64.h b/arch/powerpc/include/asm/crashdump-ppc64.h >> new file mode 100644 >> index 0000000..90deb46 >> --- /dev/null >> +++ b/arch/powerpc/include/asm/crashdump-ppc64.h >> @@ -0,0 +1,10 @@ >> +/* SPDX-License-Identifier: GPL-2.0-only */ >> +#ifndef _ASM_POWERPC_CRASHDUMP_PPC64_H >> +#define _ASM_POWERPC_CRASHDUMP_PPC64_H >> + >> +/* min & max addresses for kdump load segments */ >> +#define KDUMP_BUF_MIN (crashk_res.start) >> +#define KDUMP_BUF_MAX ((crashk_res.end < ppc64_rma_size) ? \ >> + crashk_res.end : (ppc64_rma_size - 1)) >> + >> +#endif /* __ASM_POWERPC_CRASHDUMP_PPC64_H */ >> diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h >> index 7008ea1..bf47a01 100644 >> --- a/arch/powerpc/include/asm/kexec.h >> +++ b/arch/powerpc/include/asm/kexec.h >> @@ -100,14 +100,16 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_co >> #ifdef CONFIG_KEXEC_FILE >> extern const struct kexec_file_ops kexec_elf64_ops; >> >> -#ifdef CONFIG_IMA_KEXEC >> #define ARCH_HAS_KIMAGE_ARCH >> >> struct kimage_arch { >> + struct crash_mem *exclude_ranges; >> + >> +#ifdef CONFIG_IMA_KEXEC >> phys_addr_t ima_buffer_addr; >> size_t ima_buffer_size; >> -}; >> #endif >> +}; >> >> int setup_purgatory(struct kimage *image, const void *slave_code, >> const void *fdt, unsigned long kernel_load_addr, >> @@ -125,6 +127,7 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, >> unsigned long initrd_load_addr, >> unsigned long initrd_len, const char *cmdline); >> #endif /* CONFIG_PPC64 */ >> + >> #endif /* CONFIG_KEXEC_FILE */ >> >> #else /* !CONFIG_KEXEC_CORE */ >> diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c >> index 23ad04c..c695f94 100644 >> --- a/arch/powerpc/kexec/elf_64.c >> +++ b/arch/powerpc/kexec/elf_64.c >> @@ -22,6 +22,7 @@ >> #include >> #include >> #include >> +#include >> >> static void *elf64_load(struct kimage *image, char *kernel_buf, >> unsigned long kernel_len, char *initrd, >> @@ -46,6 +47,12 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, >> if (ret) >> goto out; >> >> + if (image->type == KEXEC_TYPE_CRASH) { >> + /* min & max buffer values for kdump case */ >> + kbuf.buf_min = pbuf.buf_min = KDUMP_BUF_MIN; >> + kbuf.buf_max = pbuf.buf_max = KDUMP_BUF_MAX; > > This is only my personal opinion and an actual maintainer may disagree, > but just looking at the lines above, I would assume that KDUMP_BUF_MIN > and KDUMP_BUF_MAX were constants, when in fact they aren't. > > I suggest using static inline macros in , for > example: > > static inline resource_size_t get_kdump_buf_min(void) > { > return crashk_res.start; > } > > static inline resource_size_t get_kdump_buf_max(void) > { > return (crashk_res.end < ppc64_rma_size) ? \ > crashk_res.end : (ppc64_rma_size - 1) > } I later noticed that KDUMP_BUF_MIN and KDUMP_BUF_MAX are only used here. In this case, I think the best option is to avoid the macros and inline functions and just use the actual expressions in the code. -- Thiago Jung Bauermann IBM Linux Technology Center From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF03EC433DF for ; Thu, 16 Jul 2020 06:00:17 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E57D20578 for ; Thu, 16 Jul 2020 06:00:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E57D20578 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4B6kB70rptzDqvN for ; Thu, 16 Jul 2020 16:00:15 +1000 (AEST) Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4B6k7w3RGCzDqth for ; Thu, 16 Jul 2020 15:58:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4B6k7w33Hcz8tFw for ; Thu, 16 Jul 2020 15:58:20 +1000 (AEST) Received: by ozlabs.org (Postfix) id 4B6k7w2ZNrz9sSt; Thu, 16 Jul 2020 15:58:20 +1000 (AEST) Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=bauerman@linux.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B6k7v41vhz9sRW for ; Thu, 16 Jul 2020 15:58:19 +1000 (AEST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06G5WHrT001936; Thu, 16 Jul 2020 01:58:15 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32792wvxy7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jul 2020 01:58:15 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06G5WL6S002191; Thu, 16 Jul 2020 01:58:15 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 32792wvxxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jul 2020 01:58:15 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06G5tdPD001596; Thu, 16 Jul 2020 05:58:13 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma04dal.us.ibm.com with ESMTP id 327529r05p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jul 2020 05:58:13 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06G5wCS117105226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jul 2020 05:58:12 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC6C5C605B; Thu, 16 Jul 2020 05:58:11 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8083C6057; Thu, 16 Jul 2020 05:58:08 +0000 (GMT) Received: from morokweng.localdomain (unknown [9.163.73.114]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTPS; Thu, 16 Jul 2020 05:58:08 +0000 (GMT) References: <159466074408.24747.10036072269371204890.stgit@hbathini.in.ibm.com> <159466088775.24747.1248185448154277951.stgit@hbathini.in.ibm.com> <87365t8pse.fsf@morokweng.localdomain> User-agent: mu4e 1.2.0; emacs 26.3 From: Thiago Jung Bauermann To: Hari Bathini Subject: Re: [PATCH v3 04/12] ppc64/kexec_file: avoid stomping memory used by special regions In-reply-to: <87365t8pse.fsf@morokweng.localdomain> Date: Thu, 16 Jul 2020 02:58:04 -0300 Message-ID: <87pn8w80ib.fsf@morokweng.localdomain> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-15_12:2020-07-15, 2020-07-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 clxscore=1015 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007160038 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pingfan Liu , Petr Tesarik , Nayna Jain , Kexec-ml , Mahesh J Salgaonkar , Mimi Zohar , lkml , linuxppc-dev , Sourabh Jain , Andrew Morton , Dave Young , Vivek Goyal , Eric Biederman Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Thiago Jung Bauermann writes: > Hari Bathini writes: > >> diff --git a/arch/powerpc/include/asm/crashdump-ppc64.h b/arch/powerpc/include/asm/crashdump-ppc64.h >> new file mode 100644 >> index 0000000..90deb46 >> --- /dev/null >> +++ b/arch/powerpc/include/asm/crashdump-ppc64.h >> @@ -0,0 +1,10 @@ >> +/* SPDX-License-Identifier: GPL-2.0-only */ >> +#ifndef _ASM_POWERPC_CRASHDUMP_PPC64_H >> +#define _ASM_POWERPC_CRASHDUMP_PPC64_H >> + >> +/* min & max addresses for kdump load segments */ >> +#define KDUMP_BUF_MIN (crashk_res.start) >> +#define KDUMP_BUF_MAX ((crashk_res.end < ppc64_rma_size) ? \ >> + crashk_res.end : (ppc64_rma_size - 1)) >> + >> +#endif /* __ASM_POWERPC_CRASHDUMP_PPC64_H */ >> diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h >> index 7008ea1..bf47a01 100644 >> --- a/arch/powerpc/include/asm/kexec.h >> +++ b/arch/powerpc/include/asm/kexec.h >> @@ -100,14 +100,16 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_co >> #ifdef CONFIG_KEXEC_FILE >> extern const struct kexec_file_ops kexec_elf64_ops; >> >> -#ifdef CONFIG_IMA_KEXEC >> #define ARCH_HAS_KIMAGE_ARCH >> >> struct kimage_arch { >> + struct crash_mem *exclude_ranges; >> + >> +#ifdef CONFIG_IMA_KEXEC >> phys_addr_t ima_buffer_addr; >> size_t ima_buffer_size; >> -}; >> #endif >> +}; >> >> int setup_purgatory(struct kimage *image, const void *slave_code, >> const void *fdt, unsigned long kernel_load_addr, >> @@ -125,6 +127,7 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, >> unsigned long initrd_load_addr, >> unsigned long initrd_len, const char *cmdline); >> #endif /* CONFIG_PPC64 */ >> + >> #endif /* CONFIG_KEXEC_FILE */ >> >> #else /* !CONFIG_KEXEC_CORE */ >> diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c >> index 23ad04c..c695f94 100644 >> --- a/arch/powerpc/kexec/elf_64.c >> +++ b/arch/powerpc/kexec/elf_64.c >> @@ -22,6 +22,7 @@ >> #include >> #include >> #include >> +#include >> >> static void *elf64_load(struct kimage *image, char *kernel_buf, >> unsigned long kernel_len, char *initrd, >> @@ -46,6 +47,12 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, >> if (ret) >> goto out; >> >> + if (image->type == KEXEC_TYPE_CRASH) { >> + /* min & max buffer values for kdump case */ >> + kbuf.buf_min = pbuf.buf_min = KDUMP_BUF_MIN; >> + kbuf.buf_max = pbuf.buf_max = KDUMP_BUF_MAX; > > This is only my personal opinion and an actual maintainer may disagree, > but just looking at the lines above, I would assume that KDUMP_BUF_MIN > and KDUMP_BUF_MAX were constants, when in fact they aren't. > > I suggest using static inline macros in , for > example: > > static inline resource_size_t get_kdump_buf_min(void) > { > return crashk_res.start; > } > > static inline resource_size_t get_kdump_buf_max(void) > { > return (crashk_res.end < ppc64_rma_size) ? \ > crashk_res.end : (ppc64_rma_size - 1) > } I later noticed that KDUMP_BUF_MIN and KDUMP_BUF_MAX are only used here. In this case, I think the best option is to avoid the macros and inline functions and just use the actual expressions in the code. -- Thiago Jung Bauermann IBM Linux Technology Center From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwuO-0004sY-V0 for kexec@lists.infradead.org; Thu, 16 Jul 2020 05:58:17 +0000 References: <159466074408.24747.10036072269371204890.stgit@hbathini.in.ibm.com> <159466088775.24747.1248185448154277951.stgit@hbathini.in.ibm.com> <87365t8pse.fsf@morokweng.localdomain> From: Thiago Jung Bauermann Subject: Re: [PATCH v3 04/12] ppc64/kexec_file: avoid stomping memory used by special regions In-reply-to: <87365t8pse.fsf@morokweng.localdomain> Date: Thu, 16 Jul 2020 02:58:04 -0300 Message-ID: <87pn8w80ib.fsf@morokweng.localdomain> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Hari Bathini Cc: Pingfan Liu , Petr Tesarik , Nayna Jain , Kexec-ml , Mahesh J Salgaonkar , Mimi Zohar , lkml , linuxppc-dev , Sourabh Jain , Andrew Morton , Dave Young , Vivek Goyal , Eric Biederman Thiago Jung Bauermann writes: > Hari Bathini writes: > >> diff --git a/arch/powerpc/include/asm/crashdump-ppc64.h b/arch/powerpc/include/asm/crashdump-ppc64.h >> new file mode 100644 >> index 0000000..90deb46 >> --- /dev/null >> +++ b/arch/powerpc/include/asm/crashdump-ppc64.h >> @@ -0,0 +1,10 @@ >> +/* SPDX-License-Identifier: GPL-2.0-only */ >> +#ifndef _ASM_POWERPC_CRASHDUMP_PPC64_H >> +#define _ASM_POWERPC_CRASHDUMP_PPC64_H >> + >> +/* min & max addresses for kdump load segments */ >> +#define KDUMP_BUF_MIN (crashk_res.start) >> +#define KDUMP_BUF_MAX ((crashk_res.end < ppc64_rma_size) ? \ >> + crashk_res.end : (ppc64_rma_size - 1)) >> + >> +#endif /* __ASM_POWERPC_CRASHDUMP_PPC64_H */ >> diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h >> index 7008ea1..bf47a01 100644 >> --- a/arch/powerpc/include/asm/kexec.h >> +++ b/arch/powerpc/include/asm/kexec.h >> @@ -100,14 +100,16 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_co >> #ifdef CONFIG_KEXEC_FILE >> extern const struct kexec_file_ops kexec_elf64_ops; >> >> -#ifdef CONFIG_IMA_KEXEC >> #define ARCH_HAS_KIMAGE_ARCH >> >> struct kimage_arch { >> + struct crash_mem *exclude_ranges; >> + >> +#ifdef CONFIG_IMA_KEXEC >> phys_addr_t ima_buffer_addr; >> size_t ima_buffer_size; >> -}; >> #endif >> +}; >> >> int setup_purgatory(struct kimage *image, const void *slave_code, >> const void *fdt, unsigned long kernel_load_addr, >> @@ -125,6 +127,7 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, >> unsigned long initrd_load_addr, >> unsigned long initrd_len, const char *cmdline); >> #endif /* CONFIG_PPC64 */ >> + >> #endif /* CONFIG_KEXEC_FILE */ >> >> #else /* !CONFIG_KEXEC_CORE */ >> diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c >> index 23ad04c..c695f94 100644 >> --- a/arch/powerpc/kexec/elf_64.c >> +++ b/arch/powerpc/kexec/elf_64.c >> @@ -22,6 +22,7 @@ >> #include >> #include >> #include >> +#include >> >> static void *elf64_load(struct kimage *image, char *kernel_buf, >> unsigned long kernel_len, char *initrd, >> @@ -46,6 +47,12 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, >> if (ret) >> goto out; >> >> + if (image->type == KEXEC_TYPE_CRASH) { >> + /* min & max buffer values for kdump case */ >> + kbuf.buf_min = pbuf.buf_min = KDUMP_BUF_MIN; >> + kbuf.buf_max = pbuf.buf_max = KDUMP_BUF_MAX; > > This is only my personal opinion and an actual maintainer may disagree, > but just looking at the lines above, I would assume that KDUMP_BUF_MIN > and KDUMP_BUF_MAX were constants, when in fact they aren't. > > I suggest using static inline macros in , for > example: > > static inline resource_size_t get_kdump_buf_min(void) > { > return crashk_res.start; > } > > static inline resource_size_t get_kdump_buf_max(void) > { > return (crashk_res.end < ppc64_rma_size) ? \ > crashk_res.end : (ppc64_rma_size - 1) > } I later noticed that KDUMP_BUF_MIN and KDUMP_BUF_MAX are only used here. In this case, I think the best option is to avoid the macros and inline functions and just use the actual expressions in the code. -- Thiago Jung Bauermann IBM Linux Technology Center _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec