[PATCH v7 059/120] x86/cpuid: Parse CPUID(0x5)
"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:38:21 +0200
| Newsgroups | dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Parse CPUID(0x5), CPUID_LEAF_MWAIT, so that its call sites can be converted to the CPUID API next. Introduce cpuid_mwait_n_substates() since its logic is required by multiple call sits. Signed-off-by: Ahmed S. Darwish <[email protected]> --- arch/x86/include/asm/cpuid/api.h | 19 +++++++++++++++++++ arch/x86/include/asm/cpuid/types.h | 1 + arch/x86/kernel/cpu/cpuid_parser.h | 1 + 3 files changed, 21 insertions(+) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/api.h index 611ee8596115..540f886a61cd 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -493,6 +493,25 @@ static inline u32 cpuid_base_hypervisor(const char *sig, u32 leaves) _ptr < &((const union leaf_0x2_regs *)(_regs))->desc[16] && (_desc = &cpuid_0x2_table[*_ptr]);\ _ptr++) +/* + * CPUID(0x5) + */ + +static inline unsigned int cpuid_mwait_n_substates(const struct leaf_0x5_0 *l5, unsigned int cstate) +{ + switch (cstate) { + case 0: return l5->n_c0_substates; + case 1: return l5->n_c1_substates; + case 2: return l5->n_c2_substates; + case 3: return l5->n_c3_substates; + case 4: return l5->n_c4_substates; + case 5: return l5->n_c5_substates; + case 6: return l5->n_c6_substates; + case 7: return l5->n_c7_substates; + default: return 0; + } +} + /* * CPUID(0x80000006) */ diff --git a/arch/x86/include/asm/cpuid/types.h b/arch/x86/include/asm/cpuid/types.h index f50e54bfb514..50156e9883a3 100644 --- a/arch/x86/include/asm/cpuid/types.h +++ b/arch/x86/include/asm/cpuid/types.h @@ -212,6 +212,7 @@ struct cpuid_leaves { CPUID_LEAF ( 0x1, 0 ); CPUID_LEAF ( 0x2, 0 ); CPUID_LEAF_N ( 0x4, 8 ); + CPUID_LEAF ( 0x5, 0 ); CPUID_LEAF ( 0x16, 0 ); CPUID_LEAF ( 0x80000000, 0 ); CPUID_LEAF ( 0x80000002, 0 ); diff --git a/arch/x86/kernel/cpu/cpuid_parser.h b/arch/x86/kernel/cpu/cpuid_parser.h index ab391de03a92..3a60dad4e861 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.h +++ b/arch/x86/kernel/cpu/cpuid_parser.h @@ -146,6 +146,7 @@ struct cpuid_parse_entry { /* Leaf Subleaf Reader function */ \ CPUID_PARSE_ENTRY ( 0x2, 0, 0x2 ), \ CPUID_PARSE_ENTRY_N ( 0x4, deterministic_cache ), \ + CPUID_PARSE_ENTRY ( 0x5, 0, generic ), \ CPUID_PARSE_ENTRY ( 0x16, 0, generic ), \ CPUID_PARSE_ENTRY ( 0x80000000, 0, 0x80000000 ), \ CPUID_PARSE_ENTRY ( 0x80000002, 0, generic ), \ -- 2.54.0