Commit c93c296f authored by Borislav Petkov's avatar Borislav Petkov

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: default avatarMichael Matz <matz@suse.de>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220824152420.20547-1-bp@alien8.de
parent cdaa0a40
...@@ -195,7 +195,7 @@ void snp_set_memory_shared(unsigned long vaddr, unsigned int npages); ...@@ -195,7 +195,7 @@ void snp_set_memory_shared(unsigned long vaddr, unsigned int npages);
void snp_set_memory_private(unsigned long vaddr, unsigned int npages); void snp_set_memory_private(unsigned long vaddr, unsigned int npages);
void snp_set_wakeup_secondary_cpu(void); void snp_set_wakeup_secondary_cpu(void);
bool snp_init(struct boot_params *bp); bool snp_init(struct boot_params *bp);
void snp_abort(void); void __init __noreturn snp_abort(void);
int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned long *fw_err); int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned long *fw_err);
#else #else
static inline void sev_es_ist_enter(struct pt_regs *regs) { } static inline void sev_es_ist_enter(struct pt_regs *regs) { }
......
...@@ -2112,7 +2112,7 @@ bool __init snp_init(struct boot_params *bp) ...@@ -2112,7 +2112,7 @@ bool __init snp_init(struct boot_params *bp)
return true; return true;
} }
void __init snp_abort(void) void __init __noreturn snp_abort(void)
{ {
sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED); sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED);
} }
......
...@@ -162,32 +162,34 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func, ...@@ -162,32 +162,34 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
/* /*
* Unfortunately these have to be hard coded because the noreturn * Unfortunately these have to be hard coded because the noreturn
* attribute isn't provided in ELF data. * attribute isn't provided in ELF data. Keep 'em sorted.
*/ */
static const char * const global_noreturns[] = { static const char * const global_noreturns[] = {
"__invalid_creds",
"__module_put_and_kthread_exit",
"__reiserfs_panic",
"__stack_chk_fail", "__stack_chk_fail",
"panic", "__ubsan_handle_builtin_unreachable",
"cpu_bringup_and_idle",
"cpu_startup_entry",
"do_exit", "do_exit",
"do_group_exit",
"do_task_dead", "do_task_dead",
"kthread_exit", "ex_handler_msr_mce",
"make_task_dead", "fortify_panic",
"__module_put_and_kthread_exit",
"kthread_complete_and_exit", "kthread_complete_and_exit",
"__reiserfs_panic", "kthread_exit",
"kunit_try_catch_throw",
"lbug_with_loc", "lbug_with_loc",
"fortify_panic",
"usercopy_abort",
"machine_real_restart", "machine_real_restart",
"make_task_dead",
"panic",
"rewind_stack_and_make_dead", "rewind_stack_and_make_dead",
"kunit_try_catch_throw", "sev_es_terminate",
"xen_start_kernel", "snp_abort",
"cpu_bringup_and_idle",
"do_group_exit",
"stop_this_cpu", "stop_this_cpu",
"__invalid_creds", "usercopy_abort",
"cpu_startup_entry", "xen_start_kernel",
"__ubsan_handle_builtin_unreachable",
"ex_handler_msr_mce",
}; };
if (!func) if (!func)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment