Thread (34 messages) flat view 34 messages, 2 authors, 2d ago
WARM2d

Revision v3 of 3 in this series.

Revisions (3)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 current

[PATCH v3 19/28] x86/xen: Make xen_start_kernel() noreturn

From: Josh Poimboeuf <jpoimboe@kernel.org>
Date: 2026-09-21 22:31:47
Also in: lkml, rust-for-linux
Subsystem: objtool, the rest, x86 architecture (32-bit and 64-bit), xen hypervisor x86 · Maintainers: Josh Poimboeuf, Peter Zijlstra, Linus Torvalds, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, Juergen Gross

startup_xen() calls xen_start_kernel() with the assumption that it never
returns, otherwise it would fall off the end of SYM_CODE_END(),
triggering undefined behavior.

But startup_xen() actually can return if 'si' is NULL.  That doesn't
seem to be possible, so drop the check and mark xen_start_kernel()
__noreturn.

A NULL 'si' would now fault on the first xen_start_info dereference,
which is at least a more deterministic way to crash.

Now that the function can no longer return, objtool can derive its
noreturn attribute directly and the noreturns.h entry can be removed.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 arch/x86/xen/enlighten_pv.c | 5 +----
 arch/x86/xen/xen-ops.h      | 2 +-
 tools/objtool/noreturns.h   | 1 -
 3 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 2c64b388f6164..8ec78df9d1d5b 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1325,15 +1325,12 @@ static void __init xen_domu_set_legacy_features(void)
 extern void early_xen_iret_patch(void);
 
 /* First C function to be called on Xen boot */
-asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
+asmlinkage __visible void __init __noreturn xen_start_kernel(struct start_info *si)
 {
 	struct physdev_set_iopl set_iopl;
 	unsigned long initrd_start = 0;
 	int rc;
 
-	if (!si)
-		return;
-
 	clear_bss();
 
 	xen_start_info = si;
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 47eebbb3684ab..d830807cfffca 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -73,7 +73,7 @@ void xen_force_evtchn_callback(void);
 
 void xen_pv_pre_suspend(void);
 void xen_pv_post_suspend(int suspend_cancelled);
-void xen_start_kernel(struct start_info *si);
+void __noreturn xen_start_kernel(struct start_info *si);
 
 void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
 void xen_init_mmu_ops(void);
diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h
index 01c94f20d1818..c4b93fc6e6299 100644
--- a/tools/objtool/noreturns.h
+++ b/tools/objtool/noreturns.h
@@ -21,4 +21,3 @@ NORETURN(panic)
 NORETURN(vpanic)
 NORETURN(rust_helper_BUG)
 NORETURN(sev_es_terminate)
-NORETURN(xen_start_kernel)
-- 
2.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help