Skip to content

Commit 95ca0ee

Browse files
dwmw2KAGA-KOKO
authored andcommitted
x86/cpufeatures: Add CPUID_7_EDX CPUID leaf
This is a pure feature bits leaf. There are two AVX512 feature bits in it already which were handled as scattered bits, and three more from this leaf are going to be added for speculation control features. Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent caf7501 commit 95ca0ee

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

arch/x86/include/asm/cpufeature.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum cpuid_leafs
2929
CPUID_8000_000A_EDX,
3030
CPUID_7_ECX,
3131
CPUID_8000_0007_EBX,
32+
CPUID_7_EDX,
3233
};
3334

3435
#ifdef CONFIG_X86_FEATURE_NAMES
@@ -79,8 +80,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
7980
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 15, feature_bit) || \
8081
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \
8182
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \
83+
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \
8284
REQUIRED_MASK_CHECK || \
83-
BUILD_BUG_ON_ZERO(NCAPINTS != 18))
85+
BUILD_BUG_ON_ZERO(NCAPINTS != 19))
8486

8587
#define DISABLED_MASK_BIT_SET(feature_bit) \
8688
( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -101,8 +103,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
101103
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 15, feature_bit) || \
102104
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \
103105
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \
106+
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \
104107
DISABLED_MASK_CHECK || \
105-
BUILD_BUG_ON_ZERO(NCAPINTS != 18))
108+
BUILD_BUG_ON_ZERO(NCAPINTS != 19))
106109

107110
#define cpu_has(c, bit) \
108111
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \

arch/x86/include/asm/cpufeatures.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/*
1414
* Defines x86 CPU feature bits
1515
*/
16-
#define NCAPINTS 18 /* N 32-bit words worth of info */
16+
#define NCAPINTS 19 /* N 32-bit words worth of info */
1717
#define NBUGINTS 1 /* N 32-bit bug flags */
1818

1919
/*
@@ -206,8 +206,6 @@
206206
#define X86_FEATURE_RETPOLINE ( 7*32+12) /* Generic Retpoline mitigation for Spectre variant 2 */
207207
#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13) /* AMD Retpoline mitigation for Spectre variant 2 */
208208
#define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */
209-
#define X86_FEATURE_AVX512_4VNNIW ( 7*32+16) /* AVX-512 Neural Network Instructions */
210-
#define X86_FEATURE_AVX512_4FMAPS ( 7*32+17) /* AVX-512 Multiply Accumulation Single precision */
211209

212210
#define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */
213211
#define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* Fill RSB on context switches */
@@ -319,6 +317,10 @@
319317
#define X86_FEATURE_SUCCOR (17*32+ 1) /* Uncorrectable error containment and recovery */
320318
#define X86_FEATURE_SMCA (17*32+ 3) /* Scalable MCA */
321319

320+
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
321+
#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
322+
#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
323+
322324
/*
323325
* BUG word(s)
324326
*/

arch/x86/include/asm/disabled-features.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#define DISABLED_MASK15 0
7272
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57)
7373
#define DISABLED_MASK17 0
74-
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
74+
#define DISABLED_MASK18 0
75+
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
7576

7677
#endif /* _ASM_X86_DISABLED_FEATURES_H */

arch/x86/include/asm/required-features.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#define REQUIRED_MASK15 0
107107
#define REQUIRED_MASK16 (NEED_LA57)
108108
#define REQUIRED_MASK17 0
109-
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
109+
#define REQUIRED_MASK18 0
110+
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
110111

111112
#endif /* _ASM_X86_REQUIRED_FEATURES_H */

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
745745
cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx);
746746
c->x86_capability[CPUID_7_0_EBX] = ebx;
747747
c->x86_capability[CPUID_7_ECX] = ecx;
748+
c->x86_capability[CPUID_7_EDX] = edx;
748749
}
749750

750751
/* Extended state features: level 0x0000000d */

arch/x86/kernel/cpu/scattered.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ struct cpuid_bit {
2121
static const struct cpuid_bit cpuid_bits[] = {
2222
{ X86_FEATURE_APERFMPERF, CPUID_ECX, 0, 0x00000006, 0 },
2323
{ X86_FEATURE_EPB, CPUID_ECX, 3, 0x00000006, 0 },
24-
{ X86_FEATURE_AVX512_4VNNIW, CPUID_EDX, 2, 0x00000007, 0 },
25-
{ X86_FEATURE_AVX512_4FMAPS, CPUID_EDX, 3, 0x00000007, 0 },
2624
{ X86_FEATURE_CAT_L3, CPUID_EBX, 1, 0x00000010, 0 },
2725
{ X86_FEATURE_CAT_L2, CPUID_EBX, 2, 0x00000010, 0 },
2826
{ X86_FEATURE_CDP_L3, CPUID_ECX, 2, 0x00000010, 1 },

0 commit comments

Comments
 (0)