From: Ingo Molnar <mingo@kernel.org>
To: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, jgross@suse.com,
tglx@linutronix.de, x86@kernel.org, bp@alien8.de
Subject: Re: [PATCH 1/4] x86/cpu: Add and use new CPUID region helper
Date: Sun, 24 Mar 2024 05:38:02 +0100 [thread overview]
Message-ID: <Zf+uKi42qFoHLAUg@gmail.com> (raw)
In-Reply-To: <20240322175630.72CE974F@davehans-spike.ostc.intel.com>
* Dave Hansen <dave.hansen@linux.intel.com> wrote:
>
> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> There are some (before now) unwritten rules about CPUID "regions".
> Basically, there is a 32-bit address space of CPUID leaves. The
> top 16 bits address a "region" and the first leaf in a region
> is special.
>
> The kernel only has a few spots that care about this, but it's
> rather hard to make sense of the code as is.
>
> Add a helper that explains regions. Use it where applicable.
>
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Juergen Gross <jgross@suse.com>
> ---
>
> b/arch/x86/include/asm/cpuid.h | 59 ++++++++++++++++++++++++++++++++++++++
> b/arch/x86/kernel/cpu/common.c | 13 +++-----
> b/arch/x86/kernel/cpu/transmeta.c | 9 +----
> b/arch/x86/xen/enlighten_pv.c | 9 +----
> 4 files changed, 69 insertions(+), 21 deletions(-)
>
> diff -puN arch/x86/include/asm/cpuid.h~cpuid-regions arch/x86/include/asm/cpuid.h
> --- a/arch/x86/include/asm/cpuid.h~cpuid-regions 2024-03-18 15:12:20.676308753 -0700
> +++ b/arch/x86/include/asm/cpuid.h 2024-03-22 09:17:13.296507986 -0700
> @@ -168,4 +168,63 @@ static inline uint32_t hypervisor_cpuid_
> return 0;
> }
>
> +/*
> + * By convention, CPUID is broken up into regions which each
> + * have 2^16 leaves. EAX in the first leaf of each valid
> + * region returns the maximum valid leaf in that region.
> + *
> + * The regions can be thought of as being vendor-specific
> + * areas of CPUID, but that's imprecise because everybody
> + * implements the "Intel" region and Intel implements the
> + * AMD region. There are a few well-known regions:
> + * - Intel (0x0000)
> + * - AMD (0x8000)
> + * - Transmeta (0x8086)
> + * - Centaur (0xC000)
> + *
> + * Consider a CPU that where the maximum leaf in the Transmeta
> + * region is 2. On such a CPU, leaf 0x80860000 would contain:
> + * EAX==0x80860002.
> + * region-^^^^
> + * max leaf-^^^^
Minor nit:
s/a CPU that where the
/a CPU where the
> + * possible for the last basic leaf to _resemble_ a
> + * valid first leaf from a region that doesn't exist.
> + * But Intel at least seems to pad out the basic region
> + * with 0's, possibly to avoid this.
> + */
> + if ((eax >> 16) != region)
> + return 0;
> +
> + return eax;
There's whitespace damage at the 'if' line.
Thanks,
Ingo
next prev parent reply other threads:[~2024-03-24 4:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 1/4] x86/cpu: Add and use new CPUID region helper Dave Hansen
2024-03-24 4:38 ` Ingo Molnar [this message]
2024-03-25 12:24 ` Huang, Kai
2024-04-02 17:13 ` Dave Hansen
2024-04-03 10:33 ` Huang, Kai
2024-04-04 23:35 ` Chang S. Bae
2024-03-22 17:56 ` [PATCH 2/4] perf/x86/ibs: Use " Dave Hansen
2024-03-22 17:56 ` [PATCH 3/4] x86/boot: Explicitly pass NX enabling status Dave Hansen
2024-03-25 12:04 ` Huang, Kai
2024-03-22 17:56 ` [PATCH 4/4] x86/xen: Enumerate NX from CPUID directly Dave Hansen
-- strict thread matches above, loose matches on Subject: below --
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
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=Zf+uKi42qFoHLAUg@gmail.com \
--to=mingo@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.