From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C649714EC77 for ; Thu, 9 Jan 2025 05:28:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736400494; cv=none; b=Id2XE01IfsIHzLuhA3GAwtJjiWsD+FqhBOWXxV86ISlhOvd10go0+X3ccJBvifv5VBe7A95ADW5Nd7U72/zaFbTvoFRqLgeaDJhuShUIG7tlj8GROu1NGActk1OUSMjfoktOFSpZQ0wwWgwW6hvXoGKRLYi8tZhRlLsX8NJr7lg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736400494; c=relaxed/simple; bh=JMzL7Jny9Qk/AWUNPZhjwmy7z3WhByQRQQvBVP0BM5M=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=aGX5lhzt2obhblyyMSm5BR8htj1tkJCJbNaBQS3Peqcc3QGbb2VDCMVut6nRQf3YrNcW3nSfQ7I5eiOPcqPhyVPsGhLCgkxZwtS4RJqIElAatmO7uKB9to0uUcm/fS7LH+kzESC4icWqGp2Ikm+EmtQ9CGb+jPzBnJjmW+lxjP8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=U+PgSr7t; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="U+PgSr7t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C924C4CED2; Thu, 9 Jan 2025 05:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1736400494; bh=JMzL7Jny9Qk/AWUNPZhjwmy7z3WhByQRQQvBVP0BM5M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=U+PgSr7tNogufpsgUKvrA3Lefa/H9gboswSYdrD6N96CPWFnk+1a6tF0Q0Ii9oUVE rvn1vkeI/CGuw+cMXoTOn9Iostx/N1URp4FtNDQ//DJvW2BBO0NSNPaHocyTeqeILZ n1/Z++kM5D2KOg0G0eVgwQvL1PPSIoUnB6WqMKjI= Date: Wed, 8 Jan 2025 21:28:13 -0800 From: Andrew Morton To: Sourabh Jain 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 Subject: Re: [PATCH] kexec: Initialize ELF lowest address to ULONG_MAX Message-Id: <20250108212813.ebc0014e384e9996ab72db40@linux-foundation.org> In-Reply-To: References: <20241210091314.185785-1-sourabhjain@linux.ibm.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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.