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: remove abort functionality and support state refresh

Previously, KHO required a dedicated kho_abort() function to clean up
state before kho_finalize() could be called again. This was necessary to
handle complex unwind paths when using notifiers.

With the shift to direct memory preservation, the explicit abort step is
no longer strictly necessary.

Remove kho_abort() and refactor kho_finalize() to handle re-entry. If
kho_finalize() is called while KHO is already finalized, it will now
automatically clean up the previous memory map and state before generating
a new one. This allows the KHO state to be updated/refreshed simply by
triggering finalize again.

Update debugfs to return -EINVAL if userspace attempts to write 0 to the
finalize attribute, as explicit abort is no longer supported.

Link: https://lkml.kernel.org/r/20251114190002.3311679-10-pasha.tatashin@soleen.com
Suggested-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Baoquan He <bhe@redhat.com>
Cc: Coiby Xu <coxu@redhat.com>
Cc: Dave Vasilevsky <dave@vasilevsky.ca>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Kees Cook <kees@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pasha Tatashin and committed by
Andrew Morton
9a4301f7 efa3a977

+5 -19
+4 -17
kernel/liveupdate/kexec_handover.c
··· 1232 1232 } 1233 1233 EXPORT_SYMBOL_GPL(kho_restore_free); 1234 1234 1235 - int kho_abort(void) 1236 - { 1237 - if (!kho_enable) 1238 - return -EOPNOTSUPP; 1239 - 1240 - guard(mutex)(&kho_out.lock); 1241 - if (!kho_out.finalized) 1242 - return -ENOENT; 1243 - 1244 - kho_update_memory_map(NULL); 1245 - kho_out.finalized = false; 1246 - 1247 - return 0; 1248 - } 1249 - 1250 1235 static int __kho_finalize(void) 1251 1236 { 1252 1237 void *root = kho_out.fdt; ··· 1282 1297 return -EOPNOTSUPP; 1283 1298 1284 1299 guard(mutex)(&kho_out.lock); 1285 - if (kho_out.finalized) 1286 - return -EEXIST; 1300 + if (kho_out.finalized) { 1301 + kho_update_memory_map(NULL); 1302 + kho_out.finalized = false; 1303 + } 1287 1304 1288 1305 ret = __kho_finalize(); 1289 1306 if (ret)
+1 -1
kernel/liveupdate/kexec_handover_debugfs.c
··· 87 87 if (val) 88 88 return kho_finalize(); 89 89 else 90 - return kho_abort(); 90 + return -EINVAL; 91 91 } 92 92 93 93 DEFINE_DEBUGFS_ATTRIBUTE(kho_out_finalize_fops, kho_out_finalize_get,
-1
kernel/liveupdate/kexec_handover_internal.h
··· 24 24 25 25 bool kho_finalized(void); 26 26 int kho_finalize(void); 27 - int kho_abort(void); 28 27 29 28 #ifdef CONFIG_KEXEC_HANDOVER_DEBUGFS 30 29 int kho_debugfs_init(void);