From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796299031; b=qJLQwqCKfe2Z33Om7Nj1qtPna3DQx+hgNWNgil1PITkmlurcV9l8z5PQBsM7m9BuPK4m A5yWQrjmM0OSct4f4qUpZw4nNWpq7uWl/yEH1cQM//w1XZAbypvvXROFVdXtZaOZbPZ96 tfBpn/0n5X9UbedCOGdhoCFNXEh04Ox6b7aaGbdSw9sqoAhULv6Msb3xEotgLbE1bOyzK 3KaLHRzwEuKIFxhuQg0aLvB2OEAcdoc1uIGTENSnlVPOPAm7XQ/KDhFrfgXASvhuYepOj ReR8/6BwFYIA20H/AKZ+l4ezBs6OA87dup/DxTrPZzJuyIo93PVt1Qy2MnEQTU6N9Ig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299031; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=WYeKrjK28/E/GfsD0CQu6pm7FaEOC/CtDV6OTZ+zuqA=; b=tgTk07qNk3m580eYhF3DSwdebn/FadWTvpUKtw/l+aQhPDcSTKcAN/aYL9CiBcDGhk8K dkSz7d0pgoVuBju1Y/5hgzN4D4GcLWypVwIm2Y5kHRGe/mCXEfeDASyHYbY4NfXUCgC5Z S3l+xTNew6CHpiADL+IG/JOm63uMAZ7KRy5eGscHKuO8897pWljf/0tctBlTaT5aMJbz+ 6MbpVaCqSn8Z9s6MTbA09YOjjeCCfSh9207/a+8uc3UqrlISDfNeXF7ZBgWDTEHRfQgHs vkvrTMfb8HIYPVGwXBiz0p1kyLeoIfas3491/vb8i84BaWQfkDSCfJS/wMERxt/3WXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GySA0bjL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (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 74CA2606A32D for ; Thu, 3 Dec 2026 11:57:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GySA0bjL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 956F81F00893; Thu, 3 Dec 2026 11:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796299031; bh=WYeKrjK28/E/GfsD0CQu6pm7FaEOC/CtDV6OTZ+zuqA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=GySA0bjL2qnkYHFwfnWrP03czmQhIOZXvjP5OWlL5xsAc7mOLRFjyKkOk3C3+Hmjl CnJP53PW3GRAOYhB3j8YfH3DVu6Bu6+Pkn5kkxTk4JHJubb86BZx/tsMFF/Ei7ckRv LaigMwr0I4oLt2PEbvgwwdadEV2PBio9xTdaFWwcRiDs5CVTeIfsbtcdrMlSGlMp4L YS2Rz+FGk6HB2a7UvhGa2k/XhqMtsld+s61j4rUD+aw/CadsyPHpKGc/f8+iOSpuur J615zNdvY2XB85+fKMvLo19pcWEQZFROHd4TPyOlcAry94FXb45Y/xrqRa5bywuYbm xgfWrlWeVdQpQ== Date: Thu, 3 Dec 2026 13:57:04 +0200 From: Mike Rapoport To: Chris Down Cc: pasha.tatashin@soleen.com, pratyush@kernel.org, graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2 2/2] kho: drop the handover if preserved memory can't be reserved Message-ID: References: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name> Hi Chris, On Tue, Dec 01, 2026 at 10:32:11PM -0800, Chris Down wrote: > kho_preserved_memory_reserve() reserves each range of preserved memory > in memblock and marks it noinit, but ignores both return values. Either > can fail when memblock has to grow its reserved array and can't find > room for the new one, which is unlikely but possible. The boot then > goes on as if the range were reserved, and two things can follow: Do you mind adding a few words about how unlikely it is? :) > - If the reservation failed, memblock_free_all() hands the range to the > page allocator with the previous kernel's data still in it, while its > KHO user still expects to restore it. A memfd preserved through LUO > can then get back pages that belong to someone else. Oh dear! > - If only the noinit marking failed, the struct pages can be > initialised later, wiping the KHO magic, so restoring the range fails. > > Let's return the error instead. The walk then stops, and > kho_mem_retrieve() logs the failure and drops the handover. The boot > carries on without it. Ranges that the walk had already reserved stay > reserved, since freeing them would need the same array growth that > just failed. The rest of the preserved memory is released like any > other free memory. > > reserve_mem= revives its regions from the handover before > mm_core_init(), and relies on the walk to reserve them. They have to > stay reserved when the handover is dropped, so make > reserve_mem_kho_revive() reserve its region itself. > > Fixes: fc33e4b44b27 ("kexec: enable KHO support for memory preservation") > Signed-off-by: Chris Down > --- > kernel/liveupdate/kho_core.c | 18 +++++++++++++++--- > mm/memblock.c | 8 ++++++++ > 2 files changed, 23 insertions(+), 3 deletions(-) -- Sincerely yours, Mike.