From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E6C773101A9 for ; Thu, 21 May 2026 22:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779401672; cv=none; b=LKB/Ts3+NrLdZrbd9QTiiKhDCGY3SBdzmyeXRAUXzfa1tOZahrQuu/2RZYYBWrQmODJhStruQJZmpcm0xOWlburn8RG0u1eUeDQHXB/ylZbgY7VkPmriC7yZvRl/Z8RJKmKFuihz9xN0mTiKM6KpyClnSM1LugbWiLW9w0J/dLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779401672; c=relaxed/simple; bh=d00LJZof55OJIdYmxr13oHM/N9+LciweqzgL1DBZ1Jo=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=ppqz61DS58ufO+ERKEaXHcNX86covm1Kj/3JRRRgYkDL+KlKOTvSo7BSlYUYYtu0fvczUl2TqOSEu/lokwknsAn/fpuHeERfcWf5yD8PIprwEMRGplpP30TlBJmqN9JfozkfYwLi654LxyMwxu1U63za2Bpa1pjPnPsJLew4Cow= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wl/Ez9PS; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wl/Ez9PS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA28B1F000E9; Thu, 21 May 2026 22:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779401670; bh=U57C2uRBVxiF1fTTpjeW1yofBxseUWTqJnzoC6A2llg=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=Wl/Ez9PSLXBQpkpIn8uMl3Ha9uN46Wo0EdmNVjzPguBJcfUL0IHjr1M9WyXOm5TcW Ql9oYpX7MIlg9EECKjR6cyuSXlj+1k48snkkejN3drEHk5um+1chfVTE/7YoYoXHP5 4su8Yhf3bEH8sJJfMAxgz28TxnZalBNG8ZrO8Q1/1FJMfh2MIyPanqCxfkWPr/oHVv Z2g/2bnQcMdl9rDo8ez9HQzUuzeVVpnXpEO2JSnApjwcBp1049vVzxi1KnKcqBM88I kRjuCY6jxZ1N9q4/RO4ZqZtdA0uMekirlUXvxRO2qGFBYyC/QMLeZMEfNs79/LtECy KkpYM8hYT9mMg== Date: Thu, 21 May 2026 16:14:27 -0600 (MDT) From: Paul Walmsley To: Han Gao cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Song Shuai , =?ISO-8859-15?Q?Bj=F6rn_T=F6pel?= , Breno Leitao , Kees Cook , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Han Gao Subject: Re: [PATCH] riscv: kexec_file: Constrain segment placement to direct map In-Reply-To: <20260519170641.123517-1-gaohan@iscas.ac.cn> Message-ID: <4f1d7f4e-e2a3-9d9e-4116-861f037f2799@kernel.org> References: <20260519170641.123517-1-gaohan@iscas.ac.cn> 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 On Wed, 20 May 2026, Han Gao wrote: > When kexec_file_load places segments with buf_max=ULONG_MAX and > top_down=true, they land at the highest available physical addresses. > On RISC-V the size of the linear mapping is determined by the active > VM mode: SV39 caps the direct map at roughly 128GB, while SV48/SV57 > extend the range substantially further. When the installed physical > memory exceeds the direct map size of the active mode, top-down > placement puts DTB/initrd at physical addresses outside the linearly > mapped region. The kexec'd kernel cannot reach them during early > boot, triggering a page fault at memcmp in start_kernel. > > Fix by constraining buf_max to PFN_PHYS(max_low_pfn), which reflects > the runtime direct map boundary for the active VM mode (SV39/SV48/ > SV57). This keeps all kexec segments within the linearly mapped > region while preserving the upstream top_down allocation strategy. > > Signed-off-by: Han Gao Thanks, queued for v7.1-rc. - Paul