Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp906653pxj; Fri, 11 Jun 2021 15:02:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOrBkIMtKrPCUKS8niGW2zIbSRO/uedIKUYAb2uSHKLo5M7R3iiXEYfeo8m666XIO+S1WF X-Received: by 2002:a17:906:cd0e:: with SMTP id oz14mr5262901ejb.308.1623448954855; Fri, 11 Jun 2021 15:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623448954; cv=none; d=google.com; s=arc-20160816; b=s9fNHv0h+Ug91ykNMLESZ6YodEfHwLYy+bF4R5OAlMMBz8W9t3NaAns3P8FIKmLcff Uzg9RHC+ayafKfPLK7w6Wn/oGhm9NyhPu/fW5OSXM61KvSyu1+OnSB1MN+xVeebQifx5 46j778gdvkPFTcbXBQECqVtzIOym5puZNuRa0V/vW0e3mW42Laf+OhJwb+6fl+XvgNng UfFiVlOxHOme0LFbrszjOXuiwmjHYjsCxAnWvFp/hp/LQH6xskm7pRUfcJn9zjEWWdy3 P1knSPVqM/2iMywzpZmfD7VN7qTe4jtBH28gVIY2/esL3jBfrl4snA9cON+HXIm87jQd OVDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EEwR5/b08FCIuHBcZmeu6ocrkwRpJQ7CMwf2+fRzK8o=; b=VNhq98wo0Zzxab8AaSFPZ2RRMW1k4yrivjALxZCdLkfo6p0HZ/e+FXxXp5lSJTfVOS 9lK2I+AUSoAhPtflNNvI1Id5RvaLf5ip2VgTfMaQ7WmoHHeAMa69RgTFryykcuZXIqy9 YTkR2zGpWXDkiaWzN7a8QtlCAZ5wuhZavJS3A/hBEbZcTXU8nzBq3cf73L+eaqhzeOMe s/v0LMRNiBQiVdV8VCieBm+6PZ2bZfPbXkgBFPIEnSumxsnpPmWgQXedR2lfRU1lw3BO qNQJqN968l5AHDu/AbyUUDa/PiJczHsFRjmiGN9m6WLRsOf/gX9dWfmEkzq3HzH1cl+z Q84w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=GXNqJE8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j27si5624170ejo.342.2021.06.11.15.02.11; Fri, 11 Jun 2021 15:02:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=GXNqJE8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230302AbhFKWDS (ORCPT + 99 others); Fri, 11 Jun 2021 18:03:18 -0400 Received: from mail.skyhub.de ([5.9.137.197]:35764 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbhFKWDR (ORCPT ); Fri, 11 Jun 2021 18:03:17 -0400 Received: from zn.tnic (p200300ec2f0aec00c039d52956c712fd.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:ec00:c039:d529:56c7:12fd]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 80F171EC01B7; Sat, 12 Jun 2021 00:01:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1623448877; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=EEwR5/b08FCIuHBcZmeu6ocrkwRpJQ7CMwf2+fRzK8o=; b=GXNqJE8MkSjDShDvC9yDZluu+iiqX7qHocrZi39M8iu9Y3Hvvbna0BEKsTJxmnqjWjzXWy 7B+XsSxLOFsPiXh7DU24EW46RT8m74XjyZ7OOkaxJbQxOQrLEi8/Lq2n9Ef2uTJMyyYjr2 IbswmaC7ikaNbpCrgNyR6DmChWDT4FY= Date: Sat, 12 Jun 2021 00:01:10 +0200 From: Borislav Petkov To: Pawan Gupta Cc: Thomas Gleixner , Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , x86@kernel.org, "H. Peter Anvin" , "Paul E. McKenney" , Randy Dunlap , Andrew Morton , "Maciej W. Rozycki" , Viresh Kumar , Vlastimil Babka , Tony Luck , Paolo Bonzini , Sean Christopherson , Kyung Min Park , Fenghua Yu , Ricardo Neri , Tom Lendacky , Juergen Gross , Krish Sadhukhan , Kan Liang , Joerg Roedel , Victor Ding , Srinivas Pandruvada , Brijesh Singh , Dave Hansen , Mike Rapoport , Anthony Steinhauser , Anand K Mistry , Andi Kleen , Miguel Ojeda , Joe Perches , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH 2/4] perf/x86/intel: Do not deploy workaround when TSX is deprecated Message-ID: References: <4926973a8b0b2ed78217add01b5c459a92f0d511.1623272033.git-series.pawan.kumar.gupta@linux.intel.com> <20210611213443.ira5gc65jlafz7pu@gupta-dev2.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210611213443.ira5gc65jlafz7pu@gupta-dev2.localdomain> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 11, 2021 at 02:34:43PM -0700, Pawan Gupta wrote: > > > diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c > > > index e28892270c58..b5953e1e59a2 100644 > > > --- a/arch/x86/events/intel/core.c > > > +++ b/arch/x86/events/intel/core.c > > > @@ -6016,10 +6016,24 @@ __init int intel_pmu_init(void) > > > intel_pmu_pebs_data_source_skl(pmem); > > > > > > if (boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)) { > > > - x86_pmu.flags |= PMU_FL_TFA; > > > - x86_pmu.get_event_constraints = tfa_get_event_constraints; > > > - x86_pmu.enable_all = intel_tfa_pmu_enable_all; > > > - x86_pmu.commit_scheduling = intel_tfa_commit_scheduling; > > > + u64 msr; > > > + > > > + rdmsrl(MSR_TSX_FORCE_ABORT, msr); > > > + /* Systems that enumerate CPUID.RTM_ALWAYS_ABORT or > > > + * support MSR_TSX_FORCE_ABORT[SDV_ENABLE_RTM] bit have > > > + * TSX deprecated by default. TSX force abort hooks are > > > + * not required on these systems. > > > > So if they're not required, why aren't you simply disabling the force > > abort "workaround" by clearing the feature flag? > > Feature flag also enumerates MSR_TSX_FORCE_ABORT, which is still present > after the microcode update. Patch 3/4 in this series clears the TSX > CPUID bits using MSR_TSX_FORCE_ABORT. So we do need the feature flag > X86_FEATURE_TSX_FORCE_ABORT. So it seems to me then, the if test above should be changed to: if (boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT) && !boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)) { ... and no need for the MSR read. Please don't tell me there are configurations where CPUID.RTM_ALWAYS_ABORT is clear but the MSR_TSX_FORCE_ABORT[SDV_ENABLE_RTM] is there?! This "A new CPUID bit CPUID.RTM_ALWAYS_ABORT (CPUID 7.EDX[11]) is added to indicate the status of always abort behavior." tells me that the CPUID bit is always set by the microcode so we should be ok. If not, you should read that MSR early and do setup_force_cpu_cap(X86_FEATURE_RTM_ALWAYS_ABORT) so that this "always abort" flag is always set when TSX transactions are always aborted. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette