x86: verify function type (and maybe attribute) in switch_stack_and_jump()
authorJan Beulich <jbeulich@suse.com>
Tue, 22 Dec 2020 07:57:19 +0000 (08:57 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Dec 2020 07:57:19 +0000 (08:57 +0100)
commit1a050d69faffe42fd22dbe9c9c49e2228919148f
treea17de970983e13732b6773a5f27bb3617f0830d7
parent8c8938dcc1bd37dd61f705410053e08804ca2b55
x86: verify function type (and maybe attribute) in switch_stack_and_jump()

It is imperative that the functions passed here are taking no arguments,
return no values, and don't return in the first place. While the type
can be checked uniformly, the attribute check is limited to gcc 9 and
newer (no clang support for this so far afaict).

Note that I didn't want to have the "true" fallback "implementation" of
__builtin_has_attribute(..., __noreturn__) generally available, as
"true" may not be a suitable fallback in other cases.

Note further that the noreturn addition to startup_cpu_idle_loop()'s
declaration requires adding unreachable() to Arm's
switch_stack_and_jump(), or else the build would break. I suppose this
should have been there already.

For vmx_asm_do_vmentry() along with adding the attribute, also restrict
its scope.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wl@xen.org>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmcs.c
xen/arch/x86/setup.c
xen/include/asm-arm/current.h
xen/include/asm-x86/current.h
xen/include/asm-x86/hvm/vmx/vmx.h
xen/include/xen/sched.h