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 E05454D90D4 for ; Wed, 29 Jul 2026 14:56:35 +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=1785336997; cv=none; b=gfC1hFo586xOLKXGi8cnyKavYDPieTSi8qExJro3C0sfL1GK3J5HSHkmKUARb/n9CKupWY+ntU1f7pxqrfN1nIxrUVTnw1vTu7MSAQYI6uXf4PdvoIfS8Ng3yzPVpJy5JP2IPCspQ5KL24RkoqdFrwH+hNoQqVzD/XeLuKV0et4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785336997; c=relaxed/simple; bh=q68uaZxQxVEAwwkiOVHXRfsAADqAblwGcH2tPzlKcFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Joj+44XZSbo43BRKXrWg5ZRwNlR2VLTBqy9WQCNq6NgynOAuHLiUyh0CeShka7naifZb/isG452n6pgk1XccH8bqskptLxks6VywDcYZbSDhKu1WllYkgEAYddHL67PRVbyKr3gIAffYVjR6j+JL0Le969m7DMtSQOyu2uT1OIE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ii4IyRWa; 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="ii4IyRWa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D60F1F000E9; Wed, 29 Jul 2026 14:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785336995; bh=sTy/SpRQxcylZAnkn90gwM+/FxNJUgUwYPXcYuU5Nao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ii4IyRWamnD4g01J74AwqlKxIWkrynFmn2QcQrVimnYszo5BagrZ+L7mELuEY9Czd irDaDWViQz/i/SJE6duuT+9iqZvBovpVPSjxhr4D7nM33E8sRrTjpD3hPkOHJNAwmI E7PcaU6r37Vy8OeBfQc/8K/UyoSl4JXa6oymUsCPdgD7ZP+jtX2IaX/hWoOl8f11m/ O25E6yCG3N4cLRKc5LiqCASvm4OeBDIJkIkAXERC7J5NJw3UF1sCC1vtI1Ew5tqAKo 7jwx+GyTQDC2snYdndIkRMoMBi+wXAUbrs+jL8p7m7gTuNnN9lW66oqpAL07a/sVRo 1ofFWUSw+x9CA== From: Pratyush Yadav To: Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Alexander Graf , Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Jason Miu , Jork Loeser Cc: kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 05/22] kho: store incoming radix tree in kho_in Date: Wed, 29 Jul 2026 16:55:50 +0200 Message-ID: <20260729145610.2827231-6-pratyush@kernel.org> X-Mailer: git-send-email 2.55.0.508.g3f0d502094-goog In-Reply-To: <20260729145610.2827231-1-pratyush@kernel.org> References: <20260729145610.2827231-1-pratyush@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pratyush Yadav (Google)" This allows other functions to also use the radix tree. While at it, also use kho_get_mem_map_phys() instead of duplicating the code to get the radix tree root from the FDT. Signed-off-by: Pratyush Yadav (Google) --- kernel/liveupdate/kexec_handover.c | 32 ++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index 5c35c11c273b..b53ae68ca087 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1337,6 +1337,7 @@ struct kho_in { char previous_release[__NEW_UTS_LEN + 1]; u32 kexec_count; struct kho_debugfs dbg; + struct kho_radix_tree radix_tree; }; static struct kho_in kho_in = { @@ -1416,24 +1417,15 @@ EXPORT_SYMBOL_GPL(kho_retrieve_subtree); static int __init kho_mem_retrieve(const void *fdt) { - struct kho_radix_tree tree; - const phys_addr_t *mem; - int len; - - /* Retrieve the KHO radix tree from passed-in FDT. */ - mem = fdt_getprop(fdt, 0, KHO_FDT_MEMORY_MAP_PROP_NAME, &len); - - if (!mem || len != sizeof(*mem)) { - pr_err("failed to get preserved KHO memory tree\n"); - return -ENOENT; - } - - if (!*mem) - return -EINVAL; - - tree.root = phys_to_virt(*mem); - mutex_init(&tree.lock); - return kho_radix_walk_tree(&tree, kho_preserved_memory_reserve); + /* + * kho_get_mem_map() should always succeed. If it fails, kho_populate() + * catches that and never sets kho_in.scratch_phys, which stops memory + * retrieval. + */ + kho_in.radix_tree.root = kho_get_mem_map(fdt); + mutex_init(&kho_in.radix_tree.lock); + return kho_radix_walk_tree(&kho_in.radix_tree, + kho_preserved_memory_reserve); } static __init int kho_out_fdt_setup(void) @@ -1640,8 +1632,10 @@ void __init kho_memory_init(void) if (kho_in.scratch_phys) { kho_scratch = phys_to_virt(kho_in.scratch_phys); - if (kho_mem_retrieve(kho_get_fdt())) + if (kho_mem_retrieve(kho_get_fdt())) { kho_in.fdt_phys = 0; + kho_in.radix_tree.root = NULL; + } } else { kho_reserve_scratch(); } -- 2.55.0.508.g3f0d502094-goog