Commit Graph

442 Commits

Author SHA1 Message Date
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
Aaron Massey 110d598118 crossystem - remove fmap_base utility
fmap_base utility no longer needed since b:157897361

BUG=chromium:1091253
BRANCH=none
TEST=Compiled, cros_workon_make test,
and cros deploy to kindred device to confirm
there was no fmap_parameter.

Change-Id: Idc89c82555531030beaf8f84ce483a5f49a86fbe
Signed-off-by: Aaron Massey <aaronmassey@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2241386
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
2020-06-16 17:56:56 +00:00
Yu-Ping Wu 7f6c50e7cc vboot: rename USB to more accurate EXTERNAL
Rename enumerators of the vb2_dev_default_boot_target enum as follows,
because the term USB is not quite accurate (we can also boot from an SD
card).

 VB2_DEV_DEFAULT_BOOT_TARGET_DISK
 --> VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL

 VB2_DEV_DEFAULT_BOOT_TARGET_USB
 --> VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL

Also perform similar renaming for the following.

enum vb2_nv_param:
 VB2_NV_DEV_BOOT_USB
 --> VB2_NV_DEV_BOOT_EXTERNAL

enum vb2_secdata_fwmp_flags:
 VB2_SECDATA_FWMP_DEV_ENABLE_USB
 --> VB2_SECDATA_FWMP_DEV_ENABLE_EXTERNAL

constants:
 VB2_NV_DEV_FLAG_USB
 --> VB2_NV_DEV_FLAG_EXTERNAL

functions:
 vb2_dev_boot_usb_allowed
 --> vb2_dev_boot_external_allowed

BRANCH=none
BUG=none
TEST=make runtests

Change-Id: Iad16fcf34d76da08c6d8a81e150c7fde927c743b
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2237622
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-06-13 08:51:23 +00:00
Julius Werner 08c2ee1bc9 chromeos-tpm-recovery: Add support for v1 secdata_kernel
The recent format changes to the kernel TPM NVRAM space weren't
reflected in the chromeos-tpm-recovery utility yet. This patch fixes
that. Since this may require upgrading from the old to the new format
(or even the other way around), we also have to fix the longstanding
limitation of not recreating TPM spaces for TPM 2.0. We still cannot do
that for the firmware TPM space, but at least we can add it for the
kernel one.

BRANCH=none
BUG=chromium:1020578,b:155149943
TEST=Ran on a Trogdor

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Iaf9bc6b29f76cfeaab90ae4f99099735c4f9441b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2227260
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-06-06 00:17:55 +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
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
Joel Kitching 83ab1908e8 vboot: use vboot2 for storing kernel rollback versions
Migrate to using vboot2 shared data fields for storing
kernel rollback versions:

  kernel_version_tpm_start(1) --> kernel_version_secdata(2)
  kernel_version_tpm(1) --> kernel_version(2)
  kernel_version_lowest(1) --> [removed]

Also remove VBSD from tests which no longer need it.

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

Change-Id: I26c2ccede5fba52e1477b625ef5fc6181f60aadf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2053179
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2020-02-19 10:29:53 +00:00
Joel Kitching e81d9bc797 vboot: fix up load_kernel_test to store subkey in workbuf
Since CL:1651221, kernel subkey has been stored and accessed
as part of vboot2 workbuf.  We forgot to update the utility
load_kernel_test to follow suit.

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

Change-Id: I67686dc9dd555d3cce9d1be287b56c108460239b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2054268
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2020-02-14 11:51:43 +00:00
Joel Kitching 58ae67008f vboot: unmarry LoadKernel from VBSD
Create a function-local copy of VbSharedDataKernelCall rather
than using the memory built-in to VBSD.  Stop making any
reference to vboot1 VBSD from LoadKernel.

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

Change-Id: I5dabfb33a0eb05c1f40509dcf00a4c5751af1ef5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2053182
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-02-14 11:51:40 +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
Yu-Ping Wu ab8a4d48cb vboot/crossystem: Deprecate recoverysw_is_virtual
As part of chromium:943150, virtual recovery switch functionality is
being deprecated. Physical presence should be chosen by specifying one
of the following USE flags:
- physical_presence_keyboard
- physical_presence_recovery
- physical_presence_power

Fields VDAT_INT_DEPRECATED_DEVSW_VIRTUAL and VDAT_INT_RECSW_VIRTUAL are
also removed from VdatIntField.

