mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Miroslav Benes <mbenes@suse.cz>,
	linux-btrfs@vger.kernel.org, Mark Rutland <mark.rutland@arm.com>,
	linux-scsi@vger.kernel.org, linux-hyperv@vger.kernel.org,
	Arnd Bergmann <arnd@arndb.de>,
	"Guilherme G . Piccoli" <gpiccoli@igalia.com>,
	Michael Kelley <mikelley@microsoft.com>
Subject: [PATCH 11/11] x86/hyperv: Mark hv_ghcb_terminate() as noreturn
Date: Fri,  7 Apr 2023 17:10:04 -0700	[thread overview]
Message-ID: <8d21cbcef0e08053b36da2bc0a74ff65f5dabd43.1680912057.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1680912057.git.jpoimboe@kernel.org>

From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>

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>
Link: https://lore.kernel.org/r/9698eff1-9680-4f0a-94de-590eaa923e94@app.fastmail.com/
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20230317160546.1497477-1-gpiccoli@igalia.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 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(-)

diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
index 1dbcbd9da74d..4f79dc76042d 100644
--- a/arch/x86/hyperv/ivm.c
+++ b/arch/x86/hyperv/ivm.c
@@ -127,7 +127,7 @@ static enum es_result hv_ghcb_hv_call(struct ghcb *ghcb, u64 exit_code,
 		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;
 
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 4c4c0ec3b62e..09c26e658bcc 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -212,7 +212,7 @@ int hv_set_mem_host_visibility(unsigned long addr, int numpages, bool visible);
 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);
 #else
 static inline void hv_ghcb_msr_write(u64 msr, u64 value) {}
 static inline void hv_ghcb_msr_read(u64 msr, u64 *value) {}
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 8586d4c36600..e23d12041be0 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -213,6 +213,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
 		"ex_handler_msr_mce",
 		"fortify_panic",
 		"hlt_play_dead",
+		"hv_ghcb_terminate",
 		"kthread_complete_and_exit",
 		"kthread_exit",
 		"kunit_try_catch_throw",
-- 
2.39.2


      parent reply	other threads:[~2023-04-08  0:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-08  0:09 [PATCH 00/12] Sprinkle more __noreturn Josh Poimboeuf
2023-04-08  0:09 ` [PATCH 01/11] init: Mark [arch_call_]rest_init() __noreturn Josh Poimboeuf
2023-04-10 20:02   ` Nick Desaulniers
2023-04-08  0:09 ` [PATCH 02/11] init: Mark start_kernel() __noreturn Josh Poimboeuf
2023-04-12 20:29   ` Nick Desaulniers
2023-04-12 21:57     ` Josh Poimboeuf
2023-04-12 23:26       ` Josh Poimboeuf
2023-04-08  0:09 ` [PATCH 03/11] x86/head: Mark *_start_kernel() __noreturn Josh Poimboeuf
2023-04-08  0:09 ` [PATCH 04/11] btrfs: Mark btrfs_assertfail() __noreturn Josh Poimboeuf
2023-04-08  0:09 ` [PATCH 05/11] arm64/cpu: Mark cpu_park_loop() and friends __noreturn Josh Poimboeuf
2023-04-08  0:09 ` [PATCH 06/11] cpu: Mark panic_smp_self_stop() __noreturn Josh Poimboeuf
2023-04-08  0:10 ` [PATCH 07/11] cpu: Mark nmi_panic_self_stop() __noreturn Josh Poimboeuf
2023-04-08  0:10 ` [PATCH 08/11] x86/cpu: Mark {hlt,resume}_play_dead() __noreturn Josh Poimboeuf
2023-04-08  0:10 ` [PATCH 09/11] objtool: Include weak functions in global_noreturns check Josh Poimboeuf
2023-04-08  0:10 ` [PATCH 10/11] scsi: message: fusion: Mark mpt_halt_firmware() __noreturn Josh Poimboeuf
2023-04-08  0:10 ` Josh Poimboeuf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d21cbcef0e08053b36da2bc0a74ff65f5dabd43.1680912057.git.jpoimboe@kernel.org \
    --to=jpoimboe@kernel.org \
    --cc=arnd@arndb.de \
    --cc=gpiccoli@igalia.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mbenes@suse.cz \
    --cc=mikelley@microsoft.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®