From patchwork Fri Jan 13 12:31:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 43242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp243510wrt; Fri, 13 Jan 2023 04:36:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXuyWoiXmJVjdx1n6Ox5tVmwjXbZu+vPrlql053E4Dr6aDRPAGTWnmBo/En/Mcm2pAWV8Kqt X-Received: by 2002:a17:907:6e05:b0:7c1:235d:2a2b with SMTP id sd5-20020a1709076e0500b007c1235d2a2bmr89362143ejc.24.1673613363033; Fri, 13 Jan 2023 04:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673613363; cv=none; d=google.com; s=arc-20160816; b=OW+nvQTtqVPRiI0pNGsCf3ASbf5kpbfnrs4Wq1RThbE8W9KH1jI6XgX3WJOsEXleGi BCm0bIxPHBKHQXNkcZxRVOdHQXW/8hTt0rg9sbnNlF0V6QQNY+uYdSTqAQzzSnsPo6l2 7f3etK2xcPrnQvTEgZHAxdvZuMpWCGJf8UlYVDlL4Yfo3PvvxRz2foNx9KRypkSYlAs5 9W7jiyUnULxkgL1oVFfaIyE+MPpL128Gu0ZGXBZXr0oAi61CoTBho15EPZfRAJeQy2oI 1Wwfik0UOwwVdvufkAWw6zWt2yVhEZGGLA2OajumFo5FRTa6PmbNmbbhXtBlHZ3wnzid s8yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=tU7xkA9KuMwEryWI7gO1xNJIVv2jk6wF1JG0bF/3e24=; b=CedRbtT/bf42FytDsGOeEF9I7AbMm6wkxm38kwJaTtg99aUkV8eCu+5vIuZ0Kgf/yK 9EKhQcft++Ig7h5MmkvLxerpHSrPIIz7wK20udVH6dN5AmpeMGwEqY6/8FLans4+EANH 0MPB3Jo/m8we8IPUfIzf2yjhHu39clNmZzRtdnZydFl3AORlCrDIO6BVX97JID1LSpX9 I+jQfQNTCYn6ZR2yPeG+f4E7eu3A9foYPokTQtChfWX4yoE7fmFcHzXLwh1kJulnfckb fttoMnvQ2LwU1I6wDSVKLEu/6v+XslijERF7GC8nLaY2pai1vVck/75l1g+LF+GHRAgK qF8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hiMLFCuE; dkim=neutral (no key) header.i=@linutronix.de header.b=tFfmIOso; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he14-20020a1709073d8e00b0085d6d5c0de2si10429101ejc.593.2023.01.13.04.35.38; Fri, 13 Jan 2023 04:36:03 -0800 (PST) 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=pass header.i=@linutronix.de header.s=2020 header.b=hiMLFCuE; dkim=neutral (no key) header.i=@linutronix.de header.b=tFfmIOso; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241508AbjAMMes (ORCPT + 99 others); Fri, 13 Jan 2023 07:34:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241271AbjAMMcO (ORCPT ); Fri, 13 Jan 2023 07:32:14 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EBA95472B; Fri, 13 Jan 2023 04:31:12 -0800 (PST) Date: Fri, 13 Jan 2023 12:31:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673613069; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tU7xkA9KuMwEryWI7gO1xNJIVv2jk6wF1JG0bF/3e24=; b=hiMLFCuEVVfG7LDn1Sv1jtrXhx/ISEX5W/w1gfoG9hkoFcJ39vkHQFFno8GFXxjSFMdQUr JBn8Y8+ADaz/AACR9YPE3kmK/+4Vb1HPo9HAmfvl7mTgOLwjTy3kTa+h74ei1tM6MTMVlb OnV0FoBq/512UhFBmWya+jxDb/mKlwY8BmNaq4k2oNsfBqppdkkNFuMuzpDDLCS/c21vtK NbidV/+GVHm8uU4vO1XYX9lZ7okouI2B0IADgErldX4tlBVsZaOnMfxo+0BGtPc1Xl/L2r rlcqVyeX+BHrc136EQHO5XI+G7oPcmWiS6J1qmlS2U6LS+iem3SuLFlCFdd/oA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673613069; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tU7xkA9KuMwEryWI7gO1xNJIVv2jk6wF1JG0bF/3e24=; b=tFfmIOso4RExrUJtxR01ctfxfFB9EiysLiSMV6VFVXN7Cuh0dxbIabl2e2euo6yJwJmerN KalDBu2d58Ij/UAw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] cpuidle, tdx: Make TDX code noinstr clean Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , Tony Lindgren , Ulf Hansson , "Rafael J. Wysocki" , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112195541.111485720@infradead.org> References: <20230112195541.111485720@infradead.org> MIME-Version: 1.0 Message-ID: <167361306922.4906.15745599332550388182.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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?1754910805865743169?= X-GMAIL-MSGID: =?utf-8?q?1754910805865743169?= The following commit has been merged into the sched/core branch of tip: Commit-ID: c3982c1a36f70bd4521a9852246ea50105912084 Gitweb: https://git.kernel.org/tip/c3982c1a36f70bd4521a9852246ea50105912084 Author: Peter Zijlstra AuthorDate: Thu, 12 Jan 2023 20:43:43 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 13 Jan 2023 11:48:16 +01:00 cpuidle, tdx: Make TDX code noinstr clean objtool found a few cases where this code called out into instrumented code: vmlinux.o: warning: objtool: __halt+0x2c: call to hcall_func.constprop.0() leaves .noinstr.text section vmlinux.o: warning: objtool: __halt+0x3f: call to __tdx_hypercall() leaves .noinstr.text section vmlinux.o: warning: objtool: __tdx_hypercall+0x66: call to __tdx_hypercall_failed() leaves .noinstr.text section Fix it by: - moving TDX tdcall assembly methods into .noinstr.text (they are already noistr-clean) - marking __tdx_hypercall_failed() as 'noinstr' - annotating hcall_func() as __always_inline Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Tested-by: Tony Lindgren Tested-by: Ulf Hansson Acked-by: Rafael J. Wysocki Acked-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20230112195541.111485720@infradead.org --- arch/x86/boot/compressed/vmlinux.lds.S | 1 + arch/x86/coco/tdx/tdcall.S | 2 ++ arch/x86/coco/tdx/tdx.c | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S index 112b237..b22f34b 100644 --- a/arch/x86/boot/compressed/vmlinux.lds.S +++ b/arch/x86/boot/compressed/vmlinux.lds.S @@ -34,6 +34,7 @@ SECTIONS _text = .; /* Text */ *(.text) *(.text.*) + *(.noinstr.text) _etext = . ; } .rodata : { diff --git a/arch/x86/coco/tdx/tdcall.S b/arch/x86/coco/tdx/tdcall.S index 508c173..ad0d51f 100644 --- a/arch/x86/coco/tdx/tdcall.S +++ b/arch/x86/coco/tdx/tdcall.S @@ -31,6 +31,8 @@ TDX_R12 | TDX_R13 | \ TDX_R14 | TDX_R15 ) +.section .noinstr.text, "ax" + /* * __tdx_module_call() - Used by TDX guests to request services from * the TDX module (does not include VMM services) using TDCALL instruction. diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 8804174..70e8015 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -64,8 +64,9 @@ static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15) } /* Called from __tdx_hypercall() for unrecoverable failure */ -void __tdx_hypercall_failed(void) +noinstr void __tdx_hypercall_failed(void) { + instrumentation_begin(); panic("TDVMCALL failed. TDX module bug?"); } @@ -75,7 +76,7 @@ void __tdx_hypercall_failed(void) * Reusing the KVM EXIT_REASON macros makes it easier to connect the host and * guest sides of these calls. */ -static u64 hcall_func(u64 exit_reason) +static __always_inline u64 hcall_func(u64 exit_reason) { return exit_reason; }