Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5239imw; Tue, 12 Jul 2022 13:24:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sCc/18HKXeXkpQPoSqsQtvbeFVLFY5SiOgR7E2FvDmPErR/ynwut8wOTyvCacNHnHvRzp3 X-Received: by 2002:a17:906:2086:b0:717:4e91:f1db with SMTP id 6-20020a170906208600b007174e91f1dbmr25247467ejq.345.1657656969373; Tue, 12 Jul 2022 13:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657656969; cv=none; d=google.com; s=arc-20160816; b=UDb5D5NyIfOdWqO4NhbysaXaAIHMorkBf6ggMPGCgbwD9PB/hY3tQWeaxq1Cb9jwlo RCkcAbCG94EEJWKjXnnphNjtlN+6NGB0T5i2yW+2Ie38vyqIm9Z7ef/mU/7o3YwYISy+ tiyKqsAWaQqclM5yqsHY1uOS1rSQ6IYq8p7RJ2zVfdRyrtfieFQhFCUIFQ9+5Pt7Tt36 yeKR9LNl+BkUXENHGKYie4b4JhKK7OzzRONykbYLv2dQ8ChY0v1EVqz5iioFo2UQ3it3 XnT97hbJXFgI/KEZHMK1E8eGRQCbH1l2tT6aNsaZiX4iAZa/ywRDZHoItIFWH6IUF6Yd VdHQ== 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=UNTohlQJRL6CsejGQoQ/2rcMuCdIOyNXNd3Xnip7fAfKf5YPtbh9n7YPuX9EJEzk5d VXdtixzZR8VwkwSmypmGkfcgYY0zeBkCELXj80JElTxda+Q/Xu6UHW4/505eW2ic8Uiw wBDjR6tsZpjFt4bUoHzqGOdzXIkqtgsYDln9k0FWeU8W7h8ffS9axZMQ6Dni5sNxWEdz teJE0GH2erFecoXiNXbaaqh/iqSM6DRolehxXVYKweRRGl1eLMbRu4VEzV3mNrZvbVFi AUHteSqk3QWe5b1fbihDDg2fKLixZ71q8v/z03fwPe2HtnO2PwXqxHwQe4/rOl4DGpq7 Qslg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jaf8xUgj; 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 m19-20020a170906849300b00722d8f8fe8asi12797224ejx.422.2022.07.12.13.15.26; Tue, 12 Jul 2022 13:16:09 -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=jaf8xUgj; 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 S235719AbiGLTP0 (ORCPT + 99 others); Tue, 12 Jul 2022 15:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236103AbiGLTO1 (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 4CC8CE6837; Tue, 12 Jul 2022 11:54:10 -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 8F414B81BBC; Tue, 12 Jul 2022 18:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4FD5C3411C; Tue, 12 Jul 2022 18:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657652047; bh=t55yt/LMlIfpbPsw7IS/Yaxzn6Vb7UHsPvECtfrxVOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jaf8xUgj2MoUu6TRWVRjm/0SOTv2XDRHnmuMkGGKLmoxr5EMoIBUtUM7A3khgsRCi 1RkqIAeY8/FgwPvRWN+JvKD/JPy9o4WdSbWOikUQe/h2/Reblg7SKmf3DK0WbkC/am MDCBFXSXGmCa2vFGDe4SaDmuBBp1WwMdc1iQZwyE= 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/61] x86/speculation: Fix firmware entry SPEC_CTRL handling Date: Tue, 12 Jul 2022 20:39:39 +0200 Message-Id: <20220712183238.642675838@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 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)