Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp457100imi; Fri, 22 Jul 2022 02:48:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tYx+2aaV6ls3sPbJUTJXo4SQaGVBqoRG4NHUMCzJgNfdNr6bpwllYaVnqd9w0zyVF9WbSy X-Received: by 2002:a63:a46:0:b0:412:b1d6:94cf with SMTP id z6-20020a630a46000000b00412b1d694cfmr2519345pgk.373.1658483293271; Fri, 22 Jul 2022 02:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483293; cv=none; d=google.com; s=arc-20160816; b=aXL1cozZIUDIGaDiT4Zge3kWVkOf+foaZFkpbSEL/1gL7RfSR69ixSNDI1HVetsOFe 9pQGynNtjL4wh7nO0+9k5UYP+Nzn7AOFwJDe4dzXd9TDQhJr67C+4oUSfXzwrpzYHjcH TraUnEh6pHztmSk/teNso5SXsiVTzCxo1p3CNHwN/4RKNFQTTWk/x0U26RO/bBGHiC0f YSXEljdQgWeJldZwjuyzeC41zbvVZgY8C44GkE1g8aCBQ6MsOVYhHOq4Aj0p7GB8jHPx wv8CQNrXK3N+4r/sY+P6fy2Dn2BxK/zJevk9z+VObi1KrdQJhzecQCnMQ2y3F7OrCgkx nqgg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/bV5yLtCxf3qIuGIknw1V3JXaAZUwEAq8dIVPk8Kb9U=; b=rLMSO5Qyb9TVV7Ik4M1m0DS9Amksa1UwjQ88By72DkklUwLe9KtBR8yqj1INC/iGnH Nd77DPZijsvJVGXUXMijeM5MKLhjp1jnwAmmcrXyXlz891mfZ9hGE2PkSPmqZiDPSaBC QL/IMbtZPr23sWjg0CktJmoCVD/iEtQnawN3Jx2pPzexymbY3uF38e/cBV3+W5sfEurC uouqWbgZfC2Ny8M47WCpeT5c0fc3LlXqrlGtLAi2DmV1Vt5E+HMFUhON74QoOB+0znK5 OldULrG1F2xGpBBYw4scrvXnfJna4ZVj4cinC8MWxYY/ZSGWUM8ihZ5dR1utZKfbgsMU jw9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PUXCllJY; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n22-20020a056a0007d600b0052b93453af1si5115148pfu.92.2022.07.22.02.47.59; Fri, 22 Jul 2022 02:48:13 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=PUXCllJY; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235371AbiGVJMj (ORCPT + 99 others); Fri, 22 Jul 2022 05:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235366AbiGVJMD (ORCPT ); Fri, 22 Jul 2022 05:12:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F3C8A0BA7; Fri, 22 Jul 2022 02:09:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E1D5DB827B2; Fri, 22 Jul 2022 09:09:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 468EBC341C6; Fri, 22 Jul 2022 09:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658480993; bh=uhBrisFVLThMsYeuo2ULPy9OQBk+D9VBI8P0/O0N2yM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PUXCllJYoxepP9ZFZkcfNMsHtQIrrFWWk5VFjuuXulr10RzMkiCvF+eUd/Kkk5DNx GNVZtkoo5T5C4BdMQOoXm+4WVvUnt7mKUGmIJIMG4fNSg9B73g+AgTi0ggDFmbk/Xg w90CgA2Vtol73R+GYe6pytMV9UxOyU2LQWDXZS2s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , "Peter Zijlstra (Intel)" , Borislav Petkov , Thadeu Lima de Souza Cascardo Subject: [PATCH 5.18 41/70] x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n Date: Fri, 22 Jul 2022 11:07:36 +0200 Message-Id: <20220722090653.018672773@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220722090650.665513668@linuxfoundation.org> References: <20220722090650.665513668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Josh Poimboeuf commit b2620facef4889fefcbf2e87284f34dcd4189bce upstream. If a kernel is built with CONFIG_RETPOLINE=n, but the user still wants to mitigate Spectre v2 using IBRS or eIBRS, the RSB filling will be silently disabled. There's nothing retpoline-specific about RSB buffer filling. Remove the CONFIG_RETPOLINE guards around it. Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Greg Kroah-Hartman --- arch/x86/entry/entry_32.S | 2 -- arch/x86/entry/entry_64.S | 2 -- arch/x86/include/asm/nospec-branch.h | 2 -- 3 files changed, 6 deletions(-) --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -698,7 +698,6 @@ SYM_CODE_START(__switch_to_asm) movl %ebx, PER_CPU_VAR(__stack_chk_guard) #endif -#ifdef CONFIG_RETPOLINE /* * When switching from a shallower to a deeper call stack * the RSB may either underflow or use entries populated @@ -707,7 +706,6 @@ SYM_CODE_START(__switch_to_asm) * speculative execution to prevent attack. */ FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW -#endif /* Restore flags or the incoming task to restore AC state. */ popfl --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -250,7 +250,6 @@ SYM_FUNC_START(__switch_to_asm) movq %rbx, PER_CPU_VAR(fixed_percpu_data) + stack_canary_offset #endif -#ifdef CONFIG_RETPOLINE /* * When switching from a shallower to a deeper call stack * the RSB may either underflow or use entries populated @@ -259,7 +258,6 @@ SYM_FUNC_START(__switch_to_asm) * speculative execution to prevent attack. */ FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW -#endif /* restore callee-saved registers */ popq %r15 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -122,11 +122,9 @@ * monstrosity above, manually. */ .macro FILL_RETURN_BUFFER reg:req nr:req ftr:req -#ifdef CONFIG_RETPOLINE ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr __FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP) .Lskip_rsb_\@: -#endif .endm /*