diff options
Diffstat (limited to 'arch/x86/kernel/cpu/amd.c')
| -rw-r--r-- | arch/x86/kernel/cpu/amd.c | 28 | 
1 files changed, 9 insertions, 19 deletions
| diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index dd8379d84445..03ef962a6992 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -766,6 +766,15 @@ static void early_init_amd(struct cpuinfo_x86 *c)  	if (cpu_has(c, X86_FEATURE_TOPOEXT))  		smp_num_siblings = ((cpuid_ebx(0x8000001e) >> 8) & 0xff) + 1; + +	if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_IBPB_BRTYPE)) { +		if (c->x86 == 0x17 && boot_cpu_has(X86_FEATURE_AMD_IBPB)) +			setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE); +		else if (c->x86 >= 0x19 && !wrmsrl_safe(MSR_IA32_PRED_CMD, PRED_CMD_SBPB)) { +			setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE); +			setup_force_cpu_cap(X86_FEATURE_SBPB); +		} +	}  }  static void init_amd_k8(struct cpuinfo_x86 *c) @@ -1301,25 +1310,6 @@ void amd_check_microcode(void)  	on_each_cpu(zenbleed_check_cpu, NULL, 1);  } -bool cpu_has_ibpb_brtype_microcode(void) -{ -	switch (boot_cpu_data.x86) { -	/* Zen1/2 IBPB flushes branch type predictions too. */ -	case 0x17: -		return boot_cpu_has(X86_FEATURE_AMD_IBPB); -	case 0x19: -		/* Poke the MSR bit on Zen3/4 to check its presence. */ -		if (!wrmsrl_safe(MSR_IA32_PRED_CMD, PRED_CMD_SBPB)) { -			setup_force_cpu_cap(X86_FEATURE_SBPB); -			return true; -		} else { -			return false; -		} -	default: -		return false; -	} -} -  /*   * Issue a DIV 0/1 insn to clear any division data from previous DIV   * operations. | 
