From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7DE763FE65C for ; Wed, 29 Apr 2026 13:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777469995; cv=none; b=kb4sIW3br7YCsWNqHn0RgCmo+wHYgCjMAUgnRXvWogzBnnjoFXfd220lc/zsOCt1TkuwK4PTWfAS+t0HdMXFxPbUHAPIdSimsESVleyviHJqB8tIm1UqXp3OOpt7HCybQkVcmCGLW19ZMHchBlOeqQA8LQ898YMwf0+YaCzndaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777469995; c=relaxed/simple; bh=sDZpiRzsQemL+9DqGDzdUHvJ8tPGWBEbveTIR7Y1hd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UYwCNiMerYy1piM34IA2hWbzE76RoJOdUEKxwapwLlXPCA5QHUYLLa+p/BP9OuixKBlcJ73/h4lR/iE2SvBKd0XBzl9xboyJz0HosuSZ8QUliHIy9hq8rEOX2fVHnWhFlCoHL7s2WOE5fUzlK4Ra6ycLTHHPfhAVmDlOv/73atY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pJMgz7rA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pJMgz7rA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8B84C2BCF5; Wed, 29 Apr 2026 13:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777469993; bh=sDZpiRzsQemL+9DqGDzdUHvJ8tPGWBEbveTIR7Y1hd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pJMgz7rANvW3gltIkCoxOmN4OeT/8No7Cp1LNZNgfeI0ERfnTBJV7X5VA9FsFlsBQ AkoG4qksc3arluR9/BXwUeN2v8vDomDJR4s/cIZa61IvEufufumwfXANLiu0VTO9Ar 4/rks236tYY0G6/gif4nwLOVloLD0TccVWymjdpcOWyoEe4YaiOykti2NUgoYASke7 MhRh3K1y4/v+UR4paeYbNAfM3yinnlpo3/1VnW3jG/w+lW2cbiU+7I3kPHDGNCLOgj IAN0zzX3m1ic3nirBkZDMHk++ARwWtCfZT1pisHHN79hfyYM3M01Lkc2epsT+rhWtK /2IZuGHxw9WIg== From: Pratyush Yadav To: Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Alexander Graf , Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Jason Miu Cc: kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/12] kho: add callback for table pages Date: Wed, 29 Apr 2026 15:39:06 +0200 Message-ID: <20260429133928.850721-5-pratyush@kernel.org> X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog In-Reply-To: <20260429133928.850721-1-pratyush@kernel.org> References: <20260429133928.850721-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)" The KHO memory preservation radix tree does not mark the table pages themselves as scratch. This is done to avoid a circular dependency where preserving a page can lead of allocating other preserved pages. This means any walker looking for free ranges of memory outside of scratch areas will ignore the table Add a table callback that is invoked for each table page. The callback is given the physical address of the table page. Signed-off-by: Pratyush Yadav (Google) --- include/linux/kho_radix_tree.h | 3 +++ kernel/liveupdate/kexec_handover.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/kho_radix_tree.h b/include/linux/kho_radix_tree.h index 030da6399d28..fe7151d89361 100644 --- a/include/linux/kho_radix_tree.h +++ b/include/linux/kho_radix_tree.h @@ -37,12 +37,15 @@ struct kho_radix_tree { /** * struct kho_radix_walk_cb - Callbacks for KHO radix tree walk. * @key: Called on each present key in the radix tree. + * @table: Called on each table of the radix tree itself. Receives the + * physical address of the page containing the table. * * For each callback, a return value of 0 continues the walk and a non-zero * return value is directly returned to the caller. */ struct kho_radix_walk_cb { int (*key)(unsigned long key); + int (*table)(phys_addr_t phys); }; #ifdef CONFIG_KEXEC_HANDOVER diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index 4a5d1b47799c..94ca831b41c9 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -273,6 +273,12 @@ static int kho_radix_walk_leaf(struct kho_radix_leaf *leaf, unsigned long key, unsigned int i; int err; + if (cb->table) { + err = cb->table(virt_to_phys(leaf)); + if (err) + return err; + } + if (!cb->key) return 0; @@ -295,6 +301,12 @@ static int __kho_radix_walk_tree(struct kho_radix_node *root, unsigned int shift; int err; + if (cb->table) { + err = cb->table(virt_to_phys(root)); + if (err) + return err; + } + for (i = 0; i < PAGE_SIZE / sizeof(phys_addr_t); i++) { if (!root->table[i]) continue; -- 2.54.0.545.g6539524ca2-goog