[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210611232114.3dmmkpkkcqg5orhw@gupta-dev2.localdomain>
Date: Fri, 11 Jun 2021 16:21:14 -0700
From: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
To: Borislav Petkov <bp@...en8.de>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Jonathan Corbet <corbet@....net>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"Maciej W. Rozycki" <macro@...am.me.uk>,
Viresh Kumar <viresh.kumar@...aro.org>,
Vlastimil Babka <vbabka@...e.cz>,
Tony Luck <tony.luck@...el.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Kyung Min Park <kyung.min.park@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>,
Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>,
Tom Lendacky <thomas.lendacky@....com>,
Juergen Gross <jgross@...e.com>,
Krish Sadhukhan <krish.sadhukhan@...cle.com>,
Kan Liang <kan.liang@...ux.intel.com>,
Joerg Roedel <jroedel@...e.de>,
Victor Ding <victording@...gle.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Brijesh Singh <brijesh.singh@....com>,
Dave Hansen <dave.hansen@...el.com>,
Mike Rapoport <rppt@...nel.org>,
Anthony Steinhauser <asteinhauser@...gle.com>,
Anand K Mistry <amistry@...gle.com>,
Andi Kleen <ak@...ux.intel.com>,
Miguel Ojeda <ojeda@...nel.org>, Joe Perches <joe@...ches.com>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 2/4] perf/x86/intel: Do not deploy workaround when TSX is
deprecated
On 12.06.2021 00:01, Borislav Petkov wrote:
>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?!
MSR_TSX_FORCE_ABORT[SDV_ENABLE_RTM]=1 actually clears
CPUID.RTM_ALWAYS_ABORT, because in this case RTM is enabled and doesn't
always aborts. As the code above is only executed at bootup and BIOS is
not expected to set it. So at bootup SDV_ENABLE_RTM will be clear (if we
ignore kexec) then yes, MSR read can avoided.
>
>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.
Yes, but MSR_TSX_FORCE_ABORT[SDV_ENABLE_RTM]=1 clears it. As
SDV_ENABLE_RTM is expected to be set only by developers (e.g. using
msr-tools), it should be fine in most other user cases. So we can avoid
reading the MSR.
>
>If not, you should read that MSR early and do
Isn't the MSR read early enough already:
early_initcall()
init_hw_perf_events()
intel_pmu_init()
MSR read
Anyways, we can avoid reading the MSR completely and rely on
CPUID.RTM_ALWAYS_ABORT. I will change it in the next version.
Thanks,
Pawan
>
> setup_force_cpu_cap(X86_FEATURE_RTM_ALWAYS_ABORT)
>
>so that this "always abort" flag is always set when TSX transactions are
>always aborted.
Powered by blists - more mailing lists