Skip to content

Commit 72435d3

Browse files
prnangiaopsiff
authored andcommitted
x86/CPU/AMD: Prevent improper isolation of shared resources in Zen2's op cache
commit c21b90f77687075115d989e53a8ec5e2bb427ab1 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> (cherry picked from commit 9109489cc8c34e50d15575a3d1ff82af586bc1aa) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 728417d commit 72435d3

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,10 @@
745745
#define MSR_AMD64_LBR_SELECT 0xc000010e
746746

747747
/* Zen4 */
748-
#define MSR_ZEN4_BP_CFG 0xc001102e
748+
#define MSR_ZEN4_BP_CFG 0xc001102e
749749
#define MSR_ZEN4_BP_CFG_BP_SPEC_REDUCE_BIT 4
750750
#define MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT 5
751+
#define MSR_ZEN2_BP_CFG_BUG_FIX_BIT 33
751752

752753
/* Fam 19h MSRs */
753754
#define MSR_F19H_UMC_PERF_CTL 0xc0010800

arch/x86/kernel/cpu/amd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,9 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
989989
msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
990990
pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
991991
}
992+
993+
if (!cpu_has(c, X86_FEATURE_HYPERVISOR))
994+
msr_set_bit(MSR_ZEN4_BP_CFG, MSR_ZEN2_BP_CFG_BUG_FIX_BIT);
992995
}
993996

994997
static void init_amd_zen3(struct cpuinfo_x86 *c)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,9 @@
728728
#define MSR_AMD64_LBR_SELECT 0xc000010e
729729

730730
/* Zen4 */
731-
#define MSR_ZEN4_BP_CFG 0xc001102e
731+
#define MSR_ZEN4_BP_CFG 0xc001102e
732732
#define MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT 5
733+
#define MSR_ZEN2_BP_CFG_BUG_FIX_BIT 33
733734

734735
/* Fam 19h MSRs */
735736
#define MSR_F19H_UMC_PERF_CTL 0xc0010800

0 commit comments

Comments
 (0)