Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp458608imi; Fri, 22 Jul 2022 02:50:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uYPhLmMFrnB1jHbswsMkg2l1SQXpO4vlmv2H/v+f9G1Th8psgVtfwQnYg/Rt9PPiE0EeFU X-Received: by 2002:a05:6a00:99f:b0:52a:dd61:a50f with SMTP id u31-20020a056a00099f00b0052add61a50fmr2684276pfg.9.1658483430773; Fri, 22 Jul 2022 02:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483430; cv=none; d=google.com; s=arc-20160816; b=RlRKQhkg9iFDv/EsCoWWzU7N/TJHbSeFrVzVmz0olS6hyX/9e7IJ9zCfdukFUlIzqr 6/TTW2ZRarNha8fBJcZbNmQP3ekfyMdLp9aw9lWEVIht9wyM+tDIDPPv5iORFCc/lCi/ 5btyvfI3tYtXGNve03EMxvYaBdKOBVR308ySOALJniVzjCYmisMQU71ojdQFCHrgoyJi cpyuQsWXwM1QgcLO24/LDi5pIzE4X8XowymkbkX1MvpPAUcoeLVRUAiBPKrRj4/ZWyx0 PNsGTaM1fi9/CMSNqXyC7+M/edcvUlPR3rCc7/qJjKEF0ONp0zNWlhdwjX+o9A4dvgQC D1gw== 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=c1X3n7PZwWDQR8dXcDAgGDvcB2zwStCNalUjhLLfWao=; b=Y8pU7xQHso3pE5EXDdmaqCeUbzxsQBmX9TZWpceB89qLS8xhOBzL0ALkEWym/jWOVS MaVn5DH4/fyXN+KEpjLksfwffAvgMQjRBI5AyPVvcr5VyW/As9VFuUeqwTODW3oiY9xA Rfw//XiGtMS6exiKAkRzlsxtZd7aIj4DqJeHhDoKnSHEM/8UZ9U/5h3qeYqM2GhF7M1G dF6BGXk2fzgZQnO2KAUbgz/ex35FY/H9vAfUjxhV7+nRxmncuaKsEQaN0JgIFK58AnHZ 7OHQTkYTAvbLcQGoQrigzUbsEVwNVmO+l+SI5JikdL5g2wrry/OhWmbNOUJlUg4Uw/RX FAnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Nfq3GAjf; 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 h16-20020a17090aa89000b001f24c2b9730si1151209pjq.20.2022.07.22.02.50.16; Fri, 22 Jul 2022 02:50:30 -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=Nfq3GAjf; 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 S235418AbiGVJMn (ORCPT + 99 others); Fri, 22 Jul 2022 05:12:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235285AbiGVJMH (ORCPT ); Fri, 22 Jul 2022 05:12:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14CBA024D; Fri, 22 Jul 2022 02:09:57 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 41F7961EE7; Fri, 22 Jul 2022 09:09:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44383C341C6; Fri, 22 Jul 2022 09:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658480996; bh=t55yt/LMlIfpbPsw7IS/Yaxzn6Vb7UHsPvECtfrxVOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nfq3GAjfNOA2IjQ0kCu/HnXYKC9w3QpUFhFZO4VuVrrxH5G1gp1mP9zQ1ClEPAvlE 0NOJalMf1fzz/xZdOwUCmh8oELHikLdkKSxOvO/oyIoJVWXigA0LzpbHru/pRvGC7V 4rxFAY9rE8eBkfu9wCk5FV1rqJlPzkq6CD2IuTEM= 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 42/70] x86/speculation: Fix firmware entry SPEC_CTRL handling Date: Fri, 22 Jul 2022 11:07:37 +0200 Message-Id: <20220722090653.073944979@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 e6aa13622ea8283cc699cac5d018cc40a2ba2010 upstream. The firmware entry code may accidentally clear STIBP or SSBD. Fix that. 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/include/asm/nospec-branch.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -285,18 +285,16 @@ extern u64 spec_ctrl_current(void); */ #define firmware_restrict_branch_speculation_start() \ do { \ - u64 val = x86_spec_ctrl_base | SPEC_CTRL_IBRS; \ - \ preempt_disable(); \ - alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \ + alternative_msr_write(MSR_IA32_SPEC_CTRL, \ + spec_ctrl_current() | SPEC_CTRL_IBRS, \ X86_FEATURE_USE_IBRS_FW); \ } while (0) #define firmware_restrict_branch_speculation_end() \ do { \ - u64 val = x86_spec_ctrl_base; \ - \ - alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \ + alternative_msr_write(MSR_IA32_SPEC_CTRL, \ + spec_ctrl_current(), \ X86_FEATURE_USE_IBRS_FW); \ preempt_enable(); \ } while (0)