Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2883193rwb; Mon, 15 Aug 2022 13:15:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR7No9xeGu1A8ZHC3yeLaMqlrf9IMSBBCkszGljPbQtDEkBPzzOOq5aRrfy9LKp29kUAX86P X-Received: by 2002:aa7:da10:0:b0:443:6bbd:a6ce with SMTP id r16-20020aa7da10000000b004436bbda6cemr11166112eds.191.1660594523258; Mon, 15 Aug 2022 13:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594523; cv=none; d=google.com; s=arc-20160816; b=EfVnCqJoHEQAW3NzVWmzR1T57h9EOeihlbI9XScenI5qjLida8h8pUKFRuxUsBxxFc ft8WEpHrSe174i2rGW8EWrZkGYNTCfChr5tXsPc40UNUZ8+x+YSB2LgHi0ErxA21vm2G FEhMAme1qJzK24/3TfmW/NNE6n/zWBCNIG/pKm1drfVlrdomEgVHHHJq5l89X4X3vVna NEn+lfupepSL2coO7YznswOyxN0hsjfknEvcDQ0+DgOs0xo6ZA+5/S9mAA72Js+/lNwk nMY/OFWwVb6qfHQ2680yelEJTwqM6wdZtEAmPMjKGlWJCdmonajjnUiJgDxbNpdct53V fRAg== 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=vwQKqW/u4qPx8KflDcEbKNkrlYjnD5But4FXlq6J9FY=; b=vJRzqSZ/Rtvn0B44ZfOPuqwoo/4s6YboqjQaWMcdshUaunZyWPgtGZeZ2wwi0Zk7zc Xbo6gE1tm0V7MuSnsDBljcv8ct9gvsf73F+dUvJeVGarA3i/QwILJUOeRhcsJzO4kD6v hKHYmLBuWDqz8WrqhCDegppbwIkjN93PzA9kfh4V2ObzzaK1M4MMIbzCqUF7qGxZOFFJ L6Y63FhvkOlnz27jbkA3ah7q4BywvGwZNASiP6m1UyQM0iNGTFa3oWFPp2Hb8CVtX62b Xg3HkoHlQLa6OrYK37jRWVZclVpgh+dwZK0UOmq+4EHKLzPjBzy/8LXwp/OkIFbf/pod nn1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EHwqrhV0; 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 qk33-20020a1709077fa100b007121b9fc6fbsi8514206ejc.956.2022.08.15.13.14.56; Mon, 15 Aug 2022 13:15:23 -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=EHwqrhV0; 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 S1344636AbiHOTn7 (ORCPT + 99 others); Mon, 15 Aug 2022 15:43:59 -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-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 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; - /* - * 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