summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cpu/intel/microcode/microcode.c28
-rw-r--r--src/include/cpu/intel/microcode.h6
2 files changed, 26 insertions, 8 deletions
diff --git a/src/cpu/intel/microcode/microcode.c b/src/cpu/intel/microcode/microcode.c
index 2c8a2121f2..51823ca6de 100644
--- a/src/cpu/intel/microcode/microcode.c
+++ b/src/cpu/intel/microcode/microcode.c
@@ -117,18 +117,15 @@ uint32_t get_microcode_checksum(const void *microcode)
return ((struct microcode *)microcode)->cksum;
}
-const void *intel_microcode_find(void)
+static const void *find_cbfs_microcode(void)
{
- static const struct microcode *ucode_updates;
+ const struct microcode *ucode_updates;
size_t microcode_len;
u32 eax;
u32 pf, rev, sig, update_size;
msr_t msr;
struct cpuinfo_x86 c;
- if (ucode_updates)
- return ucode_updates;
-
ucode_updates = cbfs_map(MICROCODE_CBFS_FILE, &microcode_len);
if (ucode_updates == NULL)
return NULL;
@@ -170,11 +167,28 @@ const void *intel_microcode_find(void)
microcode_len -= update_size;
}
- ucode_updates = NULL;
-
return NULL;
}
+const void *intel_microcode_find(void)
+{
+ static bool microcode_checked;
+ static const void *ucode_update;
+
+ if (microcode_checked)
+ return ucode_update;
+
+ /*
+ * Since this function caches the found microcode (NULL or a valid
+ * microcode pointer), it is expected to be run from BSP before starting
+ * any other APs. This sequence is not multithread safe otherwise.
+ */
+ ucode_update = find_cbfs_microcode();
+ microcode_checked = true;
+
+ return ucode_update;
+}
+
void intel_update_microcode_from_cbfs(void)
{
const void *patch = intel_microcode_find();
diff --git a/src/include/cpu/intel/microcode.h b/src/include/cpu/intel/microcode.h
index a0ab7fd13b..d977e5836f 100644
--- a/src/include/cpu/intel/microcode.h
+++ b/src/include/cpu/intel/microcode.h
@@ -7,7 +7,11 @@
void intel_update_microcode_from_cbfs(void);
/* Find a microcode that matches the revision and platform family returning
* NULL if none found. The found microcode is cached for faster access on
- * subsequent calls of this function. */
+ * subsequent calls of this function.
+ *
+ * Since this function caches the found microcode (NULL or a valid microcode
+ * pointer), it is expected to be run from BSP before starting any other APs.
+ * It is not multithread safe otherwise. */
const void *intel_microcode_find(void);
/* It is up to the caller to determine if parallel loading is possible as