summaryrefslogtreecommitdiff
path: root/common/flash.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2021-07-27 18:33:46 -0700
committerCommit Bot <commit-bot@chromium.org>2021-07-30 21:13:22 +0000
commit3d67df923a05a5108ef1f00586880e35acf89d82 (patch)
tree0abb3d5b7c89ac4ee4b42d20f8c1e6c603aecfa7 /common/flash.c
parentd92c21a2ae6544aac372ec9b98a97cab1db6d302 (diff)
downloadchrome-ec-3d67df923a05a5108ef1f00586880e35acf89d82.tar.gz
flash: Set CBI EEPROM WP immediately if SW WP set
With `CONFIG_EEPROM_CBI_WP`, the EC will set the the CBI EEPROM WP according to `system_is_locked`. The system lock status is also cached. In order to prevent requiring an EC reboot after setting the software write protect status, this commit will set the CBI EEPROM WP status when the SW WP is asserted along with the HW WP. This is the same criteria that `system_is_locked` would use when deciding if the system is locked. BUG=b:181769483 BRANCH=None TEST=Build and flash a reworked lalala, enable HW WP, enable SW WP via `flashrom -p ec --wp-enable` and verify that EC_CBI_WP is asserted immediately without requiring an EC reboot. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I987a5b7652134be11c82855aab9ed4eb1442b57c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3058077 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/flash.c')
-rw-r--r--common/flash.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/flash.c b/common/flash.c
index 779fbe24db..c8f58a82af 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -7,6 +7,7 @@
#include "common.h"
#include "console.h"
+#include "cros_board_info.h"
#include "flash.h"
#include "gpio.h"
#include "hooks.h"
@@ -945,6 +946,15 @@ int crec_flash_set_protect(uint32_t mask, uint32_t flags)
rv = crec_flash_physical_protect_now(0);
if (rv)
retval = rv;
+
+ /*
+ * Latch the CBI EEPROM WP immediately if HW WP is asserted and
+ * we're now protecting the RO region with SW WP.
+ */
+ if (IS_ENABLED(CONFIG_EEPROM_CBI_WP) &&
+ (EC_FLASH_PROTECT_GPIO_ASSERTED &
+ crec_flash_get_protect()))
+ cbi_latch_eeprom_wp();
}
/* 5 - Commit ALL_NOW. */