[PATCH 19/27] x86/xen: Make xen_start_kernel() noreturn
Josh Poimboeuf <[email protected]>
| Newsgroups | gmane.linux.kernel.rust,gmane.linux.kernel,gmane.linux.kbuild.devel |
|---|---|
| Message-ID | <90d7c1943218be3c95b005e7b0fd004b9c78dbdc.1787890035.git.jpoimboe@kernel.org> |
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 <[email protected]> --- 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 dc265bdda24d7..20e8fb6244426 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