From df7e1f9a4345ed4a3db30a8efedea628f3f9fa18 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Mon, 11 Nov 2019 14:27:54 -0800 Subject: [PATCH] soc/intel/fsp_broadwell_de: Check if memory is 'locked' Under certain conditions TXT can "lock" memory controller for security purpose. This manifests itself in IMC's SMbus controller failing all SPD data read requests. FSP does not detect error condition and fails boot with "No memory found" issue. TEST=tested on OCP monolake in 'locked' state Change-Id: If4637e4293421794a89037ff107e87794c40114a Signed-off-by: Andrey Petrov Reviewed-on: https://review.coreboot.org/c/coreboot/+/42710 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Rudolph Reviewed-by: Christian Walter --- src/soc/intel/fsp_broadwell_de/include/soc/memory.h | 4 ++++ src/soc/intel/fsp_broadwell_de/include/soc/msr.h | 5 +++++ src/soc/intel/fsp_broadwell_de/romstage/memory.c | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/src/soc/intel/fsp_broadwell_de/include/soc/memory.h b/src/soc/intel/fsp_broadwell_de/include/soc/memory.h index 3bdba2ef56..494ca34da1 100644 --- a/src/soc/intel/fsp_broadwell_de/include/soc/memory.h +++ b/src/soc/intel/fsp_broadwell_de/include/soc/memory.h @@ -27,4 +27,8 @@ void save_dimm_info(void); +/* Determine if memory configuration has been locked by TXT */ +bool memory_config_is_locked(void); + + #endif diff --git a/src/soc/intel/fsp_broadwell_de/include/soc/msr.h b/src/soc/intel/fsp_broadwell_de/include/soc/msr.h index f9fdffb2bf..2bbcf23687 100644 --- a/src/soc/intel/fsp_broadwell_de/include/soc/msr.h +++ b/src/soc/intel/fsp_broadwell_de/include/soc/msr.h @@ -39,4 +39,9 @@ #define MSR_PRMRR_PHYS_BASE 0x1f4 #define MSR_PRMRR_PHYS_MASK 0x1f5 +/* EDS vol 2 */ +#define MSR_LT_MEMORY_LOCKED 0x2e7 +#define MSR_MEM_LOCK_BIT1 (1 << 1) +#define MSR_MEM_LOCK_BIT2 (1 << 2) + #endif /* _SOC_MSR_H_ */ diff --git a/src/soc/intel/fsp_broadwell_de/romstage/memory.c b/src/soc/intel/fsp_broadwell_de/romstage/memory.c index b4bc097e84..571ab091ab 100644 --- a/src/soc/intel/fsp_broadwell_de/romstage/memory.c +++ b/src/soc/intel/fsp_broadwell_de/romstage/memory.c @@ -13,6 +13,8 @@ * GNU General Public License for more details. */ +#include +#include #include #include #include @@ -85,3 +87,9 @@ void save_dimm_info(void) } } } + +bool memory_config_is_locked(void) +{ + msr_t msr = rdmsr(MSR_LT_MEMORY_LOCKED); + return (msr.lo & (MSR_MEM_LOCK_BIT1 | MSR_MEM_LOCK_BIT2)); +}