summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2020-05-13 18:23:52 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-14 08:38:15 +0000
commit63a8d07fbc74c8a141a8d30f56434846d8e5af08 (patch)
treec66d71335650f89d4a945308cb84f1f27c6f7095
parentb70e2768c856641e91205fdb50b20a4147b2a7e2 (diff)
downloadchrome-ec-63a8d07fbc74c8a141a8d30f56434846d8e5af08.tar.gz
system: Add EC_RESET_FLAG_EFS
This patch adds EC_RESET_FLAG_EFS. It indicates EC jumped to RW by successfully running EFS. system_jumped_late can be used to avoid running some code twice (once in RO and again in RW). Such code is currently (wrongly) guarded by system_jumped_to_this_image. BUG=b:156101251, chromium:1072743 BRANCH=none TEST=Verified the bug is fixed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I58fc18510b2f95dfd116cbacba09875cb7cf5051 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2200245
-rw-r--r--common/system.c6
-rw-r--r--common/vboot/efs2.c3
-rw-r--r--include/ec_commands.h1
-rw-r--r--include/reset_flag_desc.inc1
-rw-r--r--include/system.h12
5 files changed, 23 insertions, 0 deletions
diff --git a/common/system.c b/common/system.c
index d64c9c3643..aa427e0dc0 100644
--- a/common/system.c
+++ b/common/system.c
@@ -274,6 +274,12 @@ int system_jumped_to_this_image(void)
return jumped_to_image;
}
+int system_jumped_late(void)
+{
+ return !(reset_flags & EC_RESET_FLAG_EFS)
+ && (reset_flags & EC_RESET_FLAG_SYSJUMP);
+}
+
int system_add_jump_tag(uint16_t tag, int version, int size, const void *data)
{
struct jump_tag *t;
diff --git a/common/vboot/efs2.c b/common/vboot/efs2.c
index 29ad42995f..3e949455fd 100644
--- a/common/vboot/efs2.c
+++ b/common/vboot/efs2.c
@@ -209,8 +209,11 @@ static void verify_and_jump(void)
enable_pd();
break;
case CR50_COMM_SUCCESS:
+ system_set_reset_flags(
+ system_get_reset_flags() | EC_RESET_FLAG_EFS);
rv = system_run_image_copy(EC_IMAGE_RW);
CPRINTS("Failed to jump (0x%x)", rv);
+ system_clear_reset_flags(EC_RESET_FLAG_EFS);
show_critical_error();
break;
default:
diff --git a/include/ec_commands.h b/include/ec_commands.h
index a74360dc7a..aca6032d45 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -5796,6 +5796,7 @@ struct ec_params_set_cbi {
#define EC_RESET_FLAG_STAY_IN_RO BIT(19) /* Do not select RW in EFS. This
* enables PD in RO for Chromebox.
*/
+#define EC_RESET_FLAG_EFS BIT(20) /* Jumped to this image by EFS */
struct ec_response_uptime_info {
/*
diff --git a/include/reset_flag_desc.inc b/include/reset_flag_desc.inc
index 58b142d3d3..9b201c373e 100644
--- a/include/reset_flag_desc.inc
+++ b/include/reset_flag_desc.inc
@@ -27,3 +27,4 @@
"security",
"ap-watchdog",
"stay-in-ro",
+"efs",
diff --git a/include/system.h b/include/system.h
index 03a2c15238..360b850470 100644
--- a/include/system.h
+++ b/include/system.h
@@ -120,10 +120,22 @@ uintptr_t get_program_memory_addr(enum ec_image copy);
/**
* Return non-zero if the system has switched between image copies at least
* once since the last real boot.
+ *
+ * You probably need to call system_jumped_late instead if you're trying to
+ * avoid initializing something again in RW.
*/
int system_jumped_to_this_image(void);
/**
+ * Return non-zero if late (legacy) sysjump occurred.
+ *
+ * This happens when EFS failed but RO still jumped to RW late on AP's request.
+ * This is typically called to avoid running some code twice (once in RO and
+ * again in RW).
+ */
+int system_jumped_late(void);
+
+/**
* Preserve data across a jump between images.
*
* This may ONLY be called from within a HOOK_SYSJUMP handler.