Commit Graph

331 Commits

Author SHA1 Message Date
Hung-Te Lin 21b7225caf futility: update: add new quirk 'no_check_platform'
Some devices may have flashed firmware with different platform name in
their early stage (especially in the first build of leading devices),
so we do want to provide an explicit way (not just --force) to skip
checking platform name.

The change CL:2059621 does not help because the loaded system
firmware looks good.

This is implemented as a quirk so we can enable it using a CBFS quirk
file, making it easier to be deployed by auto update.

BRANCH=None
BUG=None
TEST=make runtests

Change-Id: I888d5848921d31c9b7cba1b96c42d38fda71927e
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2573999
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
2020-12-09 17:37:53 +00:00
Julius Werner 9d4053df76 Revert "Reland: Clean up implicit fall through."
This reverts commit 6208b9aa9c.

Upstream coreboot has raised concerns that relying on GCC 7+ features
for host utilities is too restrictive, so revert this and go back to
customizing fallthrough annotations by compiler. Cleaned out some of the
C++-specific stuff because vboot isn't built with C++.

BRANCH=None
BUG=None
TEST=Built with clang and GCC.

Change-Id: I75d796d289b0a6c249fc8ac2dadb1453be468642
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2547821
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-11-20 01:51:08 +00:00
Hung-Te Lin 772d739ac1 futility: update: load quirks from firmware image CBFS file
The firmware updater now looks at CBFS 'FW_MAIN_A' (RW A) and if a text
file 'updater_quirks' is found, the contents will be fetched to setup
default quirks.

This helps sharing same customization across multiple firmware images
(for different models) shared by same unibuild OS image.  Without that,
we have to maintain a large list of hard-coded model names in firmware
updater source.

BRANCH=none
BUG=b:169284414
TEST=make runtests

Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Change-Id: I938bffe9f16bc3adee0dc3efb6976efe581c6d8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2426093
Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
2020-10-16 11:12:50 +00:00
Karthikeyan Ramasubramanian 662bb489d5 futility/updater: Add quirk to preserve management engine
In recent Intel platforms, updating Management Engine (ME) while SoC is in
S0 state is an unsupported use-case. To work-around this issue for the
devices that are in development, specifically during firmware update,
this quirk is added to preserve the ME region. In the subsequent boot,
ME region is updated as part of boot firmware update upstart script.

BUG=b:165590952
BRANCH=None
TEST=With the quirk enabled, ensured that the ME is preserved under the
following scenario:
chromeos-firmwareupdate --mode=autoupdate
chromeos-firmwareupdate --mode=recovery
futility update --mode=autoupdate -a /usr/sbin/chromeos-firmwareupdate
futility update --mode=recovery -a /usr/sbin/chromeos-firmwareupdate
In other scenarios, ME region is not preserved.

Change-Id: I81a52d11d1fb363b7e07ef3439b927449456b28a
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2465286
Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org>
2020-10-15 22:01:13 +00:00
Hung-Te Lin ee0b21b31c futility: update: support multi-line quirks
To support loading quirks from external files, we want to skip tab (\t)
and new line characters (\n, \r).

BRANCH=none
BUG=b:169284414
TEST=make runtests

Change-Id: If314d6cf36907837ce9c36b73337976ee0c6fad1
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2467305
Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org>
2020-10-15 02:17:29 +00:00
Hung-Te Lin 524012c64c futility: updater: print flashrom execution logs on read failure
To prevent flooding AU logs, we don't want flashrom to print verbose
logs especially when reading system SPI flash. However, if anything goes
wrong it will be very helpful to have all the messages logged.

With this patch, we will try reading system flash again with max verbosity.

BUG=chromium:943262,b:169026171
TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
BRANCH=None

Change-Id: I5469182f2628855e65546bef3abf8791261aabca
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1545598
Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2020-09-26 09:18:33 +00:00
Idwer Vollering ade6151a67 portability fixes: support building vboot on FreeBSD
Built on FreeBSD 12.1-RELEASE, 13-CURRENT, using gcc9 installed from
packages.

