From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp.subspace.kernel.org (Postfix) with ESMTPS id C513C33C9 for ; Thu, 9 Jan 2025 05:32:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736400756; cv=none; b=tP/f5378RYTaK3Tr0rBIwhPBOYJWzPZhBT9UbfwUHbNGmXEAm089alDCMr5tUO9aZdgyByYFXOKq6vk+p9Agd+DymdjzZmnLjmCSLdPhUdsKzJzXQ1Z6MPSb8VQWtAOogyD5175A3947E52PfcYUUvh7nXJIT/1DBSO4kRkh9j4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736400756; c=relaxed/simple; bh=GjiJxeyjCAhwGoRa7ZuRhHuRb5GPlvFdD3uIUBYSRh4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aQqTL61s+UPEJBxRGMhRLilbi0MqAcCzm53jftgwJgmYHgAij8Hr6AArOtKk+GebYupSlo1NYezL4kNq3oSVPFf1dL1WwZ+P9hVV1WP0gsFRe62nCH/YEDy/Y3aaK+ZNLqXWY1VKeZc8163STbOU8p/0x475UpuNbtttk9QjePA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=nbHkyLGS; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="nbHkyLGS" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 508Nx5Sk017951; Thu, 9 Jan 2025 05:32:17 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=h5j9sM 6ZygV6v/cZEi3e0Oz3FL1wLmqSFPtHaDymFco=; b=nbHkyLGS//ZO/uZG07+aBh 3l3E1fwMlY0/zZ98hcYe9aQMNUWJ/uDYrvgJUs9F2RsIgZzMVXRfDKBwnOFCpo72 XnneLjhgCMrmYgamp40G3ZBivYcSSeDoaBMDPVIp+gVoMiXzYMANbYSXi1z8D3AU gILv05gAyBr9vv67vbmYFIdcL6/spPXYxntK8YbSDjxAg57W91RtZFZFBNs8NVP3 SV68vj9LBWEfrMqMramHm53zBMhQaGXTkI1xlDbYJD6YnyqWz2sapbsESkuG/oX4 FL1XIr26HnD0QeX8imzHc9i+YrdvN6nN+L3Ymdtgkh+JSzGob2bOokD0JZb2mDDg == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4423ghs47e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jan 2025 05:32:17 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5093IKj7004143; Thu, 9 Jan 2025 05:32:16 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 43yfatbt2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jan 2025 05:32:16 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5095WD6i49217824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Jan 2025 05:32:13 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0820D2004B; Thu, 9 Jan 2025 05:32:13 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5852620049; Thu, 9 Jan 2025 05:32:10 +0000 (GMT) Received: from [9.43.18.121] (unknown [9.43.18.121]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 9 Jan 2025 05:32:10 +0000 (GMT) Message-ID: <5c814eef-b4e4-4afc-a394-c17857da8a07@linux.ibm.com> Date: Thu, 9 Jan 2025 11:02:08 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] kexec: Initialize ELF lowest address to ULONG_MAX To: Andrew Morton Cc: Baoquan he , ebiederm@xmission.com, Hari Bathini , Madhavan Srinivasan , Michael Ellerman , kexec@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20241210091314.185785-1-sourabhjain@linux.ibm.com> <20250108212813.ebc0014e384e9996ab72db40@linux-foundation.org> Content-Language: en-US From: Sourabh Jain In-Reply-To: <20250108212813.ebc0014e384e9996ab72db40@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: WTn7GuVs0jUb3wRC6a6crfU-Oz7_JEjL X-Proofpoint-ORIG-GUID: WTn7GuVs0jUb3wRC6a6crfU-Oz7_JEjL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 mlxscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501090043 Hello Andrew, On 09/01/25 10:58, Andrew Morton wrote: > On Thu, 9 Jan 2025 09:42:14 +0530 Sourabh Jain wrote: > >> Hello Baoquan and Eric, >> >> >> On 12/12/24 08:25, Baoquan he wrote: >>> On 12/10/24 at 02:43pm, Sourabh Jain wrote: >>>> kexec_elf_load() loads an ELF executable and sets the address of the >>>> lowest PT_LOAD section to the address held by the lowest_load_addr >>>> function argument. >>>> >>>> To determine the lowest PT_LOAD address, a local variable lowest_addr >>>> (type unsigned long) is initialized to UINT_MAX. After loading each >>>> PT_LOAD, its address is compared to lowest_addr. If a loaded PT_LOAD >>>> address is lower, lowest_addr is updated. However, setting lowest_addr >>>> to UINT_MAX won't work when the kernel image is loaded above 4G, as the >>>> returned lowest PT_LOAD address would be invalid. This is resolved by >>>> initializing lowest_addr to ULONG_MAX instead. >>>> >>>> This issue was discovered while implementing crashkernel high/low >>>> reservation on the PowerPC architecture. >>>> >>>> Fixes: a0458284f062 ("powerpc: Add support code for kexec_file_load()") >>>> Cc: Baoquan he >>>> Cc: Hari Bathini >>>> CC: Madhavan Srinivasan >>>> Cc: Michael Ellerman >>>> Cc: kexec@lists.infradead.org >>>> Cc: linuxppc-dev@lists.ozlabs.org >>>> Cc: linux-kernel@vger.kernel.org >>>> Signed-off-by: Sourabh Jain >>>> --- >>>> kernel/kexec_elf.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/kernel/kexec_elf.c b/kernel/kexec_elf.c >>>> index d3689632e8b9..3a5c25b2adc9 100644 >>>> --- a/kernel/kexec_elf.c >>>> +++ b/kernel/kexec_elf.c >>>> @@ -390,7 +390,7 @@ int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, >>>> struct kexec_buf *kbuf, >>>> unsigned long *lowest_load_addr) >>>> { >>>> - unsigned long lowest_addr = UINT_MAX; >>>> + unsigned long lowest_addr = ULONG_MAX; >>> Great catch. >>> >>> Acked-by: Baoquan He >> Thank you for the Ack! The upcoming two patch series, which aim to >> enable generic crashkernel reservation, depends on this fix. One of them >> is already posted for upstream review: >> https://lore.kernel.org/all/20250108101458.406806-1-sourabhjain@linux.ibm.com/ >> I was wondering if you could guide us on how to get this fix pushed to >> the mainline tree. > Please include this patch (with Baoquan's ack) in whichever tree > contains the powerpc patches which depend upon it. Sure, I will include this patch in the respective patch series. Thanks, Sourabh Jain