Blob Blame History Raw
From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Date: Wed, 12 Apr 2023 16:49:41 -0700
Patch-mainline: v6.4-rc1
Subject: x86/hyperv: Mark hv_ghcb_terminate() as noreturn
Git-commit: 611d4c716db0141cfc436994dc5aff1d69c924ad
References: bsc#1206453

Annotate the function prototype and definition as noreturn to prevent
objtool warnings like:

vmlinux.o: warning: objtool: hyperv_init+0x55c: unreachable instruction

Also, as per Josh's suggestion, add it to the global_noreturns list.
As a comparison, an objdump output without the annotation:

[...]
1b63:  mov    $0x1,%esi
1b68:  xor    %edi,%edi
1b6a:  callq  ffffffff8102f680 <hv_ghcb_terminate>
1b6f:  jmpq   ffffffff82f217ec <hyperv_init+0x9c> # unreachable
1b74:  cmpq   $0xffffffffffffffff,-0x702a24(%rip)
[...]

Now, after adding the __noreturn to the function prototype:

[...]
17df:  callq  ffffffff8102f6d0 <hv_ghcb_negotiate_protocol>
17e4:  test   %al,%al
17e6:  je     ffffffff82f21bb9 <hyperv_init+0x469>
[...]  <many insns>
1bb9:  mov    $0x1,%esi
1bbe:  xor    %edi,%edi
1bc0:  callq  ffffffff8102f680 <hv_ghcb_terminate>
1bc5:  nopw   %cs:0x0(%rax,%rax,1) # end of function

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/32453a703dfcf0d007b473c9acbf70718222b74b.1681342859.git.jpoimboe@kernel.org
Acked-by: Olaf Hering <ohering@suse.de>
---
 arch/x86/hyperv/ivm.c           |    2 +-
 arch/x86/include/asm/mshyperv.h |    2 +-
 tools/objtool/check.c           |    1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

--- a/arch/x86/hyperv/ivm.c
+++ b/arch/x86/hyperv/ivm.c
@@ -129,7 +129,7 @@ static enum es_result hv_ghcb_hv_call(st
 		return ES_OK;
 }
 
-void hv_ghcb_terminate(unsigned int set, unsigned int reason)
+void __noreturn hv_ghcb_terminate(unsigned int set, unsigned int reason)
 {
 	u64 val = GHCB_MSR_TERM_REQ;
 
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -221,7 +221,7 @@ int hv_unmap_ioapic_interrupt(int ioapic
 void hv_ghcb_msr_write(u64 msr, u64 value);
 void hv_ghcb_msr_read(u64 msr, u64 *value);
 bool hv_ghcb_negotiate_protocol(void);
-void hv_ghcb_terminate(unsigned int set, unsigned int reason);
+void __noreturn hv_ghcb_terminate(unsigned int set, unsigned int reason);
 void hv_vtom_init(void);
 #else
 static inline void hv_ghcb_msr_write(u64 msr, u64 value) {}
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -190,6 +190,7 @@ static bool __dead_end_function(struct o
 		"do_exit",
 		"do_task_dead",
 		"fortify_panic",
+		"hv_ghcb_terminate",
 		"kunit_try_catch_throw",
 		"lbug_with_loc",
 		"machine_real_restart",