Change-Id: Ifa8bb343c7e916c1b545cf6c1e4bd0a18ea391cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2382790
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Julius Werner <jwerner@chromium.org>
2020-09-11 01:29:19 +00:00
Hung-Te Lin 34c589e5c1 futility: update: Add '--gbb_flags FLAGS' to override GBB flags
Developers may want to use the new GBB flags when flashing a firmware
image. That can be done by --factory, but it's also more convenient to
have a new parameter for overriding the flags with a new value.

BRANCH=none
BUG=b:166569397
TEST=make runtests

Change-Id: If9dce9b1f2fbb27655ad2a111ba75ab83375fb7a
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2382991
Reviewed-by: Julius Werner <jwerner@chromium.org>
2020-08-29 17:49:21 +00:00
Julius Werner 927a952612 futility: Work around clang/GCC problem with libzip headers
I don't even want to get into why this is needed. I'm so tired of
having to deal with new clang-specific toolchain bullshit 2-3 times a
year. libzip did this

1d949dd773

and then we upreved to it in CL:2245845 and now building upstream
coreboot in a Chrome OS chroot is broken.

I have to get back to wasting time on the other three random things
that broke when I ran repo sync, so someone please just approve...

BRANCH=None
BUG=None
TEST=None

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Ic578e8f8e47f7fafd98d8c3148cbe24d9156886b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2366053
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2020-08-25 08:07:34 +00:00
Daisuke Nojiri 053592bd3d inclusive: change usage of sanity
Google is working to change its source code to use more inclusive
language. To that end, replace the term "sanity" with inclusive
alternatives.

BUG=b:163883397
BRANCH=None
TEST=grep -ir sanity
TEST=make runtests

Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I708a044d89050c442f14fb11a8ae5e98490d56af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2353420
Reviewed-by: Julius Werner <jwerner@chromium.org>
2020-08-19 02:09:02 +00:00
Bob Moragues 075ce5e15e futility: Allow --force to override min_platform_version quirk
BUG=b:162747154
BRANCH=none
TEST=verify that update runs for rev1, but not rev0 without --force
TEST=verify that update runs for both rev1 and rev0 with --force

Signed-off-by: Bob Moragues <moragues@chromium.org>
Change-Id: I1594d6a4c83d8a0c13494f8f108225618612db8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2360590
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
2020-08-18 09:42:23 +00:00
Hung-Te Lin ba87dbf12e futility: updater: always set new boot/try cookies
If the update target is same as the active image, the firmware updater
will do nothing on vboot2. However, if the system already have
fw_try_next set to other slot (for example after multiple updates
applied without rebooting) then the next boot will not pick the right
firmware. So we have to ensure fw_try_next is set to right value.
In the meantime, if fw_try_count and fw_result are not configured at the
same time, the system may start "trying" again and increase the chance
to fail.

To fix that, we should clear trial cookies when there is no update, just
like chromeos-setgoodfirmware.

BUG=b:162866548
TEST=make runtests
BRANCH=None

Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Change-Id: I41ecac445000a850d050d77f0f694ee431926424
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2340172
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
2020-08-08 05:59:15 +00:00
Bob Moragues b99b5f454c futility: Add version quirk for trogdor
BUG=b:162747154
BRANCH=none
TEST=verify that update runs for rev1, but not rev0

Signed-off-by: Bob Moragues <moragues@chromium.org>
Change-Id: I19e88a3046c6e98968650b6d7b1296a1a47c1470
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2334360
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
2020-08-06 00:57:58 +00:00
Jack Rosenthal cc210abb14 flashrom: set umask before creating temporary files
Good security practice.  Set to 077; resultant file permissions are:
  -rw-------

BUG=b:160717634
BRANCH=none
TEST=unit tests

