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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E00B2FC9ED1 for ; Sat, 7 Mar 2026 05:21:34 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fSWph2pPTz3cCJ; Sat, 07 Mar 2026 16:21:32 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1772860892; cv=none; b=Wq2LExzGs0k2CqAkvgm0OzEUsKinXyltSC/Njbm3bN+L/lpL22tsWSvrf3ApsYjtn95Tr20Ldxnl1uRv+mwzvSW+6/OC/6ac+34Y7SWnWusZSGOuVFqpB8QEGdYhuOg6tPtA9vw4jidAh+Krb2YnIcjX+1HQoCILZKzkXz+GIe+ULVjSFRqbdxeg7s3QYKyFtn/zLRLDhFVW9Z1dJ2b/Fmm3VWPf7jzoIW7vaUok8OC3fGR72q6HlJP9NtyRqipxNmEEiQWnBMs2aUQRUMDwtEJ5CcPxadWvF7qtd/+KGxw/9LaIvkb1xTABu6PfNV9kC3KcWNi7GMEYrCsQWsvLGQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1772860892; c=relaxed/relaxed; bh=beEzyBsCHPmer9tjGhYo66b2SfICE46PlfHILn1Irts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Wy09+duKdpgnKe9BcfSoIXV78bsTpKvXICjA/BHSx3PsaFaWCdTFUaLH92BtHttVML1sHEQyWlgX+sXEBGL77+sEkkGtJbqyfoNOqFGL31GlGGGHi+hJhxIE3ZGtnVzTn1BzVZUN2ZTp5/STD30HZSA6VVFyUgBnfWdMjDTIvH5KHy+FZWdinz03RkengyaCPXPIuPGxFuUAuZIrUQJ+eKLR5ckcQnV0n8ECARtF2nckr9NLqGChHPJHhFKIo+xJAPs5O9oU2w75/6+pJkHQDQ/0TylOYYT8vWXlh4eVXmwqg7pyA3eGYb2i4HcgOnZ+6YO6YEI1n+yMuRcoubU1zQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=DYAqMMYb; dkim-atps=neutral; spf=pass (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=sourabhjain@linux.ibm.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=DYAqMMYb; dkim-atps=neutral Authentication-Results: lists.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=sourabhjain@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fSWpg4m8Zz3c9y for ; Sat, 07 Mar 2026 16:21:31 +1100 (AEDT) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6275KG0k1371484; Sat, 7 Mar 2026 05:21:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=beEzyB sCHPmer9tjGhYo66b2SfICE46PlfHILn1Irts=; b=DYAqMMYbS0znA8ZD6/nbsH VrPm4JR39Bl3hURF4l/j7Q2hE6p71IlZLuuJbRacABv+7km993GA4iB59UDfMe9m qFAcvLSGp+aKl8oLubVItCdCPC+UrUH7NLe1ZB6Ccu3W+k2nlqEleEufV0m5Vf3C gf+T/9axYqKYQnzd/LuRHoBd1dP1Ioi/PDh1rt2wcmS1qF5ZIl1vMUSkEhNXKCRb nNjj99i7Z49seBzSamNCP5EwEIaj/A2VQ3eYaqpcjaJ24V5Ql1zkvGPfnM4aSDJ3 gnZdwl6o3JEOKOtBIOMG7jyLKKCsFrj2jNiScZb8tRH3rjLE2oKUAGHngNSV3nCw == Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4crcvm03xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Mar 2026 05:21:23 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6274pdRJ003201; Sat, 7 Mar 2026 05:21:22 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4cmb2yjtta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Mar 2026 05:21:21 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6275LIRV42336744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 Mar 2026 05:21:18 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E6BA2004B; Sat, 7 Mar 2026 05:21:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C34220040; Sat, 7 Mar 2026 05:21:15 +0000 (GMT) Received: from li-4f5ba44c-27d4-11b2-a85c-a08f5b49eada.ibm.com.domain.name (unknown [9.124.213.92]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 7 Mar 2026 05:21:15 +0000 (GMT) From: Sourabh Jain To: linuxppc-dev@lists.ozlabs.org Cc: Sourabh Jain , Hari Bathini , Madhavan Srinivasan , Mahesh Salgaonkar , Michael Ellerman , "Ritesh Harjani (IBM)" , Shivang Upadhyay Subject: [PATCH v2 1/2] powerpc/crash: fix backup region offset update to eflcorehdr Date: Sat, 7 Mar 2026 10:50:56 +0530 Message-ID: <20260307052102.944952-2-sourabhjain@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260307052102.944952-1-sourabhjain@linux.ibm.com> References: <20260307052102.944952-1-sourabhjain@linux.ibm.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=y Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: gZZ3MlAbXaSWp9HKxGdZ7jPQCeZPfk3s X-Proofpoint-ORIG-GUID: 4no6IEV6afsnzzU5-GbXXQOz8abKuOdo X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDA0MyBTYWx0ZWRfX0Wy3YtaoX+ra 4q0mlp49RAPWSVLy2rVOwN3YR9FTa0xsOWN+N3nJ6MCjnScxICaqCEnsljAuhtK3AKC0PrjkPEt 1y3ZzTuuUbPEZSYIG9fkudNHJ6ILnI5fizGDPE88gubj8jRQrep0w4ninnhMOlaauTEudX+i/Is NXlzfPtguU1cQqNES6XmItzPFsPA0whJGS2TlE+QmFWnSbcKfHHEcvpI9Gqo7Tj528mHnm0a66w gOjNR5RozpQh7Uow9DH55HD90cC1VUOYJFL3+dOyXsgN20PxAln97VYwcv0NqwMWyfPPd+toi/Y 561hoa7tCI6MZq6FQotBnNRUGAsKTCnnyDMcMrOIm14sqqVUBxR3JoIir7IJzJetXX+xMIwnN/H EQRyjajR4w0Ojju3dAsHVj5LB+lLGJmGjdfh3K9hR2h48XuBynzRWwpSERo9IynJiuaxSh0l1Hn NN2CprB1Ir5I+fu6LiA== X-Authority-Analysis: v=2.4 cv=B5q0EetM c=1 sm=1 tr=0 ts=69abb5d3 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=qf4gfuq51q0A:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=pGLkceISAAAA:8 a=tR4UYP6JrHl6jBHRX14A:9 a=3ZKOabzyN94A:10 a=k40Crp0UdiQA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-07_02,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070043 update_backup_region_phdr() in file_load_64.c iterates over all the program headers in the kdump kernel’s elfcorehdr and updates the p_offset of the program header whose physical address starts at 0. However, the loop logic is incorrect because the program header pointer is not updated during iteration. Since elfcorehdr typically contains PT_NOTE entries first, the PT_LOAD program header with physical address 0 is never reached. As a result, its p_offset is not updated to point to the backup region. Because of this behavior, the capture kernel exports the first 64 KB of the crashed kernel’s memory at offset 0, even though that memory actually lives in the backup region. When a crash happens, purgatory copies the first 64 KB of the crashed kernel’s memory into the backup region so the capture kernel can safely use it. This has not caused problems so far because the first 64 KB is usually identical in both the crashed and capture kernels. However, this is just an assumption and is not guaranteed to always hold true. Fix update_backup_region_phdr() to correctly update the p_offset of the program header with a starting physical address of 0 by correcting the logic used to iterate over the program headers. Fixes: cb350c1f1f86 ("powerpc/kexec_file: Prepare elfcore header for crashing kernel") Cc: Hari Bathini Cc: Madhavan Srinivasan Cc: Mahesh Salgaonkar Cc: Michael Ellerman Cc: Ritesh Harjani (IBM) Cc: Shivang Upadhyay Signed-off-by: Sourabh Jain --- arch/powerpc/kexec/file_load_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index e7ef8b2a2554..e631cf2eda2c 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -391,7 +391,7 @@ static void update_backup_region_phdr(struct kimage *image, Elf64_Ehdr *ehdr) unsigned int i; phdr = (Elf64_Phdr *)(ehdr + 1); - for (i = 0; i < ehdr->e_phnum; i++) { + for (i = 0; i < ehdr->e_phnum; i++, phdr++) { if (phdr->p_paddr == BACKUP_SRC_START) { phdr->p_offset = image->arch.backup_start; kexec_dprintk("Backup region offset updated to 0x%lx\n", -- 2.52.0