coreboot-kgpe-d16/src/cpu/intel
Furquan Shaikh f14c05f144 cpu/intel/microcode: Fix caching logic in intel_microcode_find
CB:49896 added support in `intel_microcode_find()` to cache the found
microcode for faster subsequent accesses. This works okay when the
function succeeds in finding the microcode on BSP. However, if for any
reason, `cpu_microcode_blob.bin` does not contain a valid microcode
for the given processor, then the logic ends up attempting to find
microcode again and again every time it is called (because
`ucode_updates` is set to NULL on failed find, thus retriggering the
whole find sequence every time). This leads to a weird race condition
when multiple APs are running in parallel and executing this
function.

A snippet of the issues observed in the scenario described above:
```
...
microcode: Update skipped, already up-to-date
...
Microcode header corrupted!
...

```

1. AP reports that microcode update is being skipped since the current
version matches the version in CBFS (even though there is no matching
microcode update in CBFS).
2. AP reports microcode header is corrupted because it thinks that the
data size reported in the microcode is larger than the file read from
CBFS.

Above issues occur because each time an AP calls
`intel_microcode_find()`, it might end up seeing some intermittent
state of `ucode_updates` and taking incorrect action.

This change fixes this race condition by separating the logic for
finding microcode into an internal function `find_cbfs_microcode()`
and maintaining the caching logic in `intel_microcode_find()` using a
boolean flag `microcode_checked`.

BUG=b:182232187
TEST=Verified that `intel_microcode_find()` no longer makes repeated
attempts to find microcode from CBFS if it failed the first time.

Change-Id: I8600c830ba029e5cb9c0d7e0f1af18d87c61ad3a
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51371
Reviewed-by: Patrick Rudolph
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-03-12 17:33:01 +00:00
..
car arch/x86: Move prologue to .init section 2021-01-07 11:02:03 +00:00
common cpu/intel/common/fsb.c: Correct code style 2021-01-28 09:17:52 +00:00
fit build system: Always add coreboot.pre dependency to intermediates 2021-01-15 23:54:09 +00:00
haswell cpu/intel/haswell: Constify ACPI c-state arrays 2021-02-14 21:57:00 +00:00
hyperthreading
microcode cpu/intel/microcode: Fix caching logic in intel_microcode_find 2021-03-12 17:33:01 +00:00
model_6bx
model_6ex
model_6fx
model_6xx
model_65x
model_67x
model_68x
model_106cx cpu/intel/*init: Remove obsolete cache enable 2021-01-15 11:21:04 +00:00
model_206ax cpu/intel/model_206ax: Drop c-state table indirection 2021-02-14 21:54:48 +00:00
model_1067x soc/intel/*: Get rid of custom microcode caching 2021-02-01 08:46:30 +00:00
model_2065x src: Remove unused <arch/cpu.h> 2021-02-11 10:25:23 +00:00
model_f2x
model_f3x
model_f4x
slot_1 treewide [Kconfig]: Remove useless comment 2021-02-02 13:49:49 +00:00
smm cpu/intel/smm/gen1/smmrelocate.c: Remove repeated word 2021-01-18 07:31:06 +00:00
socket_441 treewide [Kconfig]: Remove useless comment 2021-02-02 13:49:49 +00:00
socket_BGA956
socket_FCBGA559
socket_LGA775 treewide [Kconfig]: Remove useless comment 2021-02-02 13:49:49 +00:00
socket_m treewide [Kconfig]: Remove useless comment 2021-02-02 13:49:49 +00:00
socket_mPGA604 treewide [Kconfig]: Remove useless comment 2021-02-02 13:49:49 +00:00
socket_p
speedstep sb/intel/i82801gx,ix: Drop MPEN from GNVS 2021-02-01 08:54:31 +00:00
turbo
Kconfig
Makefile.inc