Change-Id: Ib3b853c824be4c98e7b9ddd31797104ec4ab67a9
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2302962
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2020-07-20 19:31:32 +00:00
Rob Barnes 687a4244e4 Revert "futility: Adds platform check quirk for zork"
This reverts commit 8dac1697ae.

Reason for revert: Case sensitivity was turned off in https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2192537. This quirk is no longer needed. It could result in accidental overwriting with incompatible firmware. 

Original change's description:
> futility: Adds platform check quirk for zork
> 
> Adds a quirk for futility on zork boards.
> Zork boards before 13073 used lowercase for the firmware
> names which causes the compatible platform check fail.
> 
> This adds the disable_compatible_platform_check quirk and
> enables it by default for zork boards.
> 
> BUG=b:156119908, b:155941790
> TEST=flashed Google_trembyle.13066.0.0 using servo
>      chromeos-firmwareupdater --force
>      rebooted and confirmed Google_Trembyle.13073.0.0 was flashed
> BRANCH=none
> 
> Change-Id: I6fc6bf5bb42b725b5e7c9d0166f945b9c123bab4
> Signed-off-by: Rob Barnes <robbarnes@google.com>
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2191089
> Reviewed-by: Edward Hill <ecgh@chromium.org>
> Reviewed-by: Eric Peers <epeers@google.com>
> Commit-Queue: Edward Hill <ecgh@chromium.org>

Bug: b:156119908, b:155941790
Change-Id: I4688a380dbcd722e8875bf0b5331ecf797efd6a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2197277
Tested-by: Rob Barnes <robbarnes@google.com>
Tested-by: Bhanu Prakash Maiya <bhanumaiya@chromium.org>
Reviewed-by: Rob Barnes <robbarnes@google.com>
Commit-Queue: Bhanu Prakash Maiya <bhanumaiya@chromium.org>
Commit-Queue: Rob Barnes <robbarnes@google.com>
Auto-Submit: Rob Barnes <robbarnes@google.com>
2020-06-09 04:18:37 +00:00
Julius Werner d5a4570063 futility: vb1_helper: Fix sanity size check for parsing kernel partition
vbutil_kernel --verify didn't check if the size of the kernel body fit
the file it was in. Now it does.

BRANCH=None
BUG=None
TEST=make runtests

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I9cdfd50bd70b72650cdc0fd62bf59a394746ad84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2225663
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-06-06 04:40:01 +00:00
Hung-Te Lin 8467bb3d6d futility: updater: Add '--servo_port' to select from multiple servods
When multiple servo boards are connected to the host, we usually want to
select the right servo by specifying its port, get the servo serial
number, and pass that to flashrom programmer.

The new --servo_port (or environment variable SERVOD_PORT) now allows
developers to flash firmware via specific servod using futility updater
easily:

 futility update --servo_port 9998 -i PATH_TO/image.bin

BRANCH=None
BUG=None
TEST=make runtest; sudo futility update --servo_port 9998 -i image.bin

Change-Id: Ic302f841abf745801995ff233fc209726ed039c8
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2228258
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Douglas Anderson <dianders@chromium.org>
2020-06-06 02:14:55 +00:00
Nicolas Boichat 1cb270074b updater: Replace servo-v2 with google-servo-v2
servo-v2 will eventually be deprecated.

BRANCH=none
BUG=b:145175076
TEST=Flash with servo v2, no more
     "Warning: Use 'google-servo-v2' instead!"

Change-Id: Ie7ae9e173a7cbe0fcd37d1c88b5746fb89cc8e22
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2206094
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2020-05-18 07:04:02 +00:00
Hung-Te Lin 6f207a88c3 futility: updater: Platform name check should be case insensitive
Some platforms (e.g., Zork) may decide to change platform name from
lower_case to CamelCase after early builds, and platform name check will
be an AU blocker in that case.

Considering there should be no devices having same name (and using
incompatible firmware), it should be fine to change the strncmp to
strncasecmp so the platform name check will be case insensitive.

