From 69a95653399657bf6b2491c259479c954fee2509 Mon Sep 17 00:00:00 2001 From: Ronak Kanabar Date: Tue, 19 Feb 2019 20:10:23 +0530 Subject: soc/intel/cannonlake: SoC specific microcode update check For CFL and WHL, Microcode is being loaded from FIT. Both supports the PRMRR/SGX feature. If This is supported the FIT microcode load will set the msr (0x08b) with the Patch id one less than the id in the microcode binary. This results in Microcode getting reloaded again in bootblock and ramstage. Avoid the microcode reload by checking for PRMRR support. CFL and WHL CPU die are based on KBL CPU so we need to have this check, where CNL CPU die is not based on KBL CPU so skip this check for CNL. BUG=b:124126405 Signed-off-by: Ronak Kanabar Change-Id: I3311a7413d27044f9c819179e5b0cb9a67b46955 Reviewed-on: https://review.coreboot.org/c/31492 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh Reviewed-by: Rizwan Qureshi --- src/soc/intel/cannonlake/cpu.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/soc') diff --git a/src/soc/intel/cannonlake/cpu.c b/src/soc/intel/cannonlake/cpu.c index f987f8b42f..19ff171eb8 100644 --- a/src/soc/intel/cannonlake/cpu.c +++ b/src/soc/intel/cannonlake/cpu.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include /* Convert time in seconds to POWER_LIMIT_1_TIME MSR value */ static const u8 power_limit_time_sec_to_msr[] = { @@ -484,3 +486,34 @@ void soc_init_cpus(struct bus *cpu_bus) /* Thermal throttle activation offset */ configure_thermal_target(); } + +int soc_skip_ucode_update(u32 current_patch_id, u32 new_patch_id) +{ + msr_t msr1; + msr_t msr2; + + /* + * CFL and WHL CPU die are based on KBL CPU so we need to + * have this check, where CNL CPU die is not based on KBL CPU + * so skip this check for CNL. + */ + if (!IS_ENABLED(CONFIG_SOC_INTEL_COMMON_CANNONLAKE_BASE)) + return 0; + + /* + * If PRMRR/SGX is supported the FIT microcode load will set the msr + * 0x08b with the Patch revision id one less than the id in the + * microcode binary. The PRMRR support is indicated in the MSR + * MTRRCAP[12]. If SGX is not enabled, check and avoid reloading the + * same microcode during CPU initialization. If SGX is enabled, as + * part of SGX BIOS initialization steps, the same microcode needs to + * be reloaded after the core PRMRR MSRs are programmed. + */ + msr1 = rdmsr(MTRR_CAP_MSR); + msr2 = rdmsr(MSR_PRMRR_PHYS_BASE); + if (msr2.lo && (current_patch_id == new_patch_id - 1)) + return 0; + + return (msr1.lo & PRMRR_SUPPORTED) && + (current_patch_id == new_patch_id - 1); +} -- cgit v1.2.3