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 84249310629 for ; Tue, 23 Dec 2025 14:11:24 +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=1766499084; cv=none; b=gSrcspStBLmKMFdubJIbPRlTiLdVpIBuFs/a4SDAVV/Me0hUctthGvWl2sI6kmWnucNTxEsSOkwf+/uQXr5L6AxCXvtGxx0KA29n70utf+AkuGgdxgOf2w8RIEW/dYUjloU/qVSvDFqulzRysRcfV2ILNiOFioLnzA3v+gF+tLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766499084; c=relaxed/simple; bh=dZ53vjUX1HpldK0KbUzIHXXkt9MCtOBq99PLYBLG+Vo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=o6YDLQRqF6JQAnnaoIjg6EFlLR+eaRSSfl3Wx0NR31lmD24F2HeFa21UkpcMih/OSmOjS5ZwUtvcheLtDMLlwZpl84nZ6r4T+0fOzV9JPL8ujNwACF9mKMe39Pnicc4n99RlPORVASThnRFDldIcbPaNTU9EJzZqg7vzb7kCJ8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ud+384l+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ud+384l+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AA65C113D0; Tue, 23 Dec 2025 14:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766499084; bh=dZ53vjUX1HpldK0KbUzIHXXkt9MCtOBq99PLYBLG+Vo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ud+384l+yB+aELzmFdX7l8ibIN7y+5+njLdeHK50/JSiAcJyiiGlkjjdtAKjHeBD4 hoQuD1jM3uSCM4t9yQgEceDsegFq6IHknfeOcqrWnRbDrmwKbx/RA2TtkB+W9AIaWW voxc3Piq7yG30t/8HGvKwdBisNooq4awkV/1xR9nwZDAn86BqbV+te3BncQtbUoll3 MjnbP3UmazmSq+nS4COmTb0OMtg5b2lQ0qM6+wFgaUOohKM9E/7DLArNeo0fBID4QC GXqFpHbnzeiMJN9E79HfRc+ILd9QLcZVOFEqn6kc68RQBGIYIJXCqWSpdHOreAc7RR jNwu3Li3A/NVA== From: Pratyush Yadav To: Pasha Tatashin Cc: akpm@linux-foundation.org, rppt@kernel.org, graf@amazon.com, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, pratyush@kernel.org, ricardo.neri-calderon@linux.intel.com Subject: Re: [PATCH v4] kho: validate preserved memory map during population In-Reply-To: <20251223140140.2090337-1-pasha.tatashin@soleen.com> (Pasha Tatashin's message of "Tue, 23 Dec 2025 09:01:40 -0500") References: <20251223140140.2090337-1-pasha.tatashin@soleen.com> Date: Tue, 23 Dec 2025 15:11:18 +0100 Message-ID: <86y0mtb855.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, Dec 23 2025, Pasha Tatashin wrote: > If the previous kernel enabled KHO but did not call kho_finalize() > (e.g., CONFIG_LIVEUPDATE=n or userspace skipped the finalization step), > the 'preserved-memory-map' property in the FDT remains empty/zero. > > Previously, kho_populate() would succeed regardless of the memory map's > state, reserving the incoming scratch regions in memblock. However, > kho_memory_init() would later fail to deserialize the empty map. By that > time, the scratch regions were already registered, leading to partial > initialization and subsequent list corruption (freeing scratch area > twice) during kho_init(). > > Move the validation of the preserved memory map earlier into > kho_populate(). If the memory map is empty/NULL: > 1. Abort kho_populate() immediately with -ENOENT. > 2. Do not register or reserve the incoming scratch memory, allowing the new > kernel to reclaim those pages as standard free memory. > 3. Leave the global 'kho_in' state uninitialized. > > Consequently, kho_memory_init() sees no active KHO context > (kho_in.mem_chunks_phys is 0) and falls back to kho_reserve_scratch(), > allocating fresh scratch memory as if it were a standard cold boot. > > Fixes: de51999e687c ("kho: allow memory preservation state updates after finalization") > Reported-by: Ricardo Neri > Closes: https://lore.kernel.org/all/20251218215613.GA17304@ranerica-svr.sc.intel.com > Signed-off-by: Pasha Tatashin > Reviewed-by: Mike Rapoport (Microsoft) > Tested-by: Ricardo Neri Reviewed-by: Pratyush Yadav [...] -- Regards, Pratyush Yadav