BUG=b:156119908
TEST=make runtests
BRANCH=None

Change-Id: I5014c136976454dd0965a607e5a98bbe4543a41e
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2192537
Commit-Queue: Rob Barnes <robbarnes@google.com>
Tested-by: Rob Barnes <robbarnes@google.com>
Reviewed-by: Rob Barnes <robbarnes@google.com>
2020-05-11 08:22:48 +00:00
Rob Barnes 8dac1697ae futility: Adds platform check quirk for zork
Adds a quirk for futility on zork boards.
Zork boards before 13073 used lowercase for the firmware
names which causes the compatible platform check fail.

This adds the disable_compatible_platform_check quirk and
enables it by default for zork boards.

BUG=b:156119908, b:155941790
TEST=flashed Google_trembyle.13066.0.0 using servo
     chromeos-firmwareupdater --force
     rebooted and confirmed Google_Trembyle.13073.0.0 was flashed
BRANCH=none

Change-Id: I6fc6bf5bb42b725b5e7c9d0166f945b9c123bab4
Signed-off-by: Rob Barnes <robbarnes@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2191089
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Eric Peers <epeers@google.com>
Commit-Queue: Edward Hill <ecgh@chromium.org>
2020-05-11 08:04:19 +00:00
Nikolai Artemiev 8603285362 updater_utils.h: stop using 'dev=1' in flashrom command
Replace 'ec:dev=1' with equivalent 'ec:type=pd'.

BUG=b:153024532
BRANCH=none
TEST=emerge vboot_reference

Change-Id: Ic8df99fcdc3769bec19054b1936b97b14bade0e7
Signed-off-by: Nikolai Artemiev <nartemiev@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2151492
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
2020-04-17 07:36:48 +00:00
Julius Werner b1c6ef3892 Rewrite algorithm type parsers and make them globally available
There is some code strewn around between futility and the vb21-specific
part of hostlib to allow parsing of textual algorithm names to vboot
enums, but it is somewhat disorganized and not written in a super
efficient way. This patch rewrites it and centralizes all the algorithm
mapping stuff under 2crypto.c so it can be a single source of truth for
all of vboot. (String parsing routines still need to stay in hostlib
since not all firmware targets support things like stroul() and
strcasecmp().)

BRANCH=None
BUG=None
TEST=make runtests

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I719b2499992a6e4395a29231bc8b9a7680c5b174
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2099447
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2020-04-06 18:54:38 +00:00
Joel Kitching 02f45f51a7 vboot: stop using StrnAppend and Uint64ToString
Use snprintf instead.  Remove utility_string library.
Also, prepare VbDisplayDebugInfo to handle 64-byte nvdata.

BUG=b:124141368, chromium:968464
TEST=make clean && make runtests
TEST=boot with 16-byte nvdata, check <TAB> output (one line)
TEST=boot with 64-byte nvdata, check <TAB> output (five lines)
BRANCH=none

Change-Id: If6c4b3a4e9fa7b71cb2d8ca7ccd37e4f36b97fd6
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:2122061
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2104880
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2020-03-31 10:36:57 +00:00
Duncan Laurie bf8c99df0c updater: Add Drallion to the wilco quirk list
Add the Drallion board to the list of sarien/arcada so it gets the
workaround to lock the CSME on dogfood units safely.

BUG=b:152475734
BRANCH=none
TEST=none

Signed-off-by: Duncan Laurie <dlaurie@google.com>
Change-Id: I2119f64d5935d3462f0f7ad27d255ec259733553
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2127313
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org>
2020-03-31 06:54:33 +00:00
inglorion 76f646088c Avoid zero-size VLA in cmd_dump_fmap.c
Zero-size variable length arrays are undefined behavior. UBSan reported a
zero-size VLA in futility/cmd_dump_fmap.c when running tests. This
change fixes that by making sure the size of the VLA is at least 1.

