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 905B73D1A98 for ; Fri, 5 Jun 2026 18:35:22 +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=1780684524; cv=none; b=CVK0Nwg8EPtzjNO0jlNQSIQhKBambIh4xDNgZfKYAkNh6zEeSX6BxynuyEKZk/3JWiVpAUXu21A4WLiY7mKJ66UA3Wl1PiqTsET2wFNIX/OPIo1VOfl4kCQ9ZvfbEA7hW6whZu17d8X3ncimxu1EdGtpxg5eIBCkxM0ca/CdYig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780684524; c=relaxed/simple; bh=M+4ZPwpYY+sNv/R8x76iTgCcpNLWjGm2xLtnh+Pu08E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ea/f92aDiD3MKjU8KECYzEcTTdv2kAaVW8sOiLKJbxVN8EYIZbub5TZmkBgEMN0d53oFKDi1hkuTWho2iiyiM0zadZ2xiBzc+YoJYJkp5lJvKjR0OupSeA50RLiRnhJs8CmKJU/6oRFJemviVjPrr2CPgmOQrk+Jf6STXuznz58= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MPgdUrBe; 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="MPgdUrBe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E09D1F00893; Fri, 5 Jun 2026 18:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780684522; bh=v/RGerRyxm8aTVCl41zoP38L2i7Ee87yOlG4ezqSjQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MPgdUrBersvdIeiDJvd3LrUzlJMbmXc7u1YjP1PjvngfbnOg1wTMed/fISSH2vkVk eBSrWcyzbcOa0R9swpxLwaqTyUddu6ao3yUL8xKCDAN+N9Gp2VQqeXfynMFPggmv++ hMyo7fR3rde1IXG7mxJf3wKg9r9gOR/rJCgkI6xqG6n0sbmCkqc+B0kk/++ipOEwBF F7lKau1V1WtMfkSYGEK6vZYrTjxT5GZtaxWGKT8dPb/DE3jaKX3IuvrYdl1M27/k8F cwBxsx9XgdMuGiqDZMQ6GidAqfuioEjCuFMdGwOI1CaYau8zZ272Azz3K2wTHrBDDH Mjp/oWSKjc6DQ== 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 v2 04/18] kho: store incoming radix tree in kho_in Date: Fri, 5 Jun 2026 20:34:37 +0200 Message-ID: <20260605183501.3884950-5-pratyush@kernel.org> X-Mailer: git-send-email 2.54.0.1032.g2f8565e1d1-goog In-Reply-To: <20260605183501.3884950-1-pratyush@kernel.org> References: <20260605183501.3884950-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 d8dd0ede4f87..61e436f5077e 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1334,6 +1334,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 = { @@ -1413,24 +1414,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) @@ -1637,8 +1629,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.54.0.1032.g2f8565e1d1-goog