From 17298c09de7cee2e191fae6e3353a6032999cf8f Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Thu, 20 May 2021 22:08:57 -0700 Subject: [PATCH] fw_config: Return false in `fw_config_probe` in unprovisioned case fw_config is unprovisioned in the factory for the first boot. This is the only case where fw_config is left unprovisioned. On first boot in factory, fw_config gets correctly provisioned by the factory toolkit. When fw_config is unprovisioned, it is not always possible to make a guess which device to enable/disable since there can be certain conflicting devices which can never be enabled at the same time. That is the reason the original implementation of fw_config library kept fw_config as 0 when it was unprovisioned. CB:47956 ("fw_config: Use UNDEFINED_FW_CONFIG to mean unprovisioned") added support for a special unprovisioned value to allow any callers to identify this factory boot condition and take any appropriate action required for this boot (Ideally, this would just involve configuring any boot devices essential to getting to OS. All other non-essential devices can be kept disabled until fw_config is properly provisioned). However, CB:47956 missed handling the `fw_config_probe()` function and resulted in silent change in behavior. This change fixes the regression introduced by CB:47956 and returns `false` in `fw_config_probe()` if fw_config is not provisioned yet. Change-Id: Ic22cd650d3eb3a6016fa2e2775ea8272405ee23b Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/c/coreboot/+/54750 Reviewed-by: Tim Wawrzynczak Reviewed-by: Karthik Ramasubramanian Reviewed-by: EricR Lai Tested-by: build bot (Jenkins) --- src/lib/fw_config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/fw_config.c b/src/lib/fw_config.c index 2c4c6b290c..7412f383e1 100644 --- a/src/lib/fw_config.c +++ b/src/lib/fw_config.c @@ -50,6 +50,10 @@ uint64_t fw_config_get(void) bool fw_config_probe(const struct fw_config *match) { + /* If fw_config is not provisioned, then there is nothing to match. */ + if (!fw_config_is_provisioned()) + return false; + /* Compare to system value. */ if ((fw_config_get() & match->mask) == match->value) { if (match->field_name && match->option_name)