mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Down <chris@chrisdown.name>
To: rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org
Cc: graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: [PATCH v2 2/2] kho: don't fail kho_init() when debugfs is disabled
Date: Sat, 28 Nov 2026 01:21:52 -0800	[thread overview]
Message-ID: <ea408fb02711a52bdd9aef4650c7079945a2bb71.1795835884.git.chris@chrisdown.name> (raw)
In-Reply-To: <cover.1795835884.git.chris@chrisdown.name>

kho_init() fails if kho_debugfs_init() or kho_out_debugfs_init() can't
create their debugfs entries, and a failed kho_init() turns KHO off.
That made sense while KHO could only be finalised through debugfs, but
commit 03d3963464a4 ("kho: make debugfs interface optional") made the
debugfs interface optional, and these days KHO doesn't need any of its
files to work.

This is a problem because debugfs can be disabled at boot with
debugfs=off, or by default with CONFIG_DEBUG_FS_ALLOW_NONE, in which
case every attempt to create a debugfs entry returns -EPERM. Given that
CONFIG_KEXEC_HANDOVER_DEBUGFS defaults to y when KHO is built in, KHO
and LUO can't be used at all on such a kernel. With kho=on liveupdate=on
debugfs=off, /dev/liveupdate never appears and a kexec hands nothing
over. kho_init() doesn't log why, so the only sign of it is the
WARN_ON_ONCE() that LUO then trips in kho_radix_add_key().

So, let's carry on without the debugfs entries when they can't be
created, as kho_in_debugfs_init() already does for the incoming FDT.

Two things then run without KHO's debugfs directories for the first
time. kho_debugfs_blob_add() would fail and trip the WARN_ON_ONCE() in
its callers, so let's make it do nothing when it has no directory to add
the blob to. kho_in_debugfs_init() would log an error on every KHO boot,
so let's make it return early when the kho directory doesn't exist.

With this applied, test_kho and luo_kexec_simple both get their state
back across a KHO kexec between two kernels booted with debugfs=off.

Fixes: 03d3963464a4 ("kho: make debugfs interface optional")
Signed-off-by: Chris Down <chris@chrisdown.name>
---
 kernel/liveupdate/kexec_handover.c          |  9 ++-------
 kernel/liveupdate/kexec_handover_debugfs.c  | 19 +++++++++++--------
 kernel/liveupdate/kexec_handover_internal.h |  8 ++++----
 3 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 663dd22e7172..4cee37ad9426 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -1847,13 +1847,8 @@ static __init int kho_init(void)
 		goto err_free_kho_radix_tree;
 	}
 
-	err = kho_debugfs_init();
-	if (err)
-		goto err_free_fdt;
-
-	err = kho_out_debugfs_init(&kho_out.dbg);
-	if (err)
-		goto err_free_fdt;
+	kho_debugfs_init();
+	kho_out_debugfs_init(&kho_out.dbg);
 
 	err = kho_out_fdt_setup();
 	if (err)
diff --git a/kernel/liveupdate/kexec_handover_debugfs.c b/kernel/liveupdate/kexec_handover_debugfs.c
index 3a91c47ad7a6..cedfc955391a 100644
--- a/kernel/liveupdate/kexec_handover_debugfs.c
+++ b/kernel/liveupdate/kexec_handover_debugfs.c
@@ -59,6 +59,10 @@ int kho_debugfs_blob_add(struct kho_debugfs *dbg, const char *name,
 	else
 		dir = dbg->sub_fdt_dir;
 
+	/* The directories are NULL if they could not be created. */
+	if (!dir)
+		return 0;
+
 	return __kho_debugfs_blob_add(&dbg->fdt_list, dir, name, blob, size);
 }
 
@@ -101,6 +105,9 @@ __init void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt)
 
 	INIT_LIST_HEAD(&dbg->fdt_list);
 
+	if (IS_ERR(debugfs_root))
+		return;
+
 	dir = debugfs_create_dir("in", debugfs_root);
 	if (IS_ERR(dir)) {
 		err = PTR_ERR(dir);
@@ -129,7 +136,7 @@ err_out:
 	}
 }
 
-__init int kho_out_debugfs_init(struct kho_debugfs *dbg)
+__init void kho_out_debugfs_init(struct kho_debugfs *dbg)
 {
 	struct dentry *dir, *f, *sub_fdt_dir;
 
@@ -137,7 +144,7 @@ __init int kho_out_debugfs_init(struct kho_debugfs *dbg)
 
 	dir = debugfs_create_dir("out", debugfs_root);
 	if (IS_ERR(dir))
-		return -ENOMEM;
+		return;
 
 	sub_fdt_dir = debugfs_create_dir("sub_fdts", dir);
 	if (IS_ERR(sub_fdt_dir))
@@ -155,17 +162,13 @@ __init int kho_out_debugfs_init(struct kho_debugfs *dbg)
 
 	dbg->dir = dir;
 	dbg->sub_fdt_dir = sub_fdt_dir;
-	return 0;
+	return;
 
 err_rmdir:
 	debugfs_remove_recursive(dir);
-	return -ENOENT;
 }
 
-__init int kho_debugfs_init(void)
+__init void kho_debugfs_init(void)
 {
 	debugfs_root = debugfs_create_dir("kho", NULL);
-	if (IS_ERR(debugfs_root))
-		return -ENOENT;
-	return 0;
 }
diff --git a/kernel/liveupdate/kexec_handover_internal.h b/kernel/liveupdate/kexec_handover_internal.h
index e9685e1ef6d7..424467a98da2 100644
--- a/kernel/liveupdate/kexec_handover_internal.h
+++ b/kernel/liveupdate/kexec_handover_internal.h
@@ -23,17 +23,17 @@ extern struct kho_bootmem *kho_bootmem;
 extern unsigned int kho_bootmem_cnt;
 
 #ifdef CONFIG_KEXEC_HANDOVER_DEBUGFS
-int kho_debugfs_init(void);
+void kho_debugfs_init(void);
 void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt);
-int kho_out_debugfs_init(struct kho_debugfs *dbg);
+void kho_out_debugfs_init(struct kho_debugfs *dbg);
 int kho_debugfs_blob_add(struct kho_debugfs *dbg, const char *name,
 			 const void *blob, size_t size, bool root);
 void kho_debugfs_blob_remove(struct kho_debugfs *dbg, void *blob);
 #else
-static inline int kho_debugfs_init(void) { return 0; }
+static inline void kho_debugfs_init(void) { }
 static inline void kho_in_debugfs_init(struct kho_debugfs *dbg,
 				       const void *fdt) { }
-static inline int kho_out_debugfs_init(struct kho_debugfs *dbg) { return 0; }
+static inline void kho_out_debugfs_init(struct kho_debugfs *dbg) { }
 static inline int kho_debugfs_blob_add(struct kho_debugfs *dbg,
 				       const char *name, const void *blob,
 				       size_t size, bool root) { return 0; }
-- 
2.56.1


      parent reply	other threads:[~2026-11-28  9:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28  9:21 [PATCH v2 0/2] kho: fixes for kho_init() failures Chris Down
2026-11-28  9:21 ` [PATCH v2 1/2] kho: don't release incoming bootmem areas when kho_init() fails Chris Down
2026-11-28  9:21 ` Chris Down [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea408fb02711a52bdd9aef4650c7079945a2bb71.1795835884.git.chris@chrisdown.name \
    --to=chris@chrisdown.name \
    --cc=graf@amazon.com \
    --cc=kernel-team@meta.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®