From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 626EA29712D; Mon, 12 May 2025 18:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747073518; cv=none; b=bMoEp9cc1cTHtZquOlMknSYJchx6UDUy1nUiIVcHSEOChh1ZFjL4lbThtXVzSOZ2EyA3fb3j4wmICTBwSC505YXJZuKpNpj7z29wx2Bijhl+apjHTAi6ViUQu4YBzNj89zp85BkL7JksJ2QBdDWd+VAic2xrOpft+6W6g6OoFBA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747073518; c=relaxed/simple; bh=Z5vwSh+Ucf53hn0XT6TDNevSk+BvlaStrLRLTJtMtMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OBVgQ31Pj3PejLV230O5kKQIeoaBFuOocH3IFZuV5ipRqx0PlOsiXSf4uiHKzMIK0eLpvzareiMjjTzdY991SPOdRG6AtktE4xIeglf4gwq9JrCsT/hQXTAvu3rPjLtE6nbxhPckV3k7K9d9AFQGiXp+D7VxXdy4zxq11LCzXy8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Y84BbjiQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Y84BbjiQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E851BC4CEE7; Mon, 12 May 2025 18:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747073518; bh=Z5vwSh+Ucf53hn0XT6TDNevSk+BvlaStrLRLTJtMtMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y84BbjiQWEQ85ChbRp5gw2jQ2TzdQrbBZCeukqK9hWBfMd5dM5KXW7VO3AB+QJ2N8 z9WMvIwgZb4WSU1z1GxI1+QtfLi3X8TWEb3KrvVAnoiSSxpBVvF/juopJuvz9Gd3e7 Ol8Iw+8J9TeLRwZs35yzpflWPmRYP/Etoh5/ZLQg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pawan Gupta , Ingo Molnar , Linus Torvalds , Peter Zijlstra Subject: [PATCH 6.6 101/113] x86/speculation: Simplify and make CALL_NOSPEC consistent Date: Mon, 12 May 2025 19:46:30 +0200 Message-ID: <20250512172031.782548957@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512172027.691520737@linuxfoundation.org> References: <20250512172027.691520737@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pawan Gupta commit cfceff8526a426948b53445c02bcb98453c7330d upstream. CALL_NOSPEC macro is used to generate Spectre-v2 mitigation friendly indirect branches. At compile time the macro defaults to indirect branch, and at runtime those can be patched to thunk based mitigations. This approach is opposite of what is done for the rest of the kernel, where the compile time default is to replace indirect calls with retpoline thunk calls. Make CALL_NOSPEC consistent with the rest of the kernel, default to retpoline thunk at compile time when CONFIG_RETPOLINE is enabled. [ pawan: s/CONFIG_MITIGATION_RETPOLINE/CONFIG_RETPOLINE/ ] Signed-off-by: Pawan Gupta Signed-off-by: Ingo Molnar Cc: Andrew Cooper Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20250228-call-nospec-v3-1-96599fed0f33@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/nospec-branch.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -458,16 +458,11 @@ static inline void x86_set_skl_return_th * Inline asm uses the %V modifier which is only in newer GCC * which is ensured when CONFIG_RETPOLINE is defined. */ -# define CALL_NOSPEC \ - ALTERNATIVE_2( \ - ANNOTATE_RETPOLINE_SAFE \ - "call *%[thunk_target]\n", \ - "call __x86_indirect_thunk_%V[thunk_target]\n", \ - X86_FEATURE_RETPOLINE, \ - "lfence;\n" \ - ANNOTATE_RETPOLINE_SAFE \ - "call *%[thunk_target]\n", \ - X86_FEATURE_RETPOLINE_LFENCE) +#ifdef CONFIG_RETPOLINE +#define CALL_NOSPEC "call __x86_indirect_thunk_%V[thunk_target]\n" +#else +#define CALL_NOSPEC "call *%[thunk_target]\n" +#endif # define THUNK_TARGET(addr) [thunk_target] "r" (addr)