mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-07 16:11:43 +00:00
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>
59 lines
1.5 KiB
ArmAsm
59 lines
1.5 KiB
ArmAsm
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*
|
|
* Build the full image with up to three program components (one Read only,
|
|
* and one or two Read write).
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include "rollback.h"
|
|
|
|
#define FW_FILE(builddir,proj,sect,suffix,ext) \
|
|
builddir##/##sect##/##proj##.##sect##suffix##.flat##ext
|
|
|
|
#define STRINGIFY0(name) #name
|
|
#define STRINGIFY(name) STRINGIFY0(name)
|
|
#define FW_IMAGE(sect,suffix) \
|
|
STRINGIFY(FW_FILE(FINAL_OUTDIR,PROJECT,sect,suffix,))
|
|
#define FW_IMAGE_SIGN(sect,suffix) \
|
|
STRINGIFY(FW_FILE(FINAL_OUTDIR,PROJECT,sect,suffix,.sig))
|
|
|
|
/* Read Only firmware */
|
|
#ifdef CONFIG_FW_INCLUDE_RO
|
|
.section .image.RO, "ax"
|
|
.incbin FW_IMAGE(RO,)
|
|
#endif
|
|
|
|
#ifdef CONFIG_RWSIG_TYPE_RWSIG
|
|
.section .image.RO.key, "a"
|
|
.incbin STRINGIFY(FINAL_OUTDIR/key.vbpubk2)
|
|
#endif
|
|
|
|
#ifdef CONFIG_ROLLBACK
|
|
/* Note: matches struct rollback_data in common/rollback.c. */
|
|
.section .image.ROLLBACK, "a"
|
|
.long CONFIG_ROLLBACK_VERSION
|
|
.long CROS_EC_ROLLBACK_COOKIE
|
|
#endif
|
|
|
|
/* Shared objects library */
|
|
#ifdef CONFIG_SHAREDLIB
|
|
.section .image.libsharedobjs, "ax"
|
|
.incbin STRINGIFY(FINAL_OUTDIR/libsharedobjs/libsharedobjs.flat)
|
|
#endif
|
|
|
|
/* Read Write firmware */
|
|
.section .image.RW, "ax"
|
|
.incbin FW_IMAGE(RW,)
|
|
|
|
#ifdef CONFIG_RWSIG_TYPE_RWSIG
|
|
.section .image.RW.sign, "a"
|
|
.incbin FW_IMAGE_SIGN(RW,)
|
|
#endif
|
|
|
|
#ifdef CONFIG_RW_B
|
|
.section .image.RW_B, "ax"
|
|
.incbin FW_IMAGE(RW,_B)
|
|
#endif
|