Attention is currently required from: Patrick Rudolph. Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/49896 )
Change subject: cpu/intel/microcode: Add caching layer around intel_microcode_find ......................................................................
cpu/intel/microcode: Add caching layer around intel_microcode_find
Change-Id: Ic40d57964600f8f20ddb26c7d1691b043fd89f29 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/cpu/intel/microcode/microcode.c M src/include/cpu/intel/microcode.h 2 files changed, 25 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/96/49896/1
diff --git a/src/cpu/intel/microcode/microcode.c b/src/cpu/intel/microcode/microcode.c index 0f362d4..843fc91 100644 --- a/src/cpu/intel/microcode/microcode.c +++ b/src/cpu/intel/microcode/microcode.c @@ -176,9 +176,26 @@ return NULL; }
+const void *intel_microcode_find_cached(void) +{ +#if ENV_STAGE_HAS_DATA_SECTION + static bool checked; + static void *cached; + + if (checked) + return cached; + + cached = intel_microcode_find(); + checked = 1; + return cached; +#else + return intel_microcode_find(); +#endif +} + void intel_update_microcode_from_cbfs(void) { - const void *patch = intel_microcode_find(); + const void *patch = intel_microcode_find_cached();
spin_lock(µcode_lock);
diff --git a/src/include/cpu/intel/microcode.h b/src/include/cpu/intel/microcode.h index f1a8601..4b5223c 100644 --- a/src/include/cpu/intel/microcode.h +++ b/src/include/cpu/intel/microcode.h @@ -8,6 +8,13 @@ /* Find a microcode that matches the revision and platform family returning * NULL if none found. */ const void *intel_microcode_find(void); + +/* + * Returns the microcode patch found in CBFS (if any), using caching if possible. + * In early stages this is as slow as intel_microcode_find(). + */ +const void *intel_microcode_find_cached(void); + /* It is up to the caller to determine if parallel loading is possible as * well as ensuring the microcode matches the family and revision (i.e. with * intel_microcode_find()). */