Skip to content

Commit 232afb5

Browse files
committed
x86/CPU/AMD: Add X86_FEATURE_ZEN1
Add a synthetic feature flag specifically for first generation Zen machines. There's need to have a generic flag for all Zen generations so make X86_FEATURE_ZEN be that flag. Fixes: 30fa928 ("x86/CPU/AMD: Add ZenX generations flags") Suggested-by: Brian Gerst <[email protected]> Suggested-by: Tom Lendacky <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 05f5f73 commit 232afb5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
#define X86_FEATURE_IBRS ( 7*32+25) /* Indirect Branch Restricted Speculation */
219219
#define X86_FEATURE_IBPB ( 7*32+26) /* Indirect Branch Prediction Barrier */
220220
#define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
221-
#define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU based on Zen microarchitecture */
221+
#define X86_FEATURE_ZEN ( 7*32+28) /* "" Generic flag for all Zen and newer */
222222
#define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
223223
#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
224224
#define X86_FEATURE_MSR_IA32_FEAT_CTL ( 7*32+31) /* "" MSR IA32_FEAT_CTL configured */
@@ -315,6 +315,7 @@
315315
#define X86_FEATURE_ZEN2 (11*32+28) /* "" CPU based on Zen2 microarchitecture */
316316
#define X86_FEATURE_ZEN3 (11*32+29) /* "" CPU based on Zen3 microarchitecture */
317317
#define X86_FEATURE_ZEN4 (11*32+30) /* "" CPU based on Zen4 microarchitecture */
318+
#define X86_FEATURE_ZEN1 (11*32+31) /* "" CPU based on Zen1 microarchitecture */
318319

319320
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
320321
#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */

arch/x86/kernel/cpu/amd.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
542542
switch (c->x86_model) {
543543
case 0x00 ... 0x2f:
544544
case 0x50 ... 0x5f:
545-
setup_force_cpu_cap(X86_FEATURE_ZEN);
545+
setup_force_cpu_cap(X86_FEATURE_ZEN1);
546546
break;
547547
case 0x30 ... 0x4f:
548548
case 0x60 ... 0x7f:
@@ -948,12 +948,13 @@ void init_spectral_chicken(struct cpuinfo_x86 *c)
948948

949949
static void init_amd_zen_common(void)
950950
{
951+
setup_force_cpu_cap(X86_FEATURE_ZEN);
951952
#ifdef CONFIG_NUMA
952953
node_reclaim_distance = 32;
953954
#endif
954955
}
955956

956-
static void init_amd_zen(struct cpuinfo_x86 *c)
957+
static void init_amd_zen1(struct cpuinfo_x86 *c)
957958
{
958959
init_amd_zen_common();
959960
fix_erratum_1386(c);
@@ -1075,8 +1076,8 @@ static void init_amd(struct cpuinfo_x86 *c)
10751076
case 0x16: init_amd_jg(c); break;
10761077
}
10771078

1078-
if (boot_cpu_has(X86_FEATURE_ZEN))
1079-
init_amd_zen(c);
1079+
if (boot_cpu_has(X86_FEATURE_ZEN1))
1080+
init_amd_zen1(c);
10801081
else if (boot_cpu_has(X86_FEATURE_ZEN2))
10811082
init_amd_zen2(c);
10821083
else if (boot_cpu_has(X86_FEATURE_ZEN3))
@@ -1143,7 +1144,7 @@ static void init_amd(struct cpuinfo_x86 *c)
11431144
* Counter May Be Inaccurate".
11441145
*/
11451146
if (cpu_has(c, X86_FEATURE_IRPERF) &&
1146-
(boot_cpu_has(X86_FEATURE_ZEN) && c->x86_model > 0x2f))
1147+
(boot_cpu_has(X86_FEATURE_ZEN1) && c->x86_model > 0x2f))
11471148
msr_set_bit(MSR_K7_HWCR, MSR_K7_HWCR_IRPERF_EN_BIT);
11481149

11491150
check_null_seg_clears_base(c);

tools/arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
#define X86_FEATURE_IBRS ( 7*32+25) /* Indirect Branch Restricted Speculation */
220220
#define X86_FEATURE_IBPB ( 7*32+26) /* Indirect Branch Prediction Barrier */
221221
#define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
222-
#define X86_FEATURE_ZEN (7*32+28) /* "" CPU based on Zen microarchitecture */
222+
#define X86_FEATURE_ZEN ( 7*32+28) /* "" Generic flag for all Zen and newer */
223223
#define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
224224
#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
225225
#define X86_FEATURE_MSR_IA32_FEAT_CTL ( 7*32+31) /* "" MSR IA32_FEAT_CTL configured */

0 commit comments

Comments
 (0)