From nobody Mon Sep 29 20:17:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 518BFC25B08 for ; Tue, 16 Aug 2022 00:54:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231368AbiHPAx7 (ORCPT ); Mon, 15 Aug 2022 20:53:59 -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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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.c= om 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; =20 - /* - * 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 =3D=3D sld_warn || sld_state =3D=3D sld_fatal)) || - sld_state =3D=3D sld_off) + if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT)) return; =20 - /* - * 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 |=3D DEBUGCTLMSR_BUS_LOCK_DETECT; + + if ((boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) && + (sld_state =3D=3D sld_warn || sld_state =3D=3D sld_fatal)) || + sld_state =3D=3D sld_off) { + /* + * Warn and fatal are handled by #AC for split lock if #AC for + * split lock is supported. + */ + val &=3D ~DEBUGCTLMSR_BUS_LOCK_DETECT; + } else { + val |=3D DEBUGCTLMSR_BUS_LOCK_DETECT; + } + wrmsrl(MSR_IA32_DEBUGCTLMSR, val); } =20 --=20 2.35.1