BUG=chromium:1058086
TEST=FEATURES="test" USE="llvm-next ubsan" emerge -e --nodeps vboot_reference
BRANCH=none

Change-Id: I3c0eee0359668ce2e1ec3c0724f243788161fb13
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2103436
Tested-by: Bob Haarman <inglorion@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2020-03-18 06:10:58 +00:00
Joel Kitching 8f4737628e vboot: stop using wpsw_boot and remove it from crossystem
wpsw_boot is being deprecated, so just use wpsw_cur.

BUG=b:124141368, chromium:950273
TEST=make clean && make runtests
BRANCH=none

Change-Id: Iae63b2a76b19629a9ecd9b87e5dd6367767860b3
Cq-Depend: chromium:2066154, chromium:2068241, chromium:2068209
Cq-Depend: chromium:2068297, chromium:2067229, chromium:2067231
Cq-Depend: chromium:2068242
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2066192
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2020-02-27 17:25:16 +00:00
Hung-Te Lin deaf82b9b4 futility: updater: Fix failure by modifying released memory
When deleting the temp files, the pointer to released head must not be
used again. Setting 'next' to NULL should be done earlier.

BUG=chromium:1055468
TEST=make clean && make runfutiltests
BRANCH=none

Change-Id: Ia4356ade5fcf85e2bfc917c5a3bcbb7f492c5a08
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2071179
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2020-02-26 01:20:32 +00:00
Hung-Te Lin b2efcbe100 futility: updater: Ignore image parsing error in --force
The firmware updater has been improved to support flashing outside DUT
(--ccd, --servo) that also implies more people will use it for devices
with corrupted (or empty) firmware. It's pretty confusing for developers
to see "Cannot load system active firmware" while the flashrom can
actually read and write to the SPI firmware.

The solution here is to allow updating on such devices when --force is
specified (which is automatically applied for --servo and --ccd).

BUG=b:148405957
TEST=make runtests
BRANCH=None

Change-Id: I19e63e3464616bc508639cbfad0d1cf8e99507b0
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2059621
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-02-21 10:35:48 +00:00
Joel Kitching 166840277a vboot: move vboot 2.1 functions and structs into host code
These structs and functions need to stick around for futility
to use, but they are no longer supported in firmware code.

