diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-03-08 17:49:25 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-04-06 03:29:38 -0700 |
commit | ca0e82685989a08c6adaa52fc8d33546cd3bb1a2 (patch) | |
tree | 14a2af14564998a5b26e3ae2de1666507b28a8a7 /common/fmap.c | |
parent | 72306c7e020818e31d0fb351b20649b4f8cd732d (diff) | |
download | chrome-ec-ca0e82685989a08c6adaa52fc8d33546cd3bb1a2.tar.gz |
common/rollback: Add support for rollback protection
Implement actual rollback protection. First, we add a new field
in the version structure, which is an incrementing integer
(we'll start by shipping images with version 0, and gradually
increase the number as required). This allows us to release
new versions of the EC without necessarily bumping the rollback
protection.
For the rollback protection block itself, it contains 2 sub-blocks
of equal size (normally, 2k), that are individually erasable.
The rollback code looks at both, and takes the most restrictive one
to determine the desired rollback minimum version. The blocks
are also allowed to be erased (full of 1's), in which case the
rollback minimum version is assumed to be 0.
We also add an FMAP entry, in case we later decide to allow the
signer to increment the rollback version.
Also note that, like any version_data struct change, this change
breaks compatibility between old and new RO/RW.
Follow-up code will take care of auto-updating the rollback block
as required, and properly manage block protection.
BRANCH=none
BUG=b:35586219
TEST=Flash hammer
rollbackinfo => 1 version 0 block, 1 empty block, RW verifies
correctly.
rollbackupdate 0; rollbackinfo => No change
rollbackupdate 1; reboot => RO refuses to jump to RW
rollbackupdate 2, 3, 4; rollbackinfo => Writes alternate
between the 2 blocks.
rollbackupdate 2 => Refuses to downgrade version
Change-Id: Ia969afb481a93deb912b9153bdd95ace01ad8fa7
Reviewed-on: https://chromium-review.googlesource.com/452815
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/fmap.c')
-rw-r--r-- | common/fmap.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/common/fmap.c b/common/fmap.c index c86d28b5ca..eb2a883b5f 100644 --- a/common/fmap.c +++ b/common/fmap.c @@ -63,11 +63,21 @@ struct fmap_area_header { } __packed; #ifdef CONFIG_RWSIG_TYPE_RWSIG -#define NUM_EC_FMAP_AREAS 9 +#define NUM_EC_FMAP_AREAS_RWSIG 2 #else -#define NUM_EC_FMAP_AREAS 7 +#define NUM_EC_FMAP_AREAS_RWSIG 0 #endif +#ifdef CONFIG_ROLLBACK +#define NUM_EC_FMAP_AREAS_ROLLBACK 1 +#else +#define NUM_EC_FMAP_AREAS_ROLLBACK 0 +#endif + +#define NUM_EC_FMAP_AREAS (7 + \ + NUM_EC_FMAP_AREAS_RWSIG + \ + NUM_EC_FMAP_AREAS_ROLLBACK) + const struct _ec_fmap { struct fmap_header header; struct fmap_area_header area[NUM_EC_FMAP_AREAS]; @@ -178,6 +188,24 @@ const struct _ec_fmap { .area_size = sizeof(current_image_data.version), .area_flags = FMAP_AREA_STATIC, }, +#ifdef CONFIG_ROLLBACK + { + /* + * RW rollback version, 32-bit unsigned integer. + * TODO: Get the relative offset of + * __image_data_offset within our RW image to + * accommodate image asymmetry. + */ + .area_name = "RW_RBVER", + .area_offset = CONFIG_EC_WRITABLE_STORAGE_OFF - + FMAP_REGION_START + CONFIG_RW_STORAGE_OFF + + RELATIVE_RO((uint32_t)__image_data_offset) + + offsetof(struct image_data, rollback_version), + .area_size = sizeof( + current_image_data.rollback_version), + .area_flags = FMAP_AREA_STATIC, + }, +#endif #ifdef CONFIG_RWSIG_TYPE_RWSIG { /* RW image signature */ |