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 C9E4DC54F55 for ; Wed, 29 Jul 2026 14:56:38 +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=sTy/SpRQxcylZAnkn90gwM+/FxNJUgUwYPXcYuU5Nao=; b=IoJBZaGpOALbqlO7wD41kYXXr2 3H5emD7l4+HIesicoiJKDx0io306UwrXmzOmCLkknMCTpNWGbCfLeHE3OPrPWN6KVyMEN+RA7Qkk8 oZx2yMIdCY4LgnDpqGN14KMcUIyhhXKX9WxfTcESsxlaH8JbQHGnb1gv/QeIMEjYIfBItTbn4z0AH G1TUgzJ17AAOaD4GdDJWzePkfMCw5pOtWyQJqhBhZwbDguZzxwNA7S03FCx+NGUi9rxBG4+OmUmFd XfvasbN57U431OpZIekpxvuBMcPBPTm23Jqq6wAs29o93SnE7DyL5IO53Typqqe5EA8y2oXaoLwSD Z6rKuo1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wp5i1-00000008J27-2srq; Wed, 29 Jul 2026 14:56:37 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wp5i0-00000008J0x-1hC5 for kexec@lists.infradead.org; Wed, 29 Jul 2026 14:56:36 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id D3256600B1; Wed, 29 Jul 2026 14:56:35 +0000 (UTC) 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> 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.508.g3f0d502094-goog