[PATCH v6 4/8] kho: Add kho_disable()
From: George Guo
Date: Thu Oct 29 2026 - 13:31:17 EST
From: George Guo <guodongtai@xxxxxxxxxx>
On LoongArch, KHO state is passed to the next kernel only through an EFI
configuration table. Only the EFI stub installs this table, during a cold
boot.
A kernel entered through kexec does not run the EFI stub, so it cannot
create the table if the previous kernel did not provide one. Without
the table, it cannot pass KHO state to the next kernel on a subsequent
kexec.
Add kho_disable() so architecture code can turn KHO off when the EFI
configuration table is missing.
Signed-off-by: George Guo <guodongtai@xxxxxxxxxx>
---
include/linux/kexec_handover.h | 3 +++
kernel/liveupdate/kexec_handover.c | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h
index ef2b188c8ed0..6f80e1b0ccd4 100644
--- a/include/linux/kexec_handover.h
+++ b/include/linux/kexec_handover.h
@@ -15,6 +15,7 @@ struct page;
#ifdef CONFIG_KEXEC_HANDOVER
bool kho_is_enabled(void);
+void kho_disable(void);
bool is_kho_boot(void);
int kho_preserve_folio(struct folio *folio);
@@ -54,6 +55,8 @@ static inline bool kho_is_enabled(void)
return false;
}
+static inline void kho_disable(void) { }
+
static inline bool is_kho_boot(void)
{
return false;
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 74c4633f5afc..3280533eaebe 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -82,6 +82,15 @@ static int __init kho_parse_enable(char *p)
}
early_param("kho", kho_parse_enable);
+/*
+ * For architecture code that finds, after the early parameters are parsed,
+ * that it cannot pass the KHO state to the next kernel.
+ */
+void __init kho_disable(void)
+{
+ kho_enable = false;
+}
+
struct kho_out {
void *fdt;
struct mutex lock; /* protects KHO FDT */
--
2.53.0