| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <cpu/cpu.h> |
| 5 |
#include <cpu/intel/common/common.h> |
| 6 |
#include <cpu/intel/microcode.h> |
| 7 |
#include <cpu/intel/smm_reloc.h> |
| 8 |
#include <cpu/intel/turbo.h> |
| 9 |
#include <cpu/x86/lapic.h> |
| 10 |
#include <cpu/x86/mp.h> |
| 11 |
#include <cpu/x86/msr.h> |
| 12 |
#include <device/pci.h> |
| 13 |
#include <fsp/api.h> |
| 14 |
#include <intelblocks/acpi.h> |
| 15 |
#include <intelblocks/cpulib.h> |
| 16 |
#include <intelblocks/mp_init.h> |
| 17 |
#include <intelblocks/msr.h> |
| 18 |
#include <soc/cpu.h> |
| 19 |
#include <soc/msr.h> |
| 20 |
#include <soc/pci_devs.h> |
| 21 |
#include <soc/soc_chip.h> |
| 22 |
#include <soc/soc_info.h> |
| 23 |
#include <static.h> |
| 24 |
|
| 25 |
bool cpu_soc_is_in_untrusted_mode(void) |
| 26 |
{ |
| 27 |
msr_t msr; |
| 28 |
|
| 29 |
msr = rdmsr(MSR_BIOS_DONE); |
| 30 |
return !!(msr.lo & ENABLE_IA_UNTRUSTED); |
| 31 |
} |
| 32 |
|
| 33 |
void cpu_soc_bios_done(void) |
| 34 |
{ |
| 35 |
msr_t msr; |
| 36 |
|
| 37 |
msr = rdmsr(MSR_BIOS_DONE); |
| 38 |
msr.lo |= ENABLE_IA_UNTRUSTED; |
| 39 |
wrmsr(MSR_BIOS_DONE, msr); |
| 40 |
} |
| 41 |
|
| 42 |
uint8_t get_supported_lpm_mask(void) |
| 43 |
{ |
| 44 |
const config_t *conf = config_of_soc(); |
| 45 |
if (!conf->s0ix_enable) |
| 46 |
return 0; |
| 47 |
|
| 48 |
return LPM_S0i2_0 | LPM_S0i2_1 | LPM_S0i2_2; |
| 49 |
} |
| 50 |
|
| 51 |
static void soc_fsp_load(void) |
| 52 |
{ |
| 53 |
fsps_load(); |
| 54 |
} |
| 55 |
|
| 56 |
static void configure_misc(void) |
| 57 |
{ |
| 58 |
msr_t msr; |
| 59 |
|
| 60 |
config_t *conf = (config_t *)config_of_soc(); |
| 61 |
|
| 62 |
msr = rdmsr(IA32_MISC_ENABLE); |
| 63 |
msr.lo |= (1 << 0); |
| 64 |
msr.lo |= (1 << 3); |
| 65 |
wrmsr(IA32_MISC_ENABLE, msr); |
| 66 |
|
| 67 |
|
| 68 |
cpu_set_eist(conf->eist_enable); |
| 69 |
|
| 70 |
|
| 71 |
msr.lo = 0; |
| 72 |
msr.hi = 0; |
| 73 |
wrmsr(IA32_THERM_INTERRUPT, msr); |
| 74 |
|
| 75 |
|
| 76 |
msr.lo = 1 << 4; |
| 77 |
msr.hi = 0; |
| 78 |
wrmsr(IA32_PACKAGE_THERM_INTERRUPT, msr); |
| 79 |
|
| 80 |
|
| 81 |
msr = rdmsr(MSR_POWER_CTL); |
| 82 |
msr.lo |= (1 << 0); |
| 83 |
msr.lo |= (1 << 23); |
| 84 |
msr.lo |= (1 << 18); |
| 85 |
wrmsr(MSR_POWER_CTL, msr); |
| 86 |
} |
| 87 |
|
| 88 |
enum core_type get_soc_cpu_type(void) |
| 89 |
{ |
| 90 |
if (cpu_is_hybrid_supported()) |
| 91 |
return cpu_get_cpu_type(); |
| 92 |
else |
| 93 |
return CPUID_CORE_TYPE_INTEL_CORE; |
| 94 |
} |
| 95 |
|
| 96 |
bool soc_is_nominal_freq_supported(void) |
| 97 |
{ |
| 98 |
return true; |
| 99 |
} |
| 100 |
|
| 101 |
static void enable_x2apic(void) |
| 102 |
{ |
| 103 |
if (!CONFIG(X2APIC_LATE_WORKAROUND)) |
| 104 |
return; |
| 105 |
|
| 106 |
enable_lapic_mode(true); |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
void soc_core_init(struct device *cpu) |
| 111 |
{ |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
mca_configure(); |
| 117 |
|
| 118 |
enable_x2apic(); |
| 119 |
|
| 120 |
enable_lapic_tpr(); |
| 121 |
|
| 122 |
|
| 123 |
configure_misc(); |
| 124 |
|
| 125 |
enable_pm_timer_emulation(); |
| 126 |
|
| 127 |
|
| 128 |
configure_dca_cap(); |
| 129 |
|
| 130 |
|
| 131 |
set_energy_perf_bias(ENERGY_POLICY_NORMAL); |
| 132 |
|
| 133 |
const config_t *conf = config_of_soc(); |
| 134 |
|
| 135 |
if (conf->enable_energy_perf_pref) |
| 136 |
if (check_energy_perf_cap()) |
| 137 |
set_energy_perf_pref(conf->energy_perf_pref_value); |
| 138 |
|
| 139 |
|
| 140 |
enable_turbo(); |
| 141 |
|
| 142 |
|
| 143 |
set_dev_core_type(); |
| 144 |
|
| 145 |
if (CONFIG(INTEL_TME) && is_tme_supported()) |
| 146 |
set_tme_core_activate(); |
| 147 |
|
| 148 |
if (CONFIG(DROP_CPU_FEATURE_PROGRAM_IN_FSP)) { |
| 149 |
|
| 150 |
if (CONFIG(SOC_INTEL_METEORLAKE_PRE_PRODUCTION_SILICON)) |
| 151 |
disable_three_strike_error(); |
| 152 |
else |
| 153 |
disable_signaling_three_strike_event(); |
| 154 |
|
| 155 |
set_aesni_lock(); |
| 156 |
|
| 157 |
|
| 158 |
set_feature_ctrl_vmx_arg(CONFIG(ENABLE_VMX) && !conf->disable_vmx); |
| 159 |
|
| 160 |
|
| 161 |
set_feature_ctrl_lock(); |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
static void per_cpu_smm_trigger(void) |
| 166 |
{ |
| 167 |
|
| 168 |
smm_relocate(); |
| 169 |
} |
| 170 |
|
| 171 |
static void pre_mp_init(void) |
| 172 |
{ |
| 173 |
soc_fsp_load(); |
| 174 |
|
| 175 |
const config_t *conf = config_of_soc(); |
| 176 |
if (conf->enable_energy_perf_pref) { |
| 177 |
if (check_energy_perf_cap()) |
| 178 |
enable_energy_perf_pref(); |
| 179 |
else |
| 180 |
printk(BIOS_WARNING, "Energy Performance Preference not supported!\n"); |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
static void post_mp_init(void) |
| 185 |
{ |
| 186 |
|
| 187 |
cpu_set_max_ratio(); |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
global_smi_enable_no_pwrbtn(); |
| 196 |
} |
| 197 |
|
| 198 |
static const struct mp_ops mp_ops = { |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
.pre_mp_init = pre_mp_init, |
| 205 |
.get_cpu_count = get_cpu_count, |
| 206 |
.get_smm_info = smm_info, |
| 207 |
.get_microcode_info = get_microcode_info, |
| 208 |
.pre_mp_smm_init = smm_initialize, |
| 209 |
.per_cpu_smm_trigger = per_cpu_smm_trigger, |
| 210 |
.relocation_handler = smm_relocation_handler, |
| 211 |
.post_mp_init = post_mp_init, |
| 212 |
}; |
| 213 |
|
| 214 |
void mp_init_cpus(struct bus *cpu_bus) |
| 215 |
{ |
| 216 |
if (mp_init_with_smm(cpu_bus, &mp_ops)) |
| 217 |
printk(BIOS_ERR, "MP initialization failure.\n"); |
| 218 |
|
| 219 |
|
| 220 |
configure_tcc_thermal_target(); |
| 221 |
} |
| 222 |
|
| 223 |
int soc_skip_ucode_update(u32 current_patch_id, u32 new_patch_id) |
| 224 |
{ |
| 225 |
if (!CONFIG(CHROMEOS)) |
| 226 |
return 0; |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
if (CONFIG(LOCK_MANAGEMENT_ENGINE) && current_patch_id) |
| 239 |
return 1; |
| 240 |
|
| 241 |
return 0; |
| 242 |
} |