Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kho: don't unpreserve memory during abort

KHO allows clients to preserve memory regions at any point before the KHO
state is finalized. The finalization process itself involves KHO
performing its own actions, such as serializing the overall preserved
memory map.

If this finalization process is aborted, the current implementation
destroys KHO's internal memory tracking structures
(`kho_out.ser.track.orders`). This behavior effectively unpreserves all
memory from KHO's perspective, regardless of whether those preservations
were made by clients before the finalization attempt or by KHO itself
during finalization.

This premature unpreservation is incorrect. An abort of the finalization
process should only undo actions taken by KHO as part of that specific
finalization attempt. Individual memory regions preserved by clients
prior to finalization should remain preserved, as their lifecycle is
managed by the clients themselves. These clients might still need to call
kho_unpreserve_folio() or kho_unpreserve_phys() based on their own logic,
even after a KHO finalization attempt is aborted.

Link: https://lkml.kernel.org/r/20251101142325.1326536-7-pasha.tatashin@soleen.com
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>
Cc: Changyuan Lyu <changyuanl@google.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Simon Horman <horms@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Zhu Yanjun <yanjun.zhu@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pasha Tatashin and committed by
Andrew Morton
99cd2ffa ce405ed5

+1 -20
+1 -20
kernel/kexec_handover.c
··· 1119 1119 1120 1120 static int __kho_abort(void) 1121 1121 { 1122 - int err = 0; 1123 - unsigned long order; 1124 - struct kho_mem_phys *physxa; 1125 - 1126 - xa_for_each(&kho_out.track.orders, order, physxa) { 1127 - struct kho_mem_phys_bits *bits; 1128 - unsigned long phys; 1129 - 1130 - xa_for_each(&physxa->phys_bits, phys, bits) 1131 - kfree(bits); 1132 - 1133 - xa_destroy(&physxa->phys_bits); 1134 - kfree(physxa); 1135 - } 1136 - xa_destroy(&kho_out.track.orders); 1137 - 1138 1122 if (kho_out.preserved_mem_map) { 1139 1123 kho_mem_ser_free(kho_out.preserved_mem_map); 1140 1124 kho_out.preserved_mem_map = NULL; 1141 1125 } 1142 1126 1143 - if (err) 1144 - pr_err("Failed to abort KHO finalization: %d\n", err); 1145 - 1146 - return err; 1127 + return 0; 1147 1128 } 1148 1129 1149 1130 int kho_abort(void)