Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3115817rwb; Mon, 15 Aug 2022 18:30:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR40WI/bfl3dTDk4+umRXb0yxTnIXjS9WFAs01QB2LpYKtWuDS/4dlSGVs/DSIlGNFzjuEZK X-Received: by 2002:a65:464a:0:b0:429:7548:722 with SMTP id k10-20020a65464a000000b0042975480722mr5058425pgr.7.1660613408227; Mon, 15 Aug 2022 18:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613408; cv=none; d=google.com; s=arc-20160816; b=HmIN+ivAR9oNZx5dgkjkFxQZGW+NJXlMMC9Eo0spBU6zL0xikzAQfkHNk0Mypk225C pk5+NJivBFeGhoI4mF6R1ULva513EZ/KyNPhlmvGiLo7yO9ISIjPCygh9aeHFAlMlSmW 6TpEndoMS0V3vFwx13b6+TEVT9xY3dAonaOXLPqXoj6M1+7ycN6eu/5sPdZnJlzlZyFY zyIa4BOfmnfM8mgYE+ZTmY++NpG8JkftBLqHK7hmePWHK7KyJJ/hjqgnsWbctb1vtJAg cI53nQYnssQRRUeYS0IAJMMq0/enOGF3bCm11moXetXqGBYt7R4xOiGdueY/9vIC7doH uLdQ== 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=uRL3i44UZXEE1grsjXpQFKInpkeEDzJBf09pPc0PCus=; b=e3hHutO0o68a/oNQCj+5ojEg6IdKC4OUv451IUrO1efekFb7LBWvt4NCkGIuU9/Akj l/ShB5G21d2Gdw1+C+5mRo7o8bigkru5nkJHDKTEx2R5c/0ORmaeQB1oa20MbYc6wQlu gFmuypiT1CzA7G5V2cuoquTVArr8kcYct3EpY2sAWp/ynaznC2jrz+ZJ7Aecjcdhgi6b ccRBDBPW1lfTe3kGx9tQgpGphfcrYK94P81GdOZCI0Df4hH4CCLFxbA8me2AtefDVRT3 9maeXhhnevbWa6lU5udjZKxw4p20/X0CbnEnNH6NTM52uq03tDOZOKPlDFaSFxRBRCi6 5WEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rbLzHBeC; 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 b3-20020a170903228300b001708e1bb3b8si13234874plh.335.2022.08.15.18.29.57; Mon, 15 Aug 2022 18:30:08 -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=rbLzHBeC; 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 S232367AbiHPAx5 (ORCPT + 99 others); Mon, 15 Aug 2022 20:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350124AbiHPAqv (ORCPT ); Mon, 15 Aug 2022 20:46:51 -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 6C6EDD8E32; Mon, 15 Aug 2022 13:45:42 -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 6105BB80EAD; Mon, 15 Aug 2022 20:45:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B34C8C433D7; Mon, 15 Aug 2022 20:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596339; bh=oYX06H7Q/VqhynFigD32O2XLFCsEWftHbR1tJ5BP51Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rbLzHBeCeAjco07WDk3jweT0Zu4jb3ctpccvWPn/fI/hG4Sfw+mT/gS8wdhN992jq 5CmS1COOaEhfXyrCdrT7aksAy7pJ8hSCexzf5vqMr/qiZrL3YCd1GMdKiY4gpWYbIV /BO7cgWvPBOf9ZDiAVvnlbSS2/NNAN1TsHcw76oc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chenyi Qiang , Ingo Molnar , Tony Luck , Sasha Levin Subject: [PATCH 5.19 1015/1157] x86/bus_lock: Dont assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero Date: Mon, 15 Aug 2022 20:06:11 +0200 Message-Id: <20220815180520.475236950@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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: Chenyi Qiang [ Upstream commit ffa6482e461ff550325356ae705b79e256702ea9 ] It's possible that this kernel has been kexec'd from a kernel that enabled bus lock detection, or (hypothetically) BIOS/firmware has set DEBUGCTLMSR_BUS_LOCK_DETECT. Disable bus lock detection explicitly if not wanted. Fixes: ebb1064e7c2e ("x86/traps: Handle #DB for bus lock") Signed-off-by: Chenyi Qiang Signed-off-by: Ingo Molnar Reviewed-by: Tony Luck Link: https://lore.kernel.org/r/20220802033206.21333-1-chenyi.qiang@intel.com Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/intel.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index fd5dead8371c..cb796ca6eff5 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -1216,22 +1216,23 @@ static void bus_lock_init(void) { u64 val; - /* - * Warn and fatal are handled by #AC for split lock if #AC for - * split lock is supported. - */ - if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) || - (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) && - (sld_state == sld_warn || sld_state == sld_fatal)) || - sld_state == sld_off) + if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT)) return; - /* - * Enable #DB for bus lock. All bus locks are handled in #DB except - * split locks are handled in #AC in the fatal case. - */ rdmsrl(MSR_IA32_DEBUGCTLMSR, val); - val |= DEBUGCTLMSR_BUS_LOCK_DETECT; + + if ((boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) && + (sld_state == sld_warn || sld_state == sld_fatal)) || + sld_state == sld_off) { + /* + * Warn and fatal are handled by #AC for split lock if #AC for + * split lock is supported. + */ + val &= ~DEBUGCTLMSR_BUS_LOCK_DETECT; + } else { + val |= DEBUGCTLMSR_BUS_LOCK_DETECT; + } + wrmsrl(MSR_IA32_DEBUGCTLMSR, val); } -- 2.35.1