BRANCH=none
BUG=chromium:943150
TEST=make runtests

Cq-Depend: chromium:2004370
Change-Id: I4342a2607538d1b4480d601073eb531e93e74b38
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2037268
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-02-06 16:21:42 +00:00
Joel Kitching e22ceb974f vboot: remove secdata TPM backend code
In vboot 2 design, secdata spaces are read/written by the vboot
caller, and not by vboot itself.  We still need to maintain a
vb2ex_commit_data callback for edge cases, such as when the vboot
UI prompts the user to reboot.

BUG=b:124141368, chromium:972956
TEST=Build locally, flash and boot eve,
     check logs for secdata writes and locks
TEST=make clean && make runtests
BRANCH=none

Change-Id: Ib3b628549185749a290dd65e297f2e19adecbc66
Cq-Depend: chromium:1958012
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1958070
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
2020-01-22 09:02:03 +00:00
Yu-Ping Wu edfe2f2873 crossystem: Fix error message when passing invalid parameter
When setting crossystem parameters with various errors, the error
message was always "Parameter dev_default_boot is read-only". Display
various error messages based on the types of errors.

BRANCH=none
BUG=chromium:965799
TEST=emerge-nami vboot_reference

Change-Id: I185ce5f9c142da538f86b6c6c298f5a76377e395
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1982431
Reviewed-by: Joel Kitching <kitching@chromium.org>
2020-01-06 12:50:25 +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 53332109ac vboot: remove some vboot1 SharedData-related functions
Remove VbSharedDataInit, VbSharedDataReserve,
VbSharedDataSetKernelKey, along with their corresponding tests.

In tests/verify_kernel and utility/load_kernel_test, just copy the
kernel subkey manually for now, until we update LoadKernel to
retrieve the key from vboot2 workbuf instead.

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

Change-Id: I7055be10f0d7a38502fd8108f0bc93c5b78f06c9
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844598
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
2019-12-17 11:52:45 +00:00
Julius Werner 32b5c34d13 chromeos-tpm-recovery: Clarify error message for boot mode
chromeos-tpm-recovery only works when it's actually booted in recovery
mode, not when just running a recovery image in developer mode with
Ctrl+U. This distinction is often not super clear to non-firmware
people, so make the error message more explicit.

BRANCH=None
BUG=None
TEST=None

Change-Id: I18afa933f624f26d1f7949b9b586ab01daf7c801
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1913491
Reviewed-by: Curtis Malainey <cujomalainey@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2019-11-16 07:25:46 +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
Joel Kitching ecdca931ae vboot: move vb2_context inside vb2_shared_data (persistent context)
Move vb2_context to live inside of vb2_shared_data, instead of
in a separate memory space allocated by the caller.

See design doc:
http://go/vboot2-persistent-context

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

Change-Id: If2421756572a43ba58b9da9f00e56a8f26ad3ad5
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1874753, chromium:1902339
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1716351
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Julius Werner <jwerner@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-11-13 06:14:05 +00:00
Joel Kitching d3b2117f9a vboot: standardize on "keyblock" as one word
Stardardize on inconsistency between "keyblock" and "key block"
both in code, comments, and textual output.

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

