From 9e8239eeebb7ed54466e9a8f17cedcd6d0823350 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Wed, 4 Apr 2018 17:39:36 -0700 Subject: flash: Allow currently active regions to be modified This patch allows chips which run code in RAM to erase or write regions even if they're active. BUG=b:77306460 BRANCH=none TEST=flashrom -p ec -w /tmp/ec.bin on Fizz Change-Id: Ib536b250dde78283513acb942507c67da0a6f622 Signed-off-by: Daisuke Nojiri Reviewed-on: https://chromium-review.googlesource.com/997022 Reviewed-by: Randall Spangler Reviewed-by: Vincent Palatin (cherry picked from commit 75e0015cc16d287724ef353c5d7f50c1287db2cb) Reviewed-on: https://chromium-review.googlesource.com/998974 --- common/flash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/flash.c b/common/flash.c index d463aee244..6746f178ef 100644 --- a/common/flash.c +++ b/common/flash.c @@ -1165,8 +1165,10 @@ static int flash_command_write(struct host_cmd_handler_args *args) if (p->size + sizeof(*p) > args->params_size) return EC_RES_INVALID_PARAM; +#ifdef CONFIG_INTERNAL_STORAGE if (system_unsafe_to_overwrite(offset, p->size)) return EC_RES_ACCESS_DENIED; +#endif if (flash_write(offset, p->size, (const uint8_t *)(p + 1))) return EC_RES_ERROR; @@ -1204,8 +1206,10 @@ static int flash_command_erase(struct host_cmd_handler_args *args) if (flash_get_protect() & EC_FLASH_PROTECT_ALL_NOW) return EC_RES_ACCESS_DENIED; +#ifdef CONFIG_INTERNAL_STORAGE if (system_unsafe_to_overwrite(offset, p->size)) return EC_RES_ACCESS_DENIED; +#endif switch (cmd) { case FLASH_ERASE_SECTOR: -- cgit v1.2.1