Skip to content

Commit c93c296

Browse files
committed
x86/sev: Mark snp_abort() noreturn
Mark both the function prototype and definition as noreturn in order to prevent the compiler from doing transformations which confuse objtool like so: vmlinux.o: warning: objtool: sme_enable+0x71: unreachable instruction This triggers with gcc-12. Add it and sev_es_terminate() to the objtool noreturn tracking array too. Sort it while at it. Suggested-by: Michael Matz <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cdaa0a4 commit c93c296

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

arch/x86/include/asm/sev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void snp_set_memory_shared(unsigned long vaddr, unsigned int npages);
195195
void snp_set_memory_private(unsigned long vaddr, unsigned int npages);
196196
void snp_set_wakeup_secondary_cpu(void);
197197
bool snp_init(struct boot_params *bp);
198-
void snp_abort(void);
198+
void __init __noreturn snp_abort(void);
199199
int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned long *fw_err);
200200
#else
201201
static inline void sev_es_ist_enter(struct pt_regs *regs) { }

arch/x86/kernel/sev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ bool __init snp_init(struct boot_params *bp)
21122112
return true;
21132113
}
21142114

2115-
void __init snp_abort(void)
2115+
void __init __noreturn snp_abort(void)
21162116
{
21172117
sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED);
21182118
}

tools/objtool/check.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,32 +162,34 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
162162

163163
/*
164164
* Unfortunately these have to be hard coded because the noreturn
165-
* attribute isn't provided in ELF data.
165+
* attribute isn't provided in ELF data. Keep 'em sorted.
166166
*/
167167
static const char * const global_noreturns[] = {
168+
"__invalid_creds",
169+
"__module_put_and_kthread_exit",
170+
"__reiserfs_panic",
168171
"__stack_chk_fail",
169-
"panic",
172+
"__ubsan_handle_builtin_unreachable",
173+
"cpu_bringup_and_idle",
174+
"cpu_startup_entry",
170175
"do_exit",
176+
"do_group_exit",
171177
"do_task_dead",
172-
"kthread_exit",
173-
"make_task_dead",
174-
"__module_put_and_kthread_exit",
178+
"ex_handler_msr_mce",
179+
"fortify_panic",
175180
"kthread_complete_and_exit",
176-
"__reiserfs_panic",
181+
"kthread_exit",
182+
"kunit_try_catch_throw",
177183
"lbug_with_loc",
178-
"fortify_panic",
179-
"usercopy_abort",
180184
"machine_real_restart",
185+
"make_task_dead",
186+
"panic",
181187
"rewind_stack_and_make_dead",
182-
"kunit_try_catch_throw",
183-
"xen_start_kernel",
184-
"cpu_bringup_and_idle",
185-
"do_group_exit",
188+
"sev_es_terminate",
189+
"snp_abort",
186190
"stop_this_cpu",
187-
"__invalid_creds",
188-
"cpu_startup_entry",
189-
"__ubsan_handle_builtin_unreachable",
190-
"ex_handler_msr_mce",
191+
"usercopy_abort",
192+
"xen_start_kernel",
191193
};
192194

193195
if (!func)

0 commit comments

Comments
 (0)