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 C5CC6606A322 for ; Thu, 3 Dec 2026 06:32:26 +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=jgsCKqK4; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dTxcA0u+ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Cc:To:Subject: From:Message-ID:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=LsbmrEQu9zfnL9tBy7a2aU0qZFMhiF8RHl7POFZxJ60=; b=jgsCKqK4uZzF/+ICzQQbJ8rJiq qYbjFpAqB5WdVlkTbQHD8/xvlL2Ur+ZlnP07fqM1S29Db9wa2H+hn95DMMjpJjFNwqynOrj8pmQSf FpWUHEkbh8TBX71S7J6Y0qyBHp5NuH/8V/PMVRL3f71CwQnGD/h5lHxEnxeIJoCmBH7NUMajBnAEJ AJSSh9K0GzbxiCc9wQuYdJqzm7kFtzwIDliG3iiF/UJF+EgnfYeL6bW2p5GTU6Fp9mK1mms1pEw3o 8H0JANPhYtaWsJbKbZmhEkF+L1szACDDRQkqupZUfD/QcXJgBP6uaG2uGvdyiwr96IjXw9N3lE78k 9TkQzhEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ0Mk-0000000DfKF-29aq; Thu, 03 Dec 2026 06:32:26 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ0Mi-0000000DfJo-3Gdf for kexec@lists.infradead.org; Thu, 03 Dec 2026 06:32:24 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 274E8454E6; Thu, 3 Dec 2026 06:32:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF1E01F000C1; Thu, 3 Dec 2026 06:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796279544; bh=LsbmrEQu9zfnL9tBy7a2aU0qZFMhiF8RHl7POFZxJ60=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dTxcA0u+uUd+jd2DRebWJi3dtC0gi7H/CzUHsip+WrBNGdrIDKRDzmEvxEBgWTOGc j+Eej/Ng7Q0jCVuaWVZXDKyokeo6lTtVbgCLlmb9vFSFDS37OWpxSq9HMUxixhiktv +VEeVFuwgAI+2uTFK7HJvvuhrlM7k7FuPved8ktFLmeOCRhb/5yCUHfeqmFII4rXrD kKErcPNfFxKAug99BlCBqBf+ccagOTuLMguFtMrRYyo9+fM/0kKpnJIA93fDYMUBzs 2hKGslSH4iqO7N+7uBM+06C0GkJnzDifeGC89HJdrweG6XfywBbfVx87YmYy85LM9I JZMbvYHX52eEA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/2] kho: drop the handover if preserved memory can't be reserved To: "Chris Down" , rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org Cc: graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org, kernel-team@meta.com In-Reply-To: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name> References: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 06:32:23 +0000 X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "kexec" X-Spam-Status: No, score=-10.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_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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] kho: kho_init() uses is_kho_boot() instead of kho_in.bootmem_phys -- commit 43513d95ccfc673fefadf352275abd473f3def20 Author: Chris Down kho: drop the handover if preserved memory can't be reserved This commit checks the return values of memblock_reserve() and memblock_reserved_mark_noinit() in kho_preserved_memory_reserve(), drops the KHO handover in kho_mem_retrieve() if either fails, and makes reserve_mem_kho_revive() reserve its own region in memblock. > diff --git a/kernel/liveupdate/kho_core.c b/kernel/liveupdate/kho_core.c > index 43ecef317cfdf..a0429e85132bc 100644 > --- a/kernel/liveupdate/kho_core.c > +++ b/kernel/liveupdate/kho_core.c [ ... ] > @@ -1731,13 +1738,18 @@ static void __init kho_mem_retrieve(void) > const struct kho_radix_walk_cb cb =3D { > .leaf =3D kho_preserved_memory_reserve, > }; > + int err; > =20 > - if (kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL)) > + err =3D kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL); > + if (err) > goto err; > =20 > return; > =20 > err: > + pr_warn("failed to reserve preserved memory: %pe, disabling KHO revival= \n", > + ERR_PTR(err)); > + > /* > * Failed to initialize preserved memory. Clear FDT and radix so KHO > * users don't treat it as a KHO boot. [Severity: High] When kho_mem_retrieve() drops the handover by clearing kho_in.fdt_phys while leaving kho_in.bootmem_phys set, is_kho_boot() becomes false even though the kernel is running out of inherited bootmem. Does that cause kho_init() to mishandle kho_bootmem in two places that still check is_kho_boot() instead of kho_in.bootmem_phys? kernel/liveupdate/kho_core.c:kho_init() { if (is_kho_boot()) kho_account_incoming_bootmem(); ... if (kho_in.bootmem_phys) return 0; ... err_free_bootmem: kho_out.fdt =3D NULL; if (!is_kho_boot()) { for (int i =3D 0; i < kho_bootmem_cnt; i++) { void *start =3D __va(kho_bootmem[i].addr); void *end =3D start + kho_bootmem[i].size; free_reserved_area(start, end, -1, ""); } } } First, if kho_init() fails and jumps to err_free_bootmem after the handover was dropped, !is_kho_boot() is true and free_reserved_area() is called on the inherited kho_bootmem ranges, which are actively in use by the running kernel and already released to the buddy allocator by memblock_free_all(). Second, on the normal path, kho_init() skips kho_account_incoming_bootmem() because is_kho_boot() is false and then returns early at if (kho_in.bootmem_phys), leaving zone->cma_pages and totalcma_pages uncounted for the inherited MIGRATE_CMA bootmem pageblocks. Checking kho_in.bootmem_phys in both places would match the early return in kho_init(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796126791.gi= t.chris@chrisdown.name?part=3D2