From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B02EEC44506 for ; Thu, 9 Jul 2026 17:38:47 +0000 (UTC) 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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=riMC6FrAK6VElTWN873G6mpWEL50ijB4MWBDV4uQp84=; b=SK+NUVd4EGgJdQd6MrLjuLkxBq KaSWz1vevhd0ylRqOKoqhHG3XFiKVkHH8wbygvfhLjl1qHXn9uKYgNdNguX1Khe4S4VkHjWjtjAvK tczL0z3/ssR6qTKjJCpK+Xl2s+KLWnTSsle5Xoci6qNo4/AYymXHPIjqeUCBFtuSNBtvymF5wlS/+ FrvdTPMuHsFt6v7uDz9VzeEAIwkEgvFfl9J1K/vMFQN8sivT4iBT2+bPwSQshnqJCdxthooZ/0ofF qx4LB26BzU6dCIeHiMWl2Pv6NYZtfSs2w6VMQSue0ekri1hAM7VSrZvzC6hsTsDEKNym/XCqH+I0n qliVTg9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1whshy-0000000384m-3yeF; Thu, 09 Jul 2026 17:38:46 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1whshx-0000000383s-49EG for kexec@lists.infradead.org; Thu, 09 Jul 2026 17:38:46 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 6CC706187C; Thu, 9 Jul 2026 17:38:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F40011F00A3A; Thu, 9 Jul 2026 17:38:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783618725; bh=riMC6FrAK6VElTWN873G6mpWEL50ijB4MWBDV4uQp84=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z0iXjBTsR5wGA5kMrETM5gowhRr8IaK972IkfXU+BAYfsmBwLm1jAl289uRYIkimL D44uq7rbFJKKGGZLusa9ZCoECzyZTt5L2NWFQg7ob9XxUkE11vhslTk2W3FZTPU3MF c9+yeiZUGiquBWzK0Awll6AZUSDJbeb2vRmQm7aj0f9Zyh1QV6GwOv9IJhqIKpSIql H3uNUtVva3OLjtgvXjv6l+gqOufJp7vg5PesaUCcZLMvAjtOHNxhd9Mc7l3wiaL2Pz 1/+82Qg9Y9zkk2BO00T7zlDM13aWdeG3xWxW4b12MoXfOea3Q65A6lDijR34NycxMU aiumvSM67xYOg== 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 v3 05/21] kho: store incoming radix tree in kho_in Date: Thu, 9 Jul 2026 19:37:54 +0200 Message-ID: <20260709173821.429921-6-pratyush@kernel.org> X-Mailer: git-send-email 2.55.0.141.g00534a21ce-goog In-Reply-To: <20260709173821.429921-1-pratyush@kernel.org> References: <20260709173821.429921-1-pratyush@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org 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.141.g00534a21ce-goog