From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97EF13B442B; Tue, 8 Sep 2026 20:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788899680; cv=none; b=FjEpUrQDZqCYzrpNVHJTqd5CbxJ/GlNj/MoofHEYlhV2OPk8dzkE4cxHCCNMX1REHe7WuHOD/R3Suv7/49s1UPEHDzF9Ysc4nrBE6a4gnrFnHjl5lPRvpP6Mtm71x5NExO8vmo23UemZH0SGuHfUoFVDoAtO8JC/uHrt3lTjHqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788899680; c=relaxed/simple; bh=/7jIcjgOxFNGI7ubXzY3AcMW0+R1rsx2kBOe6fYE6Aw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NiZernqjUw+5+QEFRe3J7DLxbJM5sldU0BO0s/uZtAKYs3eYg1BBbhW+wy4GVOHsVXw998ziByRwLuYK/qLbUAIe/EaFZUUTHQPAkls8J46Id80VdMczZ6iZLRfcg5gc1bePFLc24FY1fWQI2JtsxnUuIyz6AMpurhTYgHv8ajw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TJvoNrUT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TJvoNrUT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ECB31F00A3E; Tue, 8 Sep 2026 20:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788899678; bh=LpssU78NKD8pmI7WdfWJNnR20LDRSOoXQsuYdchzvVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TJvoNrUTksWoiuke0M219zJ8JdNvDqX19lG8mUOObA6EOjXtgZZYvA3uTJkL8TuSu j3500BEWIfeRupA42m6RkRlDYxABZbBG63/haVJsX+DDZuwcIU421qY5GxT4uMRjuD coVfRsX9MYTVS/Y4WWpIHzL65ZATgfajqGFvgX0JRrQ8pMwsKp0yw/Rut+SbyBz5yh szIjA5Q2ybZXKyP36P0frCQwMIkaJJb5GcXuWqty+Qo7GsxbJwyu4Zh43RDplNDmnW HlilPqg25eNYatwt9tcERQAtogYz8fRDlrbN5P2qRbMqVcdCP/KoGVkvA85zUAAJjq uDs26sycQO36A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH v2 19/27] x86/xen: Make xen_start_kernel() noreturn Date: Tue, 8 Sep 2026 13:33:31 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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