Change-Id: Ib8819a2426c1179286663f21f0d254f3de9d94a4
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1786385
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-10-23 16:28:16 +00:00
Joel Kitching 77dff643fc vboot: remove timers from VbSelectAndLoadKernel and crossystem
These timers have not been used in eons, and an alternative
already exists (coreboot's tstamp_table).

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

Change-Id: Ic0d3e14028315d6f343388c7c1c9d105b7bd58a2
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1860254
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-10-23 16:28:14 +00:00
Joel Kitching 3c477458fa vboot: format hex numbers with %#x instead of 0x%x
Also standardize on using hex for printing ASCII key values
across vboot_ui.c and vboot_ui_menu.c.

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

Change-Id: Ib10288d95e29c248ebe807d99108aea75775b155
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1840191
Reviewed-by: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-10-23 16:28:14 +00:00
Joel Kitching ffd42a8220 vboot: fix up some more includes
Should have no extra line breaks in between local includes,
and should be sorted alphabetically.

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

Change-Id: I83c25d30d7376712857314965a7d93f57190aa3f
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776281
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-09-23 17:54:12 +00:00
Joel Kitching 110df5cafa vboot/secdata: rename rollback_index to secdata_tpm
These secure spaces are now used for more than just rollback
versions and should be renamed thus.

Note: Originally this rename operation was batched into the CL
which rewrites the functions in rollback_index/secdata_tpm, but
it made reviewing in Gerrit a pain, since it couldn't pick up on
the file renames, and instead showed them as deletes/adds.

Doing the rename separately helps ensure all references to
rollback_index are updated, and gives us a better review
experience in Gerrit.

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

Change-Id: I51e5c731e0d7a071d384c28da56e7adce64ba943
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776279
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-09-05 14:29:06 +00:00
Joel Kitching 090279951f vboot: remove more Alt OS code
BUG=b:124141368, b:131663912, b:139392536
TEST=make clean && make runtests
BRANCH=none

Change-Id: I91eab08130786188b0a7c514b35574c611863b03
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758147
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-08-28 18:40:56 +00:00
Joel Kitching 9adf2aa243 vboot: fix up some headers, includes, comments, spacing
BUG=b:124141368
TEST=make clean && make runtests
BRANCH=none

Change-Id: Id97f544da845f7070555e5e8cc6e782b2d45c300
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758151
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-08-28 07:32:05 +00:00
Joel Kitching 4539726499 vboot: remove 9-year old tpm_init_temp_fix workaround
From the original CL:3077016:
"Small program to temporarily fix TPM state until we can do this
in the BIOS."

BUG=b:124141368
TEST=emerge with USE=cros_host and USE=-cros_host
BRANCH=none

Change-Id: Icc90bc2b3ee76b66b803af4059dafbe5e1d52daf
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1763969
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1763970
Reviewed-by: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-08-27 04:33:48 +00:00
Joel Kitching b1329fe473 vboot: bring load_kernel_test up to coding style standards
In case we want to keep it around.  See b:139839429.

BUG=b:124141368, b:139839429
TEST=None
BRANCH=none

Change-Id: Ib49a8c7a1acf2e643fcda0a68bf39d756506e3a2
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1763971
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-08-27 04:33:46 +00:00
Joel Kitching 0b3ce46218 vboot: replace sysincludes.h with 2sysincludes.h
sysincludes.h and 2sysincludes.h are almost identical except for
one extra header (ctype.h) in the vboot1 variant.  Add this to
2sysincludes.h, and nuke sysincludes.h.

Depends on: https://review.coreboot.org/c/coreboot/+/33525

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

Change-Id: Iaba21a9b8bb2ae0c081184019576663898317bd1
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1680325
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1659990
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Auto-Submit: Joel Kitching <kitching@chromium.org>
2019-08-22 04:37:19 +00:00
Joel Kitching cf49e7b6ae vboot: replace VBERROR_SUCCESS with VB2_SUCCESS
Replace vboot1-style VBERROR_SUCCESS with VB2_SUCCESS
(trivial change since both are equal values).

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

Change-Id: I46e02471a031e9f36ec869d11d0b957d1c1b5769
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1728114
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722915
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-08-13 08:23:54 +00:00
Julius Werner a5afd01feb Minor fixes for clang
We want to switch over from GCC to clang for userspace utilities. It
comes with a new default warning that we happen to trigger, so silence
that. It also comes with a dumb reachability checker that can't tell
when the use of one variable is guarded by another, so need to
unnecessarily initialize a variable in load_kernel_test.

BRANCH=none
BUG=chromium:991812
TEST=Built for Kevin with clang.

Change-Id: If9fc391ade0243aea1cae8d682e31390dc082f77
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1744667
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2019-08-09 22:07:47 +00:00
Joel Kitching 90671fa6d2 vboot: rename VbError_t typedef to vb2_error_t
As part of the conversion of error codes from vboot1 to vboot2,
replace all instances of VbError_t with vb2_error_t.

vboot2 currently uses the int type for return values, but we
would like to implement the use of vb2_error_t instead, which is
potentially clearer than simply using an int.  Existing functions
will be converted to use vb2_error_t in a subsequent CL.

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

Change-Id: Iee90d9a1f46bcf5f088e981ba6ddbcf886ff0f18
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1728112
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722914
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
2019-08-06 15:14:47 +00:00
Joel Kitching 34abb32ed2 vboot: remove Boot Descriptor Block (BDB) library and utilities
Remove unused BDB code, previously created for a cancelled SoC
project.

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

Change-Id: I91faf97d9850f8afb816fa324ad9a4d9f3842888
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1710336
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
2019-07-24 06:53:40 +00:00
Joel Kitching e501b731d8 vboot: remove VbPublicKey struct
Update all references to vboot2-style struct vb2_packed_key.

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

Change-Id: I55a5f6bf315bdb4b83a998759d3732077283998e
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675871
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-07-10 01:57:10 +00:00
Vadim Bendebury 236bfb0bc3 tpmc: fix tpmc pcrextend error message
The PCR extension value size should not have been hardcoded, it is
different for different TPM specification versions.

BRANCH=none
BUG=none
TEST=the error message prints the correct expected input size for both
     tpm and tpm2 case now.

Change-Id: I8e65181edff1e62bbaae46e622fe67f420cbab25
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1627640
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2019-05-27 23:09:14 -07:00
Joel Kitching 27e3e9fcba vboot: deprecate v1 GoogleBinaryBlockHeader struct
Deprecate internal usage of GoogleBinaryBlockHeader struct in
favour of vb2_gbb_header struct.  Keep the v1 struct around until
we remove references in other repos.

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

Change-Id: I396d2e624bd5dcac9c461cc86e8175e8f7692d26
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1583826
Commit-Ready: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2019-05-17 18:36:48 -07:00
Joel Kitching 43f6cab881 vboot: update display init to use vboot2 code
As per go/vboot2-oprom-cleanup, use vboot2 SD flag
DISPLAY_AVAILABLE, instead of the old vboot1 flags
OPROM_MATTERS and OPROM_LOADED.

Remove instances of "OPROM" and update with correct
nomenclature.

Update code and tests for EC software sync and diagnostic
menu to use vboot2 display init model.

OPROM_MATTERS and OPROM_LOADED are now deprecated, and
will be removed when no references remain in depthcharge
and coreboot.

Deprecate VBERROR_DISPLAY_INIT_MISMATCH (previously
OPROM_MISMATCH) and return VBERROR_REBOOT_REQUIRED
directly when needed.

BUG=b:124141368, b:124192753, chromium:948529
TEST=Build image for eve, force EC update,
     check that the "critical update" screen shows
TEST=make clean && make runtests
BRANCH=none

Change-Id: I889872f886230f8559d5cce09d0de194da3fcc38
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1605641
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-05-16 09:04:19 -07:00
Julius Werner 52fa8c11f8 Makefile: Enable more warnings for host utilities / tests
This patch adds a bunch of more warnings that are already enabled in
coreboot and thus already enabled for firmware builds anyway (because
coreboot just passes its CFLAGS through). Enabling it in the vboot
Makefile means they also apply to host utilities and tests, which sounds
desirable for consistency.

Fix enough of the cruft and bad coding practices that accumulated over
the years of not having warnings enabled to get it to build again (this
includes making functions static, removing dead code, cleaning up
prototypes, etc.).

Also remove -fno-strict-aliasing from the x86 firmware build options,
because it's not clear why it's there (coreboot isn't doing this, so
presumably it's not needed).

BRANCH=None
BUG=None
TEST=make runtests

Change-Id: Ie4a42083c4770a4eca133b22725be9ba85b24184
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1598721
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
2019-05-14 20:13:04 -07:00
Julius Werner 8cb16750de utility: Remove efi(de)compress
These utilities used to be a bmpblk dependency way back in the day. Now
that bmpblk utilities have been removed, we don't need them anymore.

BRANCH=None
BUG=None
TEST=make runtests

Change-Id: I73b77b853dc03a7c867b8726de3cdeb01314916e
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1601677
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2019-05-14 20:13:03 -07:00
Daisuke Nojiri ad546b47f6 Remove code for displaying screen from GBB
This patch removes the code displaying vboot screens using bitmap
and layout data stored in GBB. bmpblk_utility, and futility
support for BmpBlock is also removed.

BUG=chromium:622501,chrome-os-partner:54619,b:124141368
BRANCH=none
CQ-DEPEND=CL:373123
TEST=Verified screens on eve && emerge-eve chromeos-bootimage &&
make runtests

Change-Id: I1a8dd8ff0162965e81df121d5a87ea64310a0854
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/367882
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
2019-05-07 17:23:01 -07:00
Matt Delco 90a95ea62a firmware: allocate nvram bit for diagnostic mode
This change allocates a bit in the nvram that will be used
in a later change to tell the firmware whether to detour
to diagnostic mode during boot.

BUG=b:124358784
BRANCH=None
TEST=Local build and ran "make runtests".  Verified with a later
change that the nvram bit takes effect as expected.

Change-Id: If2fd3f46da30fc7375d37b240e3e745819ae0632
Signed-off-by: Matt Delco <delco@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1504758
Reviewed-by: Julius Werner <jwerner@chromium.org>
2019-03-20 19:51:15 -07:00
Joel Kitching 006de7e72e crossystem: correct spacing for Alt OS in help messages
Also, add (writable) at the end.

BUG=None
TEST=None

Change-Id: I34eb1e8e02ba3c837ba5fa452f9f6da64ce7b6e0
Reviewed-on: https://chromium-review.googlesource.com/1328391
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2018-11-19 16:28:26 -08:00
Joel Kitching 8c52481794 crossystem: add alt_os_enabled to show Alt OS state
Some user-space applications need to know whether Alt OS is
currently enabled or disabled.  Add alt_os_enabled to
crossystem as a read-only flag for this purpose.

It is currently based off of reading VBSD_ALT_OS_SHOW_PICKER
from VbSharedDataHeader.  We may want to change that to a
field dedicated to showing Alt OS state in the future
(see b/117195332).

BUG=b:117195332,b:117142023
TEST=emerge-eve vboot_reference && \
     cros deploy --force --board=eve dut vboot_reference

Change-Id: Ic9a120e7d24021eb984d501f09ce4d7b6f85d730
Reviewed-on: https://chromium-review.googlesource.com/1328390
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2018-11-19 16:28:25 -08:00
Joel Kitching 0f7779862c CHERRY-PICK: vboot: create NVRAM flag to pause after EC software sync
Previously, it is impossible to programmatically enable/disable
Alt OS mode in eve.  This is because only EC-RW supports the
kbatboot keyboard matrix functionality.  But, as part of the
campfire boot flow, the keyboard matrix is retrieved *immediately*
after jumping into EC-RW.  We need to insert a small pause in
order to allow for some entity (autotest/servo) to send a kbatboot
command, simulating the Alt OS keyboard press hotkey.

BUG=b:117140648,b:118786884
TEST=Manually use crossystem to set post_ec_sync_delay=1
     Reboot, and wait for the delay to begin
     Run `kbatboot 1 4 1` in EC console
     Check that AP console contains:
       "vb2_post_ec_sync_hooks: post_ec_sync_delay 5000 ms..."
TEST=make clean && make runtests

Note that we are only cherry-picking the changes which affect
crossystem in this CL.  Firmware changes will still live in
campfire-eve branch only.

Change-Id: I1305357199d87b80b4edc4e311015106ab07de65
Reviewed-on: https://chromium-review.googlesource.com/c/1256644
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Trybot-Ready: Joel Kitching <kitching@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 64d7369976)
Reviewed-on: https://chromium-review.googlesource.com/1328389
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2018-11-19 16:28:25 -08:00
Meng-Huan Yu 62eec262de tpmc: Make 'tpmc def' replace the existing space by default
In chromium:895549, we want to have consistent behavior of
'tpmc def' between TPM 1.2 and TPM 2.0.
In TPM 1.2, define space command will undefine the existing space,
and create a new one. So we make the 'tpmc def' act as this by
default.

Also, provide a option for whom may want to define a new space
only if it is not defined yet. It will return TPM error code
at that case.

BUG=chromium:895549
BRANCH=None
TEST=unit test; manually test:

 # For TPM 2.0 use AUTHREAD|AUTHWRITE
 tpmc tpmversion | grep 2.0 && export PERM=0x40004
 tpmc tpmversion | grep 1.2 && export PERM=0x1

 # Define the space
 tpmc def 0x1020 0x1 "$PERM"

 # Redefine the space, default will overwrite
 tpmc def 0x1020 0x1 "$PERM"
 # Expected: Success

 tpmc def 0x1020 0x1 "$PERM" --no-overwrite
 # Expected: output error for the space is already defined.
 # For TPM 2.0, it should output:
 #  command "def" failed with code 0x14c
 #  the TPM error code is unknown to this program
 # For TPM 1.2, it should output:
 #  The space is existing but --no-overwrite is set.

Change-Id: I9b4e742f2935578443ebcc69e91d0aebc84deed8
Reviewed-on: https://chromium-review.googlesource.com/1298098
Commit-Ready: Meng-Huan Yu <menghuan@chromium.org>
Tested-by: Meng-Huan Yu <menghuan@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2018-11-01 02:17:43 -07:00
Meng-Huan Yu e05cdbc1d3 tpmc: Add 'undef' command support to undefine NV space
For TPM 1.2, the undef command only works when NvLocked is not set
which is usually set before boot, even for recovery mode.

For TPM 2.0, it will automaticly choose the correct authorization
according to the TPMA_NV_PLATFORMCREATE attribute of that index.

BUG=chromium:895549
BRANCH=None
TEST=No test for TPM 1.2

Manually test for TPM 2.0:
1. Boot with platform hierarchy is disabled, then
  # perm: TPMA_NV_AUTHREAD | TPMA_NV_AUTHWRITE
  tpmc def 0x1020 0x10 0x40004
  tpmc getp 0x1020 # check the space exists, expect success
  tpmc undef 0x1020
2. Boot with platform hierarchy is enabled, then run
  # perm: TPMA_NV_AUTHREAD | TPMA_NV_AUTHWRITE |
  #       TPMA_NV_PLATFORMCREATE
  tpmc def 0x1020 0x1 0x40040004
  tpmc getp 0x1020 # check the space exists, expect success
  tpmc undef 0x1020

Change-Id: I1d814287fda3e7c11933eca7334fdc3ab1ebf895
Reviewed-on: https://chromium-review.googlesource.com/1298097
Commit-Ready: Meng-Huan Yu <menghuan@chromium.org>
Tested-by: Meng-Huan Yu <menghuan@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2018-11-01 02:17:43 -07:00
Mike Frysinger b6cd64b799 crossystem: automate writable desc (and display type)
A bunch of the params have '(writable)' at the end of the description
to indicate it's a writable field.  However, it's not listed on every
field.  Rather than resync all of them, automate it.  Throw in the
type for good measure.

The old display:
  hwid          = LUMPY  # Hardware ID
  dev_boot_usb  = 1      # Enable developer mode boot from USB/SD (writable)
The new display:
  hwid          = LUMPY  # [RO/str] Hardware ID
  dev_boot_usb  = 1      # [RW/int] Enable developer mode boot from USB/SD

BUG=None
TEST=`crossystem` output looks better
BRANCH=None

Change-Id: I953cf5cb78b52edeece4215c3249b79b26d36f26
Reviewed-on: https://chromium-review.googlesource.com/1224652
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-09-15 12:56:26 -07:00
Mike Frysinger 2495d9902b crossystem: fix field alignment
clear_tpm_owner_request is 23 chars now.

BUG=None
TEST=`crossystem` is aligned
BRANCH=None

Change-Id: I6d077b7311c74c51fd608281ad48b29fc6219937
Reviewed-on: https://chromium-review.googlesource.com/1218502
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-09-13 06:14:13 -07:00
Mike Frysinger 2f52ccad33 crossystem: resort param list
A bunch of these fields are slightly missorted.

BUG=None
TEST=`crossystem` is sorted
BRANCH=None

Change-Id: I9e90343f5034e7a8a2d81c9b8eeb4b1d7286f157
Reviewed-on: https://chromium-review.googlesource.com/1218503
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-09-13 06:14:09 -07:00
Ting Shen 935d60e837 Add AltOS NVRAM flags
Port CL:1009444 to ToT.
Adds (enable|disable)_alt_os_request flag for AltOS boot flow.

BRANCH=none
BUG=b:70804764
TEST=1. make runtests
     2. Manually, set and get new flags via crossystem

Change-Id: Ie7fe2620f736335f11c39cbfe37b3fdf400ff926
Reviewed-on: https://chromium-review.googlesource.com/1014840
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-08-07 01:51:13 -07:00
Tudor Brindus c239374ac3 vboot_reference: Add recoverysw_is_virtual flag to crossystem
This commit adds a flag recoverysw_is_virtual for determining whether a
device's recovery switch status (as given by recoverysw_cur) is from a
physical button or a line connected to Servo, without a physical button
(e.g. veyron_minnie).

BRANCH=none
BUG=chromium:845589
TEST=manually tested on cave and veyron_minnie; make runtests

Change-Id: If8e54e1df78b25a52dbf359ce641bea75533d705
Reviewed-on: https://chromium-review.googlesource.com/1157537
Commit-Ready: Tudor Brindus <tbrindus@chromium.org>
Tested-by: Tudor Brindus <tbrindus@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2018-08-02 21:50:16 -07:00