Rename host/lib21/include/* files to end in 21 instead of 2.

BUG=b:124141368, chromium:968464
TEST=make clean && make runtests
BRANCH=none

Change-Id: I01e181e2f03553d60724fbdc826f5ada63777303
Cq-Depend: chromium:1969172
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1963621
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2020-02-11 02:04:10 +00:00
Manoj Gupta 6208b9aa9c Reland: Clean up implicit fall through.
Directly use the __attribute__ ((fallthrough)) instead of
a macro.
This was suggested in CL:1772474.

BUG=chromium:997709
TEST=CQ
BRANCH=None

Change-Id: Ifcdcd3822eddea41aeb88f4a55bd09aa483f6054
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2031766
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2020-02-01 03:54:08 +00:00
Julius Werner f57ad98c29 Enable format string warnings for vb2ex_printf()
This patch enables the -Wformat warning and tags vb2ex_printf() with the
appropriate attribute so the compiler recognizes it as a printf variant.
This shows a bunch of (sometimes pretty bad) issues in existing code
that are hereby fixed.

Cannot enable -Wformat-security yet since a lot of code still uses
non-constant format strings and it's unclear whether we can/want to
change that in all circumstances (e.g. stuff like DoError()).

BRANCH=None
BUG=None
TEST=make runtests

Change-Id: I917a4982a97a668a5c0f793f7c771573f2bd3949
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2013857
2020-01-25 05:39:33 +00:00
Hung-Te Lin e6d3c63809 futility: updater: Add '--servo' for updating via Servo-V2 and ServoMicro
Flashing via Servo V2 and Servo Micro was known to be a complicated.
With the new virtual control 'cpu_fw_spi' we have a better way to
prepare servo in an unified way.

The new '--servo' will detect servo type and pick up the right params
(for servo v2, servo micro, servo v4 with ccd, or servo v4 + micro)
for programming.

BRANCH=None
BUG=None
TEST=make runtest; sudo futility update --servo -i image.bin

Cq-Depend: chromium:1966176
Change-Id: Ia14288b1bd5f24acfc4fb85ba64c2c445152a3a7
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1966872
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Wai-Hong Tam <waihong@google.com>
2020-01-20 07:09:10 +00:00
Paul Ma 5ea8fe68b1 futility: updater: override signature id for phaser360
Because of lacking CL:1501614 in octopus factory branch, dopefish
root key is written to some phaser360 devices. That will lead to
firmware updater not be able to verify RW vblock and AU will fail.
This CL will fix that by using root key info and model name to
make firmware updater get a proper sig_id so that in-field machines
can be updated by AU.

BUG=b:146876241, b:133901651, b:146482979
BRANCH=none
TEST=using a DUT of phaser360 (without whitelabel_tag = dopefish)
     which is flashed dopefish rootkey and hwid, using command
     'chromeos-firmwareupdate -m autoupdate --wp=1' to flash
     firmware, RW firmware can be updated and DUT can boot normally.

Change-Id: I163c16189c28a996ed08bf2a7b162e6ee3b13be6
Signed-off-by: Paul Ma <magf@bitland.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1981650
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
2020-01-08 07:47:13 +00:00
Joel Kitching 582453dd62 vboot: fix up some host key functions for host_key2.c
Deprecate:
  PublicKeyInit --> vb2_init_packed_key
  PublicKeyCopy --> vb2_copy_packed_key

Rename:
  packed_key_looks_ok --> vb2_packed_key_looks_ok

Move vb2_packed_key_looks_ok from host_key.c to host_key2.c.
Move tests/vboot_common_tests.c to tests/vb2_host_key_tests.c.
Remove firmware/lib/vboot_common.c.
Remove host/lib/host_key.c.

BUG=b:124141368, chromium:968464
TEST=make clean && make runtests
BRANCH=none

Change-Id: I627b2af0416ac69460f9860614a69cad8bdb76a7
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844597
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-12-25 22:33:00 +00:00
Joel Kitching 568b7b0d8a vboot: remove VerifyVmlinuzInsideKBlob function
Replace the use of VerifyVmlinuzInsideKBlob with vboot2-style
vb2_verify_member_inside.

BUG=b:124141368
TEST=make clean && make runtests
BRANCH=none

Change-Id: I2ffb52a4e7d7b93b2512923145db5f6ff4f3dfd5
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844599
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
2019-12-21 01:04:47 +00:00
Joel Kitching efec8ac6a3 vboot: merge vb2_struct.h into 2struct.h
Also remove unused preamble structs in vboot_struct.h.

BUG=b:124141368, chromium:968464
TEST=make clean && make runtests
BRANCH=none

Change-Id: I8b41f24b55eba91b1f952415eda1b532732848eb
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844601
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-12-10 10:36:21 +00:00
Joel Kitching b85ce0705d vboot: remove unnecessary vboot_common.h includes
BUG=b:124141368
TEST=make clean && make runtests
BRANCH=none

Change-Id: I7daf97a88c71ff188c5812a30ca71d6c84823ae9
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844595
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-12-06 21:19:43 +00:00
Hung-Te Lin dc721411f2 futility: updater: Remove quirk 'daisy_snow_dual_model'
Daisy snow has set its AUE version to R75 and R76 went stable for a long
time, so we can now remove the quirk for it.

BUG=None
TEST=make clean && make runtests

Change-Id: I8a955f1e02221c6562958f584dabdb27ab5d870d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1940401
Tested-by: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-11-29 05:24:18 +00:00
Hung-Te Lin 6ef33b9905 futility: updater: refactor: unify getting temp files for firmware images
Unify "create a temp file and write firmware image contents" to the
new API get_firmware_image_temp_file with better error messages.

BRANCH=none
BUG=chromium:1024401
TEST=make clean && make runtests

Change-Id: I441f24053a8d94def587cf8270c44a4bdce9a4fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1928359
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Hung-Te Lin <hungte@chromium.org>
2019-11-27 16:58:19 +00:00
Hung-Te Lin 16c91aa86c futility: updater: refactor: isolate tempfile functions from updater_config
The updater_utils.c should not deal with updater_config directly.
Currently everything relates to generating temporary files will need
updater_config due to updater_create_temp_file. By moving that out (let
every caller to pass &cfg->tempfiles) we can detach updater_utils.c from
updater_config.

BRANCH=none
BUG=chromium:1024401
TEST=make clean && make runtests

Change-Id: I44bc4df0152596a822b1e0672f41c16825472249
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1928358
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Hung-Te Lin <hungte@chromium.org>
2019-11-22 22:09:24 +00:00
Hung-Te Lin 10c0559dd4 futility: updater: move "EC partial recovery" to be a quirk.
The "EC update" (either calling flashrom or using EC RO software sync)
logic has been bloated and is really not a typical updater feature (that
only makes sense for dogfooders). And we have seen enough special cases
that some boards may not want to use it (or causing problems).

Move that to a quirk so we can turn on or off in a more flexible way.

BRANCH=none
BUG=chromium:1024401
TEST=make clean && make runtests

Change-Id: I2d4fe0d9ee0d98ad41b8cbdcaff848846d120d07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1926010
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Hung-Te Lin <hungte@chromium.org>
2019-11-22 22:09:23 +00:00
Hung-Te Lin e861838005 futility: updater: move system-related utility functions to updater_utils
The firmware updater (updater.c) is bloated so we should move functions
that are not really related to 'updating logic' to a new file,
updater_utils.c.

Refactor only by moving functions (and renamed few functions), no
changes in updater logic.

BRANCH=none
BUG=chromium:1024401
TEST=make clean && make runtests

Change-Id: I98339c5c4a81845b36daf842c79625fa2389c7f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1926009
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Hung-Te Lin <hungte@chromium.org>
2019-11-22 22:09:21 +00:00
Hung-Te Lin a31ad0c3be futility: updater: fix wrong arguments passed by --ccd
When flashing using CCD, we should:
 - Set programmer to raiden_debug_spi:target=AP
 - Set write protection argument to "0" instead of number 0 (which means NULL).
 - do_check_compatible_tpm_keys should not raise failure if force_update is set.

BRANCH=None
BUG=None
TEST=make runtest;
     sudo futility update --ccd -i image.bin

Change-Id: I01121791bbbae0ffbcbc7a56c24b506d48ef7394
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1926011
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Hung-Te Lin <hungte@chromium.org>
2019-11-21 22:59:49 +00:00
Hung-Te Lin 6737b9e9a7 futility: updater: Check and use larger regions in EC RO update
Unlike STM32 (used on ARM Chromebooks), EC images on most x86
Chromebooks used to have a header before EC_RO section describing the
size and attributes of firmware to load.  However, partial updating with
only 'EC_RO' by flashrom will not include those data. So we should use
'WP_RO' to update whole RO area.

This also implies EC RO software sync, which usually only updates
ec.RO.bin in EC_RO, is not safe on devices with extra data. A quick
solution is to only allow RO software sync when EC_RO is aligned to top
of EC firmware image. Also in future devices cannot run EC software sync
may skip generating EC RO blobs in AP coreboot CBFS so the updater won't
try to do RO software sync.

BUG=chromium:1024401
TEST=(kukui) chromeos-firmwareupdate --mode=recovery # updated and boot
     (laser) chromeos-firmwareupdate --mode=recovery # updated and boot
     also verified we can update from old x86 EC (EC_RO does not
     include header) to new style (EC_RO contains header).

Change-Id: I2c90320ffbfd79ba0cbaf70016446d8ab489e6ac
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1919097
Reviewed-by: Shelley Chen <shchen@chromium.org>
2019-11-18 07:44:33 +00:00
Hung-Te Lin 26cb4f2d56 futility: updater: Correct EC RO name in CBFS
The EC RO name inside CBFS is actually 'ecro' instead of 'ec_ro'.

BRANCH=None
BUG=b:141965252
TEST=make clean && make runtests
     Run 'futility update -i image.bin -e ec.bin --mode=recovery'

Change-Id: I2ede0bfbd550d343726df893ce707e82d77d5f30
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1913689
Reviewed-by: Joel Kitching <kitching@chromium.org>
2019-11-14 03:11:14 +00:00
Joel Kitching 92ea19ae09 vboot: align workbuf to VB2_WORKBUF_ALIGN
Also standardize on position and spacing of __attribute__.

BUG=b:124141368
TEST=make clean && make runtests
BRANCH=none

Change-Id: Ic61d6193c2413824837a51af98eb2dcd9ea4ab85
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1902843
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-11-13 14:45:18 +00:00
Mike Frysinger c48a593b26 futility: updater: sync mtimes
When unpacking files, unzip will retain timestamps on the outputs.
This makes it easy to recreate the firmware unpacker with the same
exact contents.  futility doesn't copy update timestamps anywhere,
so all the mtimes are $now, which makes it impossible to recreate
the same archive.

Update the API to pass around mtimes by reading them from inputs,
setting them on outputs, and copying them across.

BUG=None
TEST=`futility update -a chromeos-firmwareupdate --unpack out` has timestamps on outputs
BRANCH=None

Change-Id: Icc0ae833390115082e1677d190d1b2a029b78439
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1913067
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2019-11-13 10:05:11 +00:00
Hung-Te Lin 87276ffed4 futility: updater: Clean up hard-coded section names to preserve
The following sections can be now deleted from hard-coded list:

- RO_PRESERVE: no boards use it.
- RO_FSG: new images have set the PRESERVE flag in CBFS.
- SI_GBE, SI_PDR: already using PRESERVE flag since fw branch is cut.

BUG=b:116326638,chromium:936768
TEST=make clean && make runtests

Change-Id: I99759949104bf4f1c1db3556e273923dcb1c5887
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1902841
Tested-by: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
2019-11-08 03:45:26 +00:00
Mathew King ed8390ec50 Revert "Clean up implicit fall through."
This reverts commit 6a703f5b0e.

Reason for revert: This change breaks building coreboot

Original change's description:
> Clean up implicit fall through.
> 
> Directly use the __attribute__ ((fallthrough)) instead of
> a macro.
> This was suggested in CL:1772474.
> 
> BUG=chromium:997709
> TEST=CQ
> BRANCH=None
> 
> Change-Id: Ic6cd417d7c735395a4b136dbb0879a6f1716da98
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1897360
> Tested-by: Manoj Gupta <manojgupta@chromium.org>
> Reviewed-by: Julius Werner <jwerner@chromium.org>
> Commit-Queue: Manoj Gupta <manojgupta@chromium.org>

Bug: chromium:997709
Change-Id: Icd0de8bcdee44d1b41f313a4f5aaba8108f734ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1899735
Reviewed-by: Mathew King <mathewk@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Julius Werner <jwerner@chromium.org>
Tested-by: Julius Werner <jwerner@chromium.org>
2019-11-05 22:45:39 +00:00
Manoj Gupta 6a703f5b0e Clean up implicit fall through.
Directly use the __attribute__ ((fallthrough)) instead of
a macro.
This was suggested in CL:1772474.

BUG=chromium:997709
TEST=CQ
BRANCH=None

Change-Id: Ic6cd417d7c735395a4b136dbb0879a6f1716da98
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1897360
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2019-11-05 15:51:53 +00:00