Skip to content

Commit dec3b91

Browse files
kimphillamdgregkh
authored andcommitted
x86/cpu, kvm: Add support for CPUID_80000021_EAX
commit 8415a74 upstream. Add support for CPUID leaf 80000021, EAX. The majority of the features will be used in the kernel and thus a separate leaf is appropriate. Include KVM's reverse_cpuid entry because features are used by VM guests, too. [ bp: Massage commit message. ] Signed-off-by: Kim Phillips <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected] [bwh: Backported to 6.1: adjust context] Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dfede4c commit dec3b91

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

arch/x86/include/asm/cpufeature.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ enum cpuid_leafs
3232
CPUID_8000_0007_EBX,
3333
CPUID_7_EDX,
3434
CPUID_8000_001F_EAX,
35+
CPUID_8000_0021_EAX,
3536
};
3637

3738
#define X86_CAP_FMT_NUM "%d:%d"
@@ -94,8 +95,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
9495
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \
9596
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \
9697
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) || \
98+
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 20, feature_bit) || \
9799
REQUIRED_MASK_CHECK || \
98-
BUILD_BUG_ON_ZERO(NCAPINTS != 20))
100+
BUILD_BUG_ON_ZERO(NCAPINTS != 21))
99101

100102
#define DISABLED_MASK_BIT_SET(feature_bit) \
101103
( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -118,8 +120,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
118120
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \
119121
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \
120122
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) || \
123+
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 20, feature_bit) || \
121124
DISABLED_MASK_CHECK || \
122-
BUILD_BUG_ON_ZERO(NCAPINTS != 20))
125+
BUILD_BUG_ON_ZERO(NCAPINTS != 21))
123126

124127
#define cpu_has(c, bit) \
125128
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/*
1414
* Defines x86 CPU feature bits
1515
*/
16-
#define NCAPINTS 20 /* N 32-bit words worth of info */
16+
#define NCAPINTS 21 /* N 32-bit words worth of info */
1717
#define NBUGINTS 2 /* N 32-bit bug flags */
1818

1919
/*

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
#define DISABLED_MASK17 0
112112
#define DISABLED_MASK18 0
113113
#define DISABLED_MASK19 0
114-
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)
114+
#define DISABLED_MASK20 0
115+
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
115116

116117
#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
@@ -98,6 +98,7 @@
9898
#define REQUIRED_MASK17 0
9999
#define REQUIRED_MASK18 0
100100
#define REQUIRED_MASK19 0
101-
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)
101+
#define REQUIRED_MASK20 0
102+
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
102103

103104
#endif /* _ASM_X86_REQUIRED_FEATURES_H */

arch/x86/kernel/cpu/common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
10761076
if (c->extended_cpuid_level >= 0x8000001f)
10771077
c->x86_capability[CPUID_8000_001F_EAX] = cpuid_eax(0x8000001f);
10781078

1079+
if (c->extended_cpuid_level >= 0x80000021)
1080+
c->x86_capability[CPUID_8000_0021_EAX] = cpuid_eax(0x80000021);
1081+
10791082
init_scattered_cpuid_features(c);
10801083
init_speculation_control(c);
10811084

arch/x86/kvm/reverse_cpuid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static const struct cpuid_reg reverse_cpuid[] = {
4848
[CPUID_7_1_EAX] = { 7, 1, CPUID_EAX},
4949
[CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX},
5050
[CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX},
51+
[CPUID_8000_0021_EAX] = {0x80000021, 0, CPUID_EAX},
5152
};
5253

5354
/*

0 commit comments

Comments
 (0)