Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2292210pxb; Wed, 9 Feb 2022 15:20:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAM2UihtB5IWzt9hVvQN7wld9kRl3caBW1Wxz5dva7ey2a6kRMor12y3chgacQ8Crv5YOx X-Received: by 2002:a65:6651:: with SMTP id z17mr3748955pgv.259.1644448859061; Wed, 09 Feb 2022 15:20:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644448859; cv=none; d=google.com; s=arc-20160816; b=Y/apgviaKYV/pUqTGTXPGc9etRVi5i95mepI1U/ZufCC4gWVsMjn0B8hgV5OAVRkKE OqgIMOjuOfTsQ1JpeD+vxANw6RzVhJnBO/a1WlxIiILxb02K0m7Foqtqwyr3hZRdMSJD vn9ocCmitTeMJGWZFjcXBwupsxOAPGcIloLZL0xhuA9z26LksYWxH1VjqSmTxAEvca6U FG7N0DkMn+CfVvEpc1AwCNbVTMnzn2oEFNPIUXcg1vcRbVldA/xeuefVmYqs4hXU+GWT Rfsi7ZTuZ7sIJ7uvNauIfT+7yvQMbTmM73r0tcXr5K1HO/Z8K9M0Tppps5sF27sw+Ce8 caiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=anhcdRJ2Oe1dscW0e7hfA0zhDDSKlBVx2VNFQdtctQ8=; b=EJ1r8PeHfP8Da96iPILzPtq5XGMNRCzs22O2Wc0E4o5ITEMOpVwCZo4ng69lQLvBO3 elss57EsK9Md4hZbytqWI3YCykc7l8l9ni78XZZIOq76pZ3NqClN8/8a0g3x1KnMeiJr 8KAz8HJk+9j1NDWYfgqvCXgJox5dsbKU9Mwf4j+BbW2V0jzns4p/nHukreH87+6WDU9A rJcHnVBl645TxQ6AlZ1ObjOgWm2ulaZgIO9LCS4EUu7KM50RbQgT/wSRKCGc8DaRkPg+ Q0dAM0dxB9fDkYryrlh58hnlOAyAFC+kLR0klX0bo9IrTfc/ZF1NCSpqyPR75sm1IK76 Hg/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dpLoguLE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u31si17164844pfg.208.2022.02.09.15.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:20:59 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dpLoguLE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D61E0E051380; Wed, 9 Feb 2022 15:17:28 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232764AbiBIVEj (ORCPT + 99 others); Wed, 9 Feb 2022 16:04:39 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:54956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232762AbiBIVEe (ORCPT ); Wed, 9 Feb 2022 16:04:34 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA92C033255 for ; Wed, 9 Feb 2022 13:04:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644440677; x=1675976677; h=date:from:to:cc:subject:message-id:mime-version; bh=9WFgncTQailPw0fCuxpKTUIeFrcwnCEtfpmUPBiT+Zg=; b=dpLoguLEY9t2TFtVeHbzyThtW2oSsiYEQbzS4XZaq/7QNJhAur4dn+2+ cj/hs8haeyfGETEl1l+CMgZYlfPkiIrwDKPF9muJISmFYKXsUx3N0Xr+m rzid2pycZil+1sq/nO6+AdI4lH5qUfia1iNSx7KQRMDEQdPTgHToDBENP 6NCCCiaqvVmX0DvyyahjSuE8ScB/lo7kSsUho8TufyoCgYv3hyQ+4cbZi R1hb7cah84krsnMZhEYgvelTsq9SoOlL0fKbOrLaHTdEI8Gvrq+DFBZ2F 7wvW4Hzeot7JpGN+ZY5xK6KBL0W8DwqRSJQ5hmGKS+smJ2kQgNp4TDcIG g==; X-IronPort-AV: E=McAfee;i="6200,9189,10253"; a="246914846" X-IronPort-AV: E=Sophos;i="5.88,356,1635231600"; d="scan'208";a="246914846" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 13:04:36 -0800 X-IronPort-AV: E=Sophos;i="5.88,356,1635231600"; d="scan'208";a="701411368" Received: from guptapa-mobl1.amr.corp.intel.com ([10.251.3.164]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 13:04:36 -0800 Date: Wed, 9 Feb 2022 13:04:36 -0800 From: Pawan Gupta To: Thomas Gleixner , Borislav Petkov Cc: Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andi Kleen , Tony Luck , linux-kernel@vger.kernel.org, antonio.gomez.iglesias@linux.intel.com, neelima.krishnan@intel.com Subject: [PATCH] x86/tsx: Use MSR_TSX_CTRL to clear CPUID bits Message-ID: <5bd785a1d6ea0b572250add0c6617b4504bc24d1.1644440311.git.pawan.kumar.gupta@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 tsx_clear_cpuid() uses MSR_TSX_FORCE_ABORT to clear CPUID.RTM and CPUID.HLE. Not all CPUs support MSR_TSX_FORCE_ABORT, alternatively use MSR_IA32_TSX_CTRL when supported. Fixes: 293649307ef9 ("x86/tsx: Clear CPUID bits when TSX always force aborts") Reported-by: kernel test robot Tested-by: Neelima Krishnan Signed-off-by: Pawan Gupta --- arch/x86/kernel/cpu/tsx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/tsx.c b/arch/x86/kernel/cpu/tsx.c index 9c7a5f049292..c2343ea911e8 100644 --- a/arch/x86/kernel/cpu/tsx.c +++ b/arch/x86/kernel/cpu/tsx.c @@ -58,7 +58,7 @@ void tsx_enable(void) wrmsrl(MSR_IA32_TSX_CTRL, tsx); } -static bool __init tsx_ctrl_is_supported(void) +static bool tsx_ctrl_is_supported(void) { u64 ia32_cap = x86_read_arch_cap_msr(); @@ -97,6 +97,10 @@ void tsx_clear_cpuid(void) rdmsrl(MSR_TSX_FORCE_ABORT, msr); msr |= MSR_TFA_TSX_CPUID_CLEAR; wrmsrl(MSR_TSX_FORCE_ABORT, msr); + } else if (tsx_ctrl_is_supported()) { + rdmsrl(MSR_IA32_TSX_CTRL, msr); + msr |= TSX_CTRL_CPUID_CLEAR; + wrmsrl(MSR_IA32_TSX_CTRL, msr); } } @@ -106,13 +110,11 @@ void __init tsx_init(void) int ret; /* - * Hardware will always abort a TSX transaction if both CPUID bits - * RTM_ALWAYS_ABORT and TSX_FORCE_ABORT are set. In this case, it is - * better not to enumerate CPUID.RTM and CPUID.HLE bits. Clear them - * here. + * Hardware will always abort a TSX transaction when CPUID + * RTM_ALWAYS_ABORT is set. In this case, it is better not to enumerate + * CPUID.RTM and CPUID.HLE bits. Clear them here. */ - if (boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT) && - boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)) { + if (boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)) { tsx_ctrl_state = TSX_CTRL_RTM_ALWAYS_ABORT; tsx_clear_cpuid(); setup_clear_cpu_cap(X86_FEATURE_RTM); -- 2.31.1