Linux-HyperV List
 help / color / mirror / Atom feed
From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: linux-hyperv@vger.kernel.org, x86@kernel.org
Cc: linux-kernel@vger.kernel.org, decui@microsoft.com,
	haiyangz@microsoft.com, kys@microsoft.com, wei.liu@kernel.org,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, hpa@zytor.com,
	thomas.lendacky@amd.com, jpoimboe@kernel.org,
	peterz@infradead.org, kernel-dev@igalia.com, kernel@gpiccoli.net,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH] x86/hyperv: Mark hv_ghcb_terminate() as noreturn
Date: Fri, 10 Mar 2023 11:02:52 -0300	[thread overview]
Message-ID: <20230310140251.1159036-1-gpiccoli@igalia.com> (raw)

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

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

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>
---


Hey folks, after getting the warning myself a quick search led me to Arnd's
thorough report - investigating a bit, this seems to be the proper solution.

Notice I didn't add the function to objtool's static list, seems this is
unnecessary in this case - lemme know otherwise!
Thanks in advance for reviews,


Guilherme


 arch/x86/include/asm/mshyperv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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) {}
-- 
2.39.2


             reply	other threads:[~2023-03-10 14:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 14:02 Guilherme G. Piccoli [this message]
2023-03-10 15:24 ` [PATCH] x86/hyperv: Mark hv_ghcb_terminate() as noreturn Josh Poimboeuf
2023-03-10 15:41   ` Guilherme G. Piccoli
2023-03-10 15:44   ` [PATCH v2] " Guilherme G. Piccoli
2023-03-10 21:17     ` Michael Kelley (LINUX)
2023-03-11  0:17       ` Guilherme G. Piccoli
2023-03-16 21:24       ` Guilherme G. Piccoli
2023-03-17 13:40         ` Michael Kelley (LINUX)
2023-03-17 14:53           ` Josh Poimboeuf
2023-03-17 16:04             ` Guilherme G. Piccoli
2023-03-17 16:05     ` [PATCH v3] " Guilherme G. Piccoli
2023-03-17 16:24       ` Josh Poimboeuf
2023-03-17 19:27         ` Guilherme G. Piccoli
2023-03-17 16:46       ` Michael Kelley (LINUX)

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=20230310140251.1159036-1-gpiccoli@igalia.com \
    --to=gpiccoli@igalia.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=kernel-dev@igalia.com \
    --cc=kernel@gpiccoli.net \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=wei.liu@kernel.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