From patchwork Fri Mar 17 16:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guilherme G. Piccoli" X-Patchwork-Id: 71353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp435275wrt; Fri, 17 Mar 2023 09:27:07 -0700 (PDT) X-Google-Smtp-Source: AK7set+SLc0RAdz71E8BdmJqupktVEpc6XA7efiv7QW+c0+n8KQWxwemlRZ2N73n3rft6miuEaXO X-Received: by 2002:a17:90b:2313:b0:234:117e:b122 with SMTP id mt19-20020a17090b231300b00234117eb122mr9918732pjb.0.1679070426949; Fri, 17 Mar 2023 09:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679070426; cv=none; d=google.com; s=arc-20160816; b=MvKREQ6jCVXYyNYjHyXNeb6yemBdu9KI7y7FHFgJl7W+0abOoP/ryknV2PPbb/ioIj quEOhZ2Kc7ttxI1MArDdMB+8ciXZcNx9X+uM/2exRCIyKO6GBwtuh6OLxeSFx3Qp7g8s 6w8PjkNIq4qhI+9XIKf0seEMk4qMQpgoCjikNhvsGsTsb4zrwUkyOwZPKCuchwoxKEBs o+KnxMopxEQsRcwyI2RtFJ+fXU0AbWW1pDXw0SEU/vjMQhsKIDbwMWVOKBkEeCxQe5yl RMjMDEVK7F057hJ3WNSEoz8FsvA4ncxr0ed6hjhuQOU7e4xuh3KodCzQHHp1JXIZDSjw pQUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bFCq2RSEAg+Y5fRTPik+kLtPCBISXTx/n8QU8KXWe6s=; b=aB8T9tZ9GlrQz4HtczeNgWpMCw2BttuXKbGhlNEMe8Mp6FshTavWKj1YoJ7iqBzzXo uS4SRVKcucTxU9+BZIEwp21N/QPJnlH4yIq0mzY+8DS5aybNgQVEIvAvsNlAoLRFkTJ1 /Ed0IijH7o5UObtBcrVKs2FkHvMmYxpfJc3wKrkfSe0ZhEUbYZ8QocG0nKNVMDmGtiee qDhyozjxyaIU9/8RKL5sZ4BNnq+Vkpo/O5zV0a8h5worUR6JalKBMeRaVG6pblKI1m+7 TVOpC7hPIPLKzWNDmhX2BDy2JrAWTFmjqBM4NTEnCH763/2wxMkUHRbxLhB5l4+X3LPM gxVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=dwAVOmc0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n127-20020a632785000000b00502f457059dsi2964761pgn.330.2023.03.17.09.26.51; Fri, 17 Mar 2023 09:27:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=dwAVOmc0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbjCQQGz (ORCPT + 99 others); Fri, 17 Mar 2023 12:06:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjCQQGu (ORCPT ); Fri, 17 Mar 2023 12:06:50 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DF45FEAD; Fri, 17 Mar 2023 09:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=bFCq2RSEAg+Y5fRTPik+kLtPCBISXTx/n8QU8KXWe6s=; b=dwAVOmc0zjj3yMuhkUmfQBj4pv ihKPwMBJ5zZGdtfkbalG+mlkZWO1mgulTp+x7fHf5eM9Fk5w7K0jD5iVAQEOhn+0J9Eq3I3vEmNQ7 pAXRc1H9v7iCwRePWoK5tkJ01gUUjVxncoxcDf0bw63B/aMLoO+yKNyrD035dxBzQnKwTnytv/2Sj kkjk5xmmRuTOsazWVVkbLOBtf5eRS9Msf85WvIlQSdAzE/r6sGuTW7pH9oWKxtUShNwyV2dtGSd6K UBSVJph6dwo/aR+51exbocMN0VYNoc1xR7MmugWdeAcfSEVftpgeDatUopFTRvxRYYMdMxA7TBNEo FNNjbu1w==; Received: from [152.254.169.34] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pdCaZ-00G3jr-Fb; Fri, 17 Mar 2023 17:05:56 +0100 From: "Guilherme G. Piccoli" 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, peterz@infradead.org, kernel-dev@igalia.com, kernel@gpiccoli.net, "Guilherme G. Piccoli" , Arnd Bergmann , Josh Poimboeuf , Michael Kelley Subject: [PATCH v3] x86/hyperv: Mark hv_ghcb_terminate() as noreturn Date: Fri, 17 Mar 2023 13:05:46 -0300 Message-Id: <20230317160546.1497477-1-gpiccoli@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310154452.1169204-1-gpiccoli@igalia.com> References: <20230310154452.1169204-1-gpiccoli@igalia.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759997059728087181?= X-GMAIL-MSGID: =?utf-8?q?1760632952027997635?= 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 1b6f: jmpq ffffffff82f217ec # unreachable 1b74: cmpq $0xffffffffffffffff,-0x702a24(%rip) [...] Now, after adding the __noreturn to the function prototype: [...] 17df: callq ffffffff8102f6d0 17e4: test %al,%al 17e6: je ffffffff82f21bb9 [...] 1bb9: mov $0x1,%esi 1bbe: xor %edi,%edi 1bc0: callq ffffffff8102f680 1bc5: nopw %cs:0x0(%rax,%rax,1) # end of function Reported-by: Arnd Bergmann Link: https://lore.kernel.org/r/9698eff1-9680-4f0a-94de-590eaa923e94@app.fastmail.com/ Cc: Josh Poimboeuf Cc: Michael Kelley Signed-off-by: Guilherme G. Piccoli Reviewed-by: Michael Kelley --- V3: - As per Michael / Josh advice (thanks!), added __noreturn to the function definition as well. V2: - Per Josh's suggestion (thanks!), added the function name to the objtool global table. Thanks in advance for reviews/comments! Cheers, Guilherme 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 f937be1afe65..4b5e03f61f1f 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -209,6 +209,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func, "do_task_dead", "ex_handler_msr_mce", "fortify_panic", + "hv_ghcb_terminate", "kthread_complete_and_exit", "kthread_exit", "kunit_try_catch_throw",