From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C16911D5170; Thu, 28 May 2026 00:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779928948; cv=none; b=CWEpnmX/YdZ5YnYjYuUW9J+A+4LpyVxvsrhtQxiRLrNCgor0CVv+Af+Qs0kfv8ZhxrJ0Z+8vAvEWoaInTSD3QUG+oHQR/cK5xbwjoiLHwUTUlb+0VG6F0DL7+WvW1zyxIvuowSSik8KA+3S2K25GV1GIYnjVo8wifKhBp2R0t5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779928948; c=relaxed/simple; bh=/3/Y4dC8f8Oo3MANG/rgpdd/aiYsnfQIqPMhX19dU+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F2LYrHc0p3LC6FvZRKjRdQRhU3pIz4oI49PqZar84CyK6CbRl2Kb9o+T3GTronZs2Im+7oEYwQ0Mfk8YqPSAcLMGStW/ao3idSY0PiYAkBHZ3mWaIa8YBJuB34s1+52Me6g0o5iyhSlPXXItm41IKS1/0iFLitFuwpMwsN3D/T4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=NGmJL0OO; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="NGmJL0OO" Received: by linux.microsoft.com (Postfix, from userid 1241) id 335A720B716F; Wed, 27 May 2026 17:42:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 335A720B716F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1779928933; bh=e5nYKaNCeQT/DwcqeJQWCXYpZxCRsHAKcumYY0kdCcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NGmJL0OOZYP1NkGpncUVpqTRJll4ru23eY1btx1XhLvHqa5M9SYbNxXmXfey14qR4 TG6z/YMZg58z8hGpSdNlfnhM/0uqZxNjplYYGLtmIyiyYu7u8ARPtRnUG4Uaz/N/+7 NzTZxFKs7QTuzbMyG6zva5le+BF9QEX2AmSqkUug= From: Jork Loeser To: linux-hyperv@vger.kernel.org, linux-mm@kvack.org, kexec@lists.infradead.org Cc: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Alexander Graf , Jason Miu , Andrew Morton , David Hildenbrand , Muchun Song , Oscar Salvador , Baoquan He , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Kees Cook , Ran Xiaokai , Justinien Bouron , Sourabh Jain , Pingfan Liu , "Rafael J. Wysocki" , Mario Limonciello , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-kernel@vger.kernel.org, Michael Kelley , Jork Loeser Subject: [RFC PATCH 04/20] kho: add callback for table pages Date: Wed, 27 May 2026 17:41:46 -0700 Message-ID: <20260528004204.1484584-5-jloeser@linux.microsoft.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260528004204.1484584-1-jloeser@linux.microsoft.com> References: <20260528004204.1484584-1-jloeser@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-hyperv@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) Signed-off-by: Jork Loeser --- 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 b22b3cec251e..0f8d058f1a27 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.43.0