From: Robert Richter <rrichter@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@intel.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
linux-kernel@vger.kernel.org, jgross@suse.com,
tglx@linutronix.de, x86@kernel.org,
Kim Phillips <kim.phillips@amd.com>,
Robert Richter <rric@kernel.org>
Subject: Re: [PATCH 2/4] perf/x86/ibs: Use CPUID region helper
Date: Thu, 18 Apr 2024 14:05:49 +0200 [thread overview]
Message-ID: <ZiEMnWaHkn99_oyW@rric.localdomain> (raw)
In-Reply-To: <20240416174850.GEZh66AmnDjrLxoXaw@fat_crate.local>
On 16.04.24 19:48:50, Borislav Petkov wrote:
> On Tue, Apr 16, 2024 at 08:23:58AM -0700, Dave Hansen wrote:
> > When I was looking at it, I (maybe wrongly) assumed that 0x8000001b and
> > X86_FEATURE_IBS were independent for a reason. Because, oddly enough:
> >
> > #define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \
> > | IBS_CAPS_FETCHSAM \
> > | IBS_CAPS_OPSAM)
> >
> > So, if the CPU enumerates X86_FEATURE_IBS but has a
> > max_level<IBS_CPUID_FEATURES then it assumes there's a working IBS
> > because the software-inserted IBS_CAPS_DEFAULT has IBS_CAPS_AVAIL set.
>
> Right, that's why I added Robert. I found this in a F10h doc (old
> Greyhound CPU rust):
>
> "CPUID Fn8000_0001_ECX Feature Identifiers
>
> ...
>
> 10: IBS: Instruction Based Sampling = 1.
>
> ...
>
> CPUID Fn8000_001B Instruction Based Sampling Identifiers
>
> ...
>
> IBSFFV. IBS feature flags valid. Revision B = 0. Revision C = 1."
>
> which makes this look like some hack to fix broken CPUID IBS reporting.
There is the X86_FEATURE_IBS bit (Fn8000_0001_ECX, bit 10) which is
available from the beginning of IBS (all Fam10h production releases,
revB onwards).
And right, IBS_CPUID_FEATURES (CPUID Fn8000_001B) was introduced with
revC. The capabilities of revB are set in IBS_CAPS_DEFAULT.
It doesn't look broken to me, simply the ibs caps field was introduced
later which can be determined checking the return code of
get_cpuid_region_leaf().
>
> And if it is that, I don't think we care, frankly, because revB is
> ooold. Mine is somewhere in the basement on some old board which got
> bricked so I don't know even if I could use it anymore.
>
> And I'm not even planing to - that CPU is almost 20 years old and no one
> cares whether it can even do IBS.
>
> So I wouldn't mind at all if we simplify this code for the sake of it.
> I don't think anyone would care or notice.
>
> But let's see what Robert says first...
My preference would be:
[...]
if (!get_cpuid_region_leaf(IBS_CPUID_FEATURES, CPUID_EAX, &caps))
return IBS_CAPS_DEFAULT;
if (caps & IBS_CAPS_AVAIL)
return caps;
return 0;
[...]
Not too complex?
This slightly modifies the functionality so that 0 is return if
!IBS_CAPS_AVAIL (instead of IBS_CAPS_DEFAULT). The feature could be
disabled then by overriding IBS_CAPS_AVAIL by just clearing the ibs
leaf, valid even for newer systems.
Thanks,
-Robert
next prev parent reply other threads:[~2024-04-18 12:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 15:35 [PATCH 0/4] [v2] x86: Add CPUID region helper and clarify Xen startup Dave Hansen
2024-04-03 15:35 ` [PATCH 1/4] x86/cpu: Add and use new CPUID region helper Dave Hansen
2024-04-04 9:04 ` Jürgen Groß
2024-04-08 16:25 ` Borislav Petkov
2024-04-03 15:35 ` [PATCH 2/4] perf/x86/ibs: Use " Dave Hansen
2024-04-16 15:12 ` Borislav Petkov
2024-04-16 15:23 ` Dave Hansen
2024-04-16 17:48 ` Borislav Petkov
2024-04-18 12:05 ` Robert Richter [this message]
2024-04-22 17:20 ` Borislav Petkov
2024-04-22 20:09 ` Robert Richter
2024-04-22 20:41 ` Borislav Petkov
2024-04-22 21:30 ` Robert Richter
2024-04-22 21:45 ` Borislav Petkov
2024-04-23 7:45 ` Robert Richter
2024-04-23 8:33 ` Borislav Petkov
2024-04-03 15:35 ` [PATCH 3/4] x86/boot: Explicitly pass NX enabling status Dave Hansen
2024-04-04 10:33 ` Jürgen Groß
2024-04-03 15:35 ` [PATCH 4/4] x86/xen: Enumerate NX from CPUID directly Dave Hansen
2024-04-04 10:44 ` Jürgen Groß
2024-04-04 14:24 ` Dave Hansen
2024-04-04 15:05 ` Sean Christopherson
2024-04-22 17:44 ` Borislav Petkov
-- strict thread matches above, loose matches on Subject: below --
2024-03-22 17:56 [PATCH 0/4] x86: Add CPUID region helper and clarify Xen startup Dave Hansen
2024-03-22 17:56 ` [PATCH 2/4] perf/x86/ibs: Use CPUID region helper Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZiEMnWaHkn99_oyW@rric.localdomain \
--to=rrichter@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jgross@suse.com \
--cc=kim.phillips@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rric@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®