Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4704720imw; Tue, 12 Jul 2022 12:44:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8rxKtm7dpmNifnA2i45gXQwHK0WBaL0zxWGVkFOKrGEzqC78K+GesKrxdFmp2EhKU/cow X-Received: by 2002:a05:6402:50ce:b0:43a:c86a:b897 with SMTP id h14-20020a05640250ce00b0043ac86ab897mr21400176edb.321.1657655046726; Tue, 12 Jul 2022 12:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657655046; cv=none; d=google.com; s=arc-20160816; b=LfXL+1RLJo1qBWq77I5E1YKv4qIW7WgyaNGVwANZYloIol6Sshs2sqV0c4Jf+IaOAr PQ0bHqtCReZgnwzMGYzcU/Sl6/JxQT6J/8U8yfHATPa5j7Ok65pqwCmFJWgOSYmJ9XRG Ryh/4v66MiuxqJuZWA5xGeWCoQih35IzQazDcQacBh9Qz+RcvfDExmOdLQapCW2e9b1B TbQlJ4qkcYkOGn11urjAeQmmHcr0dSyNozdjExhDkfjszqzZltw5M/o1gOnVkhnVZljP ZEIm3IvB/VtASwsOb4ROY854uz6UkIIXRY8sqaCPuceLiVI6QzHK3DKFbTjdThnBaJBL uyBw== 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=XuSf238Y61Hhd2EYoBEeOevbWffbVTJ8YluETKNyNAAeq/OLM/f1CmErbSnx3YIw1u nlql5bT1jlFE/PjJVi/o/poOqHlE3HDKIj+RBmi2DTy+wVz8Ou0rSYHQeanrYXvUMhia ssFoWlcIdkSlKPAhosDreuDZCvbZ/wqUlYME+ExM0+BSSKMytvcPK0v4+BrE+tVT8dhX oYkGx2FQuO8FtCd6kKNtev7IYm7fU7Fa/yjcvJ/C2OJI/iR2sJhMuLTCqISIBz0XTqqk G0hL69PrhGQituH8Hxs963FJWaBUHDmcmQk9EfMv2sQ7AxvS2NfO9PGwUwCOwWkZ15br 4znA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ObxHOx7g; 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 h1-20020a056402280100b0043779a90504si20296249ede.606.2022.07.12.12.43.41; Tue, 12 Jul 2022 12:44: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=pass header.i=@linuxfoundation.org header.s=korg header.b=ObxHOx7g; 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 S235982AbiGLTPa (ORCPT + 99 others); Tue, 12 Jul 2022 15:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236109AbiGLTO1 (ORCPT ); Tue, 12 Jul 2022 15:14:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C972E3C11; Tue, 12 Jul 2022 11:54:06 -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 4FED4B81BBB; Tue, 12 Jul 2022 18:54:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F0F9C3411C; Tue, 12 Jul 2022 18:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657652044; bh=uhBrisFVLThMsYeuo2ULPy9OQBk+D9VBI8P0/O0N2yM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ObxHOx7gnHvCwVr7yllEo5UiYekEuRPPo540u9KAJM5anJkNkeRl1kTCpdI2/CCVq WZ+I/OcYvcsm0e5keZbUmrVXsTb5E2yNIR25tvtwkwbi96Cf1mdlFW/zdi5+KMGUFN CTyf26sJR90oczZp6Ne9fq37mn577T9ScpGf/+hg= 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/61] x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n Date: Tue, 12 Jul 2022 20:39:38 +0200 Message-Id: <20220712183238.608252082@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183236.931648980@linuxfoundation.org> References: <20220712183236.931648980@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.7 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,T_SCC_BODY_TEXT_LINE 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 /*