Skip to content

Commit ff6fc65

Browse files
prnangiagregkh
authored andcommitted
x86/CPU/AMD: Prevent improper isolation of shared resources in Zen2's op cache
commit c21b90f upstream. Make sure resources are not improperly shared in the op cache and cause instruction corruption this way. Signed-off-by: Prathyushi Nangia <prathyushi.nangia@amd.com> Co-developed-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8f907d3 commit ff6fc65

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

arch/x86/include/asm/msr-index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@
675675
/* Zen4 */
676676
#define MSR_ZEN4_BP_CFG 0xc001102e
677677
#define MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT 5
678+
#define MSR_ZEN2_BP_CFG_BUG_FIX_BIT 33
678679

679680
/* Zen 2 */
680681
#define MSR_ZEN2_SPECTRAL_CHICKEN 0xc00110e3

arch/x86/kernel/cpu/amd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,9 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
11661166
msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
11671167
pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
11681168
}
1169+
1170+
if (!cpu_has(c, X86_FEATURE_HYPERVISOR))
1171+
msr_set_bit(MSR_ZEN4_BP_CFG, MSR_ZEN2_BP_CFG_BUG_FIX_BIT);
11691172
}
11701173

11711174
static void init_amd_zen3(struct cpuinfo_x86 *c)

tools/arch/x86/include/asm/msr-index.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@
638638
/* AMD Last Branch Record MSRs */
639639
#define MSR_AMD64_LBR_SELECT 0xc000010e
640640

641+
#define MSR_ZEN4_BP_CFG 0xc001102e
642+
#define MSR_ZEN2_BP_CFG_BUG_FIX_BIT 33
643+
641644
/* Fam 17h MSRs */
642645
#define MSR_F17H_IRPERF 0xc00000e9
643646

0 commit comments

Comments
 (0)