From nobody Sun Dec 14 06:24:55 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 C0EC4C00140 for ; Mon, 15 Aug 2022 19:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344647AbiHOToA (ORCPT ); Mon, 15 Aug 2022 15:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344358AbiHOTkQ (ORCPT ); Mon, 15 Aug 2022 15:40:16 -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 9CD5E402F8; Mon, 15 Aug 2022 11:47:07 -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 C8256B81085; Mon, 15 Aug 2022 18:47:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ED4EC4314F; Mon, 15 Aug 2022 18:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589224; bh=RbdrB2ItTg/BQanc9oDqPCLEHobXmx1sahtu8v1k7UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EHwqrhV050ZvVoqer+hPRcV0FLIc3nl6RYTuVpRHpj+9mt5rtPxReAZ3RoTDW/oce fh5j2lkumch/rENuwKMwDrAWd/XXcAMdYwI5OjoV7n308JNf3WRUnHI3TUTDbWpRIL KfmGiM4DP60P/nXwvqaaQ3HB3IYeb+g2+B47C+FM= 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.15 651/779] x86/bus_lock: Dont assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero Date: Mon, 15 Aug 2022 20:04:55 +0200 Message-Id: <20220815180405.193350957@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 2c87d62f191e..ae7d4c85f4f4 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -1145,22 +1145,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