From 3cc4745be2503a4da28ca92e63b9cf5397f5a820 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Wed, 25 Jul 2012 16:44:12 -0700 Subject: Don't protect firmware now if protect-ro-at-boot is not set Otherwise, EC software sync protects the entire firmware except in recovery mode, regardless of the WP pin. BUG=chrome-os-partner:11847 TEST=boot with WP enabled but RO-at-boot disabled; flashinfo should show entire flash still writable CQ-DEPEND=28444 Change-Id: I58d60adfaa952b127e8695213f95f6da0e34821d Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/28445 Reviewed-by: Bill Richardson --- chip/lm4/flash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'chip/lm4') diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c index 826783b45b..8eab52ca9c 100644 --- a/chip/lm4/flash.c +++ b/chip/lm4/flash.c @@ -326,8 +326,12 @@ int flash_set_protect(uint32_t mask, uint32_t flags) retval = rv; } - /* All subsequent flags only work if write protect is disabled */ - if (!(flash_get_protect() & EC_FLASH_PROTECT_GPIO_ASSERTED)) + /* + * All subsequent flags only work if write protect is enabled (that is, + * hardware WP flag) *and* RO is protected at boot (software WP flag). + */ + if ((~flash_get_protect()) & (EC_FLASH_PROTECT_GPIO_ASSERTED | + EC_FLASH_PROTECT_RO_AT_BOOT)) return retval; if ((mask & EC_FLASH_PROTECT_RO_NOW) && -- cgit v1.2.1