|
28 | 28 |
|
29 | 29 | static const int amd_erratum_383[];
|
30 | 30 | static const int amd_erratum_400[];
|
| 31 | +static const int amd_erratum_1054[]; |
31 | 32 | static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);
|
32 | 33 |
|
33 | 34 | /*
|
@@ -972,6 +973,15 @@ static void init_amd(struct cpuinfo_x86 *c)
|
972 | 973 | /* AMD CPUs don't reset SS attributes on SYSRET, Xen does. */
|
973 | 974 | if (!cpu_has(c, X86_FEATURE_XENPV))
|
974 | 975 | set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
|
| 976 | + |
| 977 | + /* |
| 978 | + * Turn on the Instructions Retired free counter on machines not |
| 979 | + * susceptible to erratum #1054 "Instructions Retired Performance |
| 980 | + * Counter May Be Inaccurate". |
| 981 | + */ |
| 982 | + if (cpu_has(c, X86_FEATURE_IRPERF) && |
| 983 | + !cpu_has_amd_erratum(c, amd_erratum_1054)) |
| 984 | + msr_set_bit(MSR_K7_HWCR, MSR_K7_HWCR_IRPERF_EN_BIT); |
975 | 985 | }
|
976 | 986 |
|
977 | 987 | #ifdef CONFIG_X86_32
|
@@ -1099,6 +1109,10 @@ static const int amd_erratum_400[] =
|
1099 | 1109 | static const int amd_erratum_383[] =
|
1100 | 1110 | AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));
|
1101 | 1111 |
|
| 1112 | +/* #1054: Instructions Retired Performance Counter May Be Inaccurate */ |
| 1113 | +static const int amd_erratum_1054[] = |
| 1114 | + AMD_OSVW_ERRATUM(0, AMD_MODEL_RANGE(0x17, 0, 0, 0x2f, 0xf)); |
| 1115 | + |
1102 | 1116 |
|
1103 | 1117 | static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
|
1104 | 1118 | {
|
|
0 commit comments