From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8380F606A32D for ; Thu, 3 Dec 2026 11:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=g1fUoTK8; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GySA0bjL DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=WYeKrjK28/E/GfsD0CQu6pm7FaEOC/CtDV6OTZ+zuqA=; b=g1fUoTK8Ojx0bCGOuL1f7aJ/6a owcLuQZTX2PYi+kt3yICAkgOQ/7+TlnzrUMQ9mwgHiLt6otX5ywmaijc6A8aSIdu5mWKJK8beBEVz Jdv/nSAW08ACszwArR28l9HO1oAyJeHIDG4gsVIu+ajg93gKLrlumzAW0xEp3wJR1YCoDcMzzcuGb hWgHO84kvzKNNGqv1ZQl9j0PLMvIThieArad9Z8y9RPJWwmulziR3rkzDh8rUBPyMybhcM/l8xkVN Q1u1MBLUjc98/f39PFWVuB17eFKRTRjG3BkSA8mQ3y+HbNrWir4cJbI6PdQTyXds20voZgH+8mILn EZNipVVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ5R5-0000000EUQS-0Hwh; Thu, 03 Dec 2026 11:57:15 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ5R3-0000000EUPk-2ODs for kexec@lists.infradead.org; Thu, 03 Dec 2026 11:57:13 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 98E4861E99; Thu, 3 Dec 2026 11:57:11 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name> X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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.