From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1BD0606A31E for ; Fri, 27 Nov 2026 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=gxvGi8l5 Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jbTgG4LcBz2xxr; Fri, 27 Nov 2026 21:10:02 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795774202; cv=none; b=bhx5whpmTq9EhporQ3/FvY40oeDjyET33JfLXqszhteEWU2SvI1DnerYIXieSLrOFyZeFpV+VIqqSIODmgjwOa7oXq0OcDkd5iQbyEnGf1Q6G4jINGq5H2HyKGGn5OLmV8Z3dAGRz6h0V6xUf9Cq9wRDoNX1xCqeScY+X1IRoepx3WrVi6F200oSwq0/6WEuYfsgwYi88UhiQxEqqgDczrsMdVQNd5i05HdYNlykZWZ6U9lDXDXjdbpbzR3spsylaaEpSdL3dMWYOChuM9gKad6j02ukPsaf4lwrAyt2ZIYQgLNPn7IJm2pxOP5ztCNEFtHZVeLG1l9nN7+ipdEcTQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795774202; c=relaxed/relaxed; bh=VAYr9WX92dg3SvFjZudKbj8hGUmjBf0kHQsMj3Huy2A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ak+mhtMmC9BuN08PM5nn6LgvLLbRZZyRBxyo7T/c3HEBYA/xj4iS/2HVXgJq1lw3IukFP4XS5qCFGUDXRYt0OgJQXsbZ8+Q/lfwzyf/NWNdcUI+d3xanYFqoeR9rBOFTTWRJaASqlOvf5u2k2dNSezioQ3md1SouVEQhaFyYyHNelvKVlNmv84xDnC1pbERemi11FCxDZ8W/qHnG+rGq4pMezCDEEZpZxtw35iowir+EVyrf262csfUkd6x2pvN5z4uVl5jZDWBOjcPPB+1DY371vec0D11tzstdn6o9WVI+6KJPq4v5NIMnCryQiSCn4bkIR0dEtgt4X0U6AER/iQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=gxvGi8l5; dkim-atps=neutral; spf=pass (client-ip=113.46.200.221; helo=canpmsgout06.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=gxvGi8l5; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=113.46.200.221; helo=canpmsgout06.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jbTgB5Zw0z2yCP for ; Fri, 27 Nov 2026 21:09:58 +1100 (AEDT) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=VAYr9WX92dg3SvFjZudKbj8hGUmjBf0kHQsMj3Huy2A=; b=gxvGi8l5GYdAixG1QRWsiSMLXXsHyOINqSPUArEqcmmeWhWDwV6nk3CkHtY7MDp+FMWYyzx6n HOBPUbx0XU/w94jHsTYt7dspTnSwdWfKEmGxB/qdyl9efuTCs2wvrwlVEjkDtbQfNn79EZnH2fE I8C2D6gS4O3csk5lTZtUg8E= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4jbTfl2PZkzRhWM; Fri, 27 Nov 2026 18:09:35 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id 303DF40575; Fri, 27 Nov 2026 18:09:55 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemk200008.china.huawei.com (7.202.194.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 27 Nov 2026 18:09:53 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v9 07/11] powerpc: kexec_file: Use the common segment helpers Date: Fri, 27 Nov 2026 18:09:21 +0800 Message-ID: <20261127100925.3019877-8-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261127100925.3019877-1-ruanjinjie@huawei.com> References: <20261127100925.3019877-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemk200008.china.huawei.com (7.202.194.74) X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 load_elfcorehdr_segment() builds the elf core header from the powerpc crash memory ranges and places it as a segment. The header needs powerpc specific post processing, so keep building it here, but use kexec_add_elf_core_header() to place it. elf64_load() also loads the initrd by hand, use kexec_add_initrd() for it. Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Andrew Morton Cc: Baoquan He Cc: Mike Rapoport Signed-off-by: Jinjie Ruan --- arch/powerpc/kexec/elf_64.c | 9 ++------- arch/powerpc/kexec/file_load_64.c | 14 ++++---------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c index d9a466cd602e..1ef444494641 100644 --- a/arch/powerpc/kexec/elf_64.c +++ b/arch/powerpc/kexec/elf_64.c @@ -96,18 +96,13 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, kexec_dprintk("Command line: %s", cmdline ? cmdline : ""); - if (initrd != NULL) { - kbuf.buffer = initrd; - kbuf.bufsz = kbuf.memsz = initrd_len; + if (initrd) { kbuf.buf_align = PAGE_SIZE; kbuf.top_down = false; - kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; - ret = kexec_add_buffer(&kbuf); + ret = kexec_add_initrd(image, &kbuf); if (ret) goto out; initrd_load_addr = kbuf.mem; - - kexec_dprintk("Loaded initrd at 0x%lx\n", initrd_load_addr); } ret = get_reserved_memory_ranges(&rmem); diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index 0cf03cee35a7..77652db7d1ca 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -416,9 +416,8 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf) /* Fix the offset for backup region in the ELF header */ sync_backup_region_phdr(image, headers, false); - kbuf->buffer = headers; - kbuf->mem = KEXEC_BUF_MEM_UNKNOWN; - kbuf->bufsz = headers_sz; + image->elf_headers = headers; + image->elf_headers_sz = headers_sz; /* * Account for extra space required to accommodate additional memory @@ -427,13 +426,9 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf) kbuf->memsz = headers_sz + kdump_extra_elfcorehdr_size(cmem); kbuf->top_down = false; - ret = kexec_add_buffer(kbuf); - if (ret) { - vfree(headers); + ret = kexec_add_elf_core_header(image, kbuf); + if (ret) goto out; - } - - image->elf_load_addr = kbuf->mem; /* * If CONFIG_CRASH_HOTPLUG is enabled, the elfcorehdr kexec segment @@ -442,7 +437,6 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf) * memory in the FDT prepared for kdump. */ image->elf_headers_sz = kbuf->memsz; - image->elf_headers = headers; out: kfree(cmem); return ret; -- 2.34.1