From nobody Mon Feb 9 15:29:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6DA6CA0FFA for ; Tue, 5 Sep 2023 17:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344963AbjIERDE (ORCPT ); Tue, 5 Sep 2023 13:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354191AbjIEKJj (ORCPT ); Tue, 5 Sep 2023 06:09:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94D7B1B7; Tue, 5 Sep 2023 03:09:35 -0700 (PDT) Date: Tue, 05 Sep 2023 10:09:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1693908573; 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=d7nkECszsry0rSk0DgCWSWbFGZv5iq8J2XANaiqx57c=; b=OD51tqLSBHKMcG14aPLMcE8mpaVovotTMfFVNXpzbrrTXAF8BD0NFgGMPKdfhwDydGrJmS VaSl9n1SFexyQbcKA+wPw7KvbFl3nvEdvcasxCSXg6i7Jc21fWiCyzhQZvsnZbW+cMEIzt y5Y7VyAYc1O56ovLXFyOgTHdUTQM2ZF7B8mbZP2CVp5y1DEvRNgE5DGvBwg5wA56ZmPESU iLgzuPxli9p07XAmCrb16Zm33qiS96fxgpH0dWLtRU/E+fCuZpB46OIBamqA+J/dq0/sgW f1HDwUmKOe5fHKZPHpYzPlAY0b2btwGtARlj6HlYeRYwPqOfMlhc8aiUxgwTxA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1693908573; 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=d7nkECszsry0rSk0DgCWSWbFGZv5iq8J2XANaiqx57c=; b=jN5FvE3dnlHA+MlOHDQ1Lbg745BbTch+hWSYEYxCL9Z5VB0WN0eroKnUxvKpSwzcqVdVxe YhKoLOSF8wVz3lBA== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/bugs] x86/nospec: Refactor UNTRAIN_RET[_*] Cc: Josh Poimboeuf , Ingo Molnar , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <169390857277.27769.6934569658577515640.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/bugs branch of tip: Commit-ID: ef96daae49597e76a99f3db00dfc2c1559fe2443 Gitweb: https://git.kernel.org/tip/ef96daae49597e76a99f3db00dfc2c155= 9fe2443 Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:05:03 -07:00 Committer: Ingo Molnar CommitterDate: Tue, 05 Sep 2023 12:05:08 +02:00 x86/nospec: Refactor UNTRAIN_RET[_*] Factor out the UNTRAIN_RET[_*] common bits into a helper macro. Signed-off-by: Josh Poimboeuf Signed-off-by: Ingo Molnar Acked-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/f06d45489778bd49623297af2a983eea09067a74.16= 93889988.git.jpoimboe@kernel.org --- arch/x86/include/asm/nospec-branch.h | 31 ++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/no= spec-branch.h index 51e3f1a..dcc7847 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -288,35 +288,24 @@ * As such, this must be placed after every *SWITCH_TO_KERNEL_CR3 at a poi= nt * where we have a stack but before any RET instruction. */ -.macro UNTRAIN_RET +.macro __UNTRAIN_RET ibpb_feature, call_depth_insns #if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + "call entry_ibpb", \ibpb_feature, \ + __stringify(\call_depth_insns), X86_FEATURE_CALL_DEPTH #endif .endm =20 -.macro UNTRAIN_RET_VM -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_IBPB_ON_VMEXIT, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH) =20 -.macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH_FROM_CALL), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET_VM \ + __UNTRAIN_RET X86_FEATURE_IBPB_ON_VMEXIT, __stringify(RESET_CALL_DEPTH) + +#define UNTRAIN_RET_FROM_CALL \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH_FROM_C= ALL) =20 =20 .macro CALL_DEPTH_ACCOUNT