summaryrefslogtreecommitdiff
path: root/host/lib
Commit message (Collapse)AuthorAgeFilesLines
* host/lib/subprocess: replace constructor function & perror with VB2_DEBUGJack Rosenthal2020-06-181-13/+3
| | | | | | | | | | | | | | | | | | | | Currently this had perror to print the error message, but we can get rid of this and the constructor function reasonably if we switch to VB2_DEBUG. This was changed since the Loonix team cannot rely on glibc-specific behaviors, and passing argv to constructor functions is glibc-specific. See the notes on cl/316913250 for a little bit of background. BUG=none BRANCH=none TEST=unit tests Change-Id: I5de76306d5a8615fdc3afcfb772a2eb32557aa87 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2251039 Reviewed-by: Joel Kitching <kitching@chromium.org>
* host/lib/flashrom: enable --fast-verify for write operationsJack Rosenthal2020-06-161-0/+1
| | | | | | | | | | | | | | | | | | | We caused a boot-speed regression as we are currently verifying the entire flash chip after any write. Flashrom has an option --fast-verify which verifies only the region written, which is significantly faster. It also looks like this is the way mosys used to handle flashrom writes, so we can align with the old behavior this way. BUG=chromium:1091903 BRANCH=none TEST=unit tests, and boot speed regression went away (on octopus) Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: If8d2288cb0c08e8644b6e05f7b174c3c21542f94 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2242738 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: rename USB to more accurate EXTERNALYu-Ping Wu2020-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* crossystem: add functions to read and write VBNV via flashromJack Rosenthal2020-06-091-0/+102
| | | | | | | | | | | | | | | | | | | | This will replace the usage of "mosys nvram vboot {read,write}" on x86 platforms, and all ARM platforms except veyron (chromebooks only) and nyan_kitty (which use VBNV storage in the ChromeOS EC, deprecated for new platforms). These affected ARM devices will be going AUE sometime this summer, and we can expect to remove the mosys usage in crossystem later this year. The code to find the active VBNV in SPI flash was modeled to match the logic in mosys (see mosys/lib/vbnv/vbnv_flash.c). BUG=chromium:1032351,chromium:1030473,chromium:789276 BRANCH=none TEST=provided unit tests Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I4f42af2f9a6b0703302635f8d8ebb2d7599d9847 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218889
* host/lib: add lightweight flashrom wrapper libraryJack Rosenthal2020-06-092-0/+208
| | | | | | | | | | | | | | | | | | | | | | Lightweight wrapper around flashrom, exposing two APIs: flashrom_read(programmer, region, data_out, size_out) flashrom_write(programmer, region, data, size) |region| can be NULL, in which case operate on the whole flash chip. The intended usage of this wrapper library is to read/write VBNV from SPI flash directly, avoiding the call thru mosys (which has deprecated the command). Bringing this logic into crossystem directly will also help with expanding VBNV to 64-bytes. BUG=chromium:1032351,chromium:1030473,chromium:789276 BRANCH=none TEST=provided unit tests Change-Id: I3997bd03a2db7e58e4e76fc200c637dd3b5b20a4 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218888
* Rewrite algorithm type parsers and make them globally availableJulius Werner2020-04-062-0/+45
| | | | | | | | | | | | | | | | | | | | | 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>
* vboot: stop using StrnAppend and Uint64ToStringJoel Kitching2020-03-315-5/+0
| | | | | | | | | | | | | | | | | | | 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>
* host: add host library for accessing chromeos-configrelease-R82-12974.BJack Rosenthal2020-03-132-0/+164
| | | | | | | | | | | | | | | | | | | | Host side library for accessing chromeos-config. Initially, this will be used by futility to access the /firmware:image-name property during a firmware update. More background: go/mosys-firmware-name (note: despite the name "mosys" in the design doc, this is an effort to *not* rely on mosys during the firmware update) BUG=chromium:1061192 BRANCH=none TEST=provided unit tests Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ib8e5f8f836a93695e3b30731ae227501f37c4633 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2099449 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: stop using wpsw_boot and remove it from crossystemJoel Kitching2020-02-271-2/+0
| | | | | | | | | | | | | | | | | | 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>
* vboot: clean up vboot_struct.hJoel Kitching2020-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | It only needs to contain VbSharedDataHeader definition, and it can be made private to vboot_reference now. Move kernel verification-related structs to vboot_kernel.h. Also, since the related constants VBSD_LF_CHECK_* are being removed in this CL, deprecate the RO_INVALID_RW_CHECK_MIN recovery reason, which was originally dismantled in CL:1863624. BUG=b:124141368, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: Ie6937cda6c3ba987031ba770ec9f1fb0ffa9cf3a Cq-Depend: chromium:2070292, chromium:2073461, chrome-internal:2634199 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2066302 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem: use wpsw_boot as fallback for wpsw_curJoel Kitching2020-02-261-0/+3
| | | | | | | | | | | | | | | | | | | In preparation for deprecating wpsw_boot, update wpsw_cur to use wpsw_boot as a fallback value. The source of wpsw_boot will still be deprecated on devices using new firmware, but in those cases, we are absolutely certain that wpsw_cur will work. BUG=b:124141368, chromium:950723 TEST=make clean && make runtests BRANCH=none Change-Id: I77ab9c6b827ef2c033ae46b7b01b12465101c0a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2071633 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: unmarry LoadKernel from VBSDJoel Kitching2020-02-141-104/+3
| | | | | | | | | | | | | | | | 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>
* vboot: move vboot 2.1 functions and structs into host codeJoel Kitching2020-02-119-9/+54
| | | | | | | | | | | | | | | | | | 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>
* vboot/crossystem: Deprecate recoverysw_is_virtualYu-Ping Wu2020-02-061-9/+0
| | | | | | | | | | | | | | | | | | | | | | 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>
* Reland: Clean up implicit fall through.Manoj Gupta2020-02-011-1/+1
| | | | | | | | | | | | | | | | 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>
* vboot: fix up some host key functions for host_key2.cfactory-excelsior-12812.BJoel Kitching2019-12-253-45/+23
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib/subprocess: add callback feature to the subprocess libraryJack Rosenthal2019-12-112-33/+141
| | | | | | | | | | | | | | | | | | For the libflashrom-compatible interface I'm working on, I needed the ability to process data from the flashrom subprocess in a callback function. This adds a new type of subprocess_target, TARGET_CALLBACK, which can read and write to/from a callback function. BUG=chromium:478356 BRANCH=none TEST=provided unit tests Change-Id: I20b71000fc2b6b297a8617d2b03d0e91813007d1 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1959944 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: merge vb2_struct.h into 2struct.hJoel Kitching2019-12-103-6/+4
| | | | | | | | | | | | | | | 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>
* lib/subprocess: style updatesstabilize-12748.BJack Rosenthal2019-12-102-19/+24
| | | | | | | | | | | | | | | Just resolving some style comments left on CL:1955805. The CL merged by CQ before I noticed the comments. BUG=none BRANCH=none TEST=compiles Change-Id: I286343e3ee2ecb4cb6092ca99fa46c4a80442e03 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1957760 Tested-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: change mosys calls to use the subprocess libraryJack Rosenthal2019-12-101-70/+17
| | | | | | | | | | | | | | | The new subprocess_run library function provides a unit-tested way to call subprocesses and collect output. BUG=chromium:1030473 BRANCH=none TEST=On drallion and druwl, crossystem works for both reading and writing Change-Id: I072d91cf68ee91c663652d2c0433ef8bbedad7d7 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1955806 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* host/lib: add a subprocess libraryJack Rosenthal2019-12-072-0/+347
| | | | | | | | | | | | | | | | | | | This is a powerful library for interacting with processes. We'll be able to clean up much of the code which manually sets up the pipes and calls exec* with this well-tested and expressive abstraction. This code will initially be used in crossystem for calling out to flashrom instead of relying on mosys. BUG=chromium:1030473 BRANCH=none TEST=provided unit tests Change-Id: I56f28419406d0b1299bb91058dd4500079b2435e Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1955805 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: remove unnecessary vboot_common.h includesJoel Kitching2019-12-067-7/+0
| | | | | | | | | | | | | 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>
* crossystem: drop support for AndroidJack Rosenthal2019-12-041-28/+4
| | | | | | | | | | | | | | This was for the Ryu project, which was cancelled (at least for CrOS). It's safe to assume crossystem will never be used on Android. BUG=chromium:990438 BRANCH=none TEST=crossystem still functions on samus Change-Id: Ide5b4ad105e9f36972067c125176ae5a08444ceb Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1949427 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* crossystem: Add a fake workbuffer for the fake contextJulius Werner2019-11-141-14/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | crossystem functions just make up a fake vb2_context for calling into things like vb2_nv_init(), but that function actually accesses vb2_shared_data as well. This used to work because vb2_get_sd() would return NULL in that case and vb2_nv_init() actually checks for that, but with the persistent context model this is no longer possible and making up directly allocated contexts is always illegal. This patch adds a small fake workbuffer to the fake context so we can have real backing storage for shared data. (This might not be the final way we want to fix it but should work as a quick band-aid over the crashes.) Also remove the now pointless (sd == NULL) checks from vb2_nv_init(). BRANCH=None BUG=chromium:1024732 TEST=make runtests Change-Id: I91247013f092bbfc41cf1974b82cf70a29fa4734 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1917486 Tested-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Brian Norris <briannorris@chromium.org>
* vboot: align workbuf to VB2_WORKBUF_ALIGNJoel Kitching2019-11-131-1/+2
| | | | | | | | | | | | | | | 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>
* Revert "Clean up implicit fall through."Mathew King2019-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6a703f5b0edfdbf2eee72d59499f73585262a46f. 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>
* Clean up implicit fall through.Manoj Gupta2019-11-051-1/+1
| | | | | | | | | | | | | | | | 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>
* vboot: keep const and non-const signature and key accessorsJoel Kitching2019-10-293-8/+9
| | | | | | | | | | | | | | | | | | | | | Keep const (default) and non-const (_mutable suffix) versions of `data` field accessors for vb2_signature and vb2_packed_key. No need for separate 2packed_key.c file -- just static inline the functions. vb2_verify_packed_key_inside should return type vb2_error_t. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I96722a746f26abbb6e19a365ce74f0bfda0da381 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1786386 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: use inline instead of __inlineJoel Kitching2019-10-231-1/+1
| | | | | | | | | | | | | | | | Use official inline keyword instead of compiler-specific __inline. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ica2b2bd5f2af5188209dad6b5ba6f317b8229b99 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1872252 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: relocate vb2_signature and vb2_keybock structsJoel Kitching2019-10-231-6/+6
| | | | | | | | | | | | | | | Move from vboot20 to vboot2. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: Ib1fe0e2cfb0865fffe33ad35e7bd67d416da4589 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776291 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: standardize on "keyblock" as one wordJoel Kitching2019-10-232-13/+13
| | | | | | | | | | | | | | | | 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>
* vboot: remove timers from VbSelectAndLoadKernel and crossystemJoel Kitching2019-10-231-16/+1
| | | | | | | | | | | | | | | | 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>
* vboot: format hex numbers with %#x instead of 0x%xJoel Kitching2019-10-231-1/+1
| | | | | | | | | | | | | | | | 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>
* vboot: deprecate legacy vboot1 FWB_TRIED flagJoel Kitching2019-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | vboot1 FWB_TRIED flag is unused and replaced by vboot2 TRY_COUNT. Remove related test cases. Rewrite a special case for preventing kernel version roll-forward with combined firmware+kernel updates. BUG=b:124141368, chromium:1010389, b:35575422 TEST=make clean && make runtests BRANCH=none Change-Id: I9300def8bb426868b5e4d687d9c86e85c0c9b2c0 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1833369 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: fix up some more includesJoel Kitching2019-09-2311-20/+14
| | | | | | | | | | | | | | | | 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>
* vboot: deprecate fastboot supportJoel Kitching2019-08-301-10/+0
| | | | | | | | | | | | | BUG=b:124141368, chromium:995172 TEST=make clean && make runtests BRANCH=none Change-Id: I42e4ac8a21ac3be416d315a8a8cc914f997bab79 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758148 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* Fix fall through warning reported by ToT clang.Manoj Gupta2019-08-281-0/+1
| | | | | | | | | | | | | | | | | | | | Clang is diagnosing implicit fallthrough in C code past https://reviews.llvm.org/rL369414. Detect the support for the fallthrough attributes in gcc/clang and enable it as VBOOT_FALLTHROUGH (copied from boringssl). This is needed to fix ToT clang builds. Note: GCC apparently does not diagnose fallthrough to another case with break but clang does (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432). And clang does not detect the fallthrough based on code comments. Bug: chromium:997709 Test: CQ Change-Id: Id8b4be4deabca2d0f1b2efd80efa72a485a5dc8c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1772474 Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@chromium.org> Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
* host/lib/crossystem: free SharedData when leaving contextPatrick Georgi2019-08-281-3/+17
| | | | | | | | | | | | | | | Minor leak avoidance as identified by Coverity Scan. BUG=none BRANCH=none TEST=none Change-Id: I4e1d0f8c7eeaf12c5cf52fb94bdcf4ed7fef3224 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1771970 Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org>
* vboot: fix up some headers, includes, comments, spacingJoel Kitching2019-08-283-8/+6
| | | | | | | | | | | | | 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>
* vboot: update vboot2 functions to use new vb2_error_tJoel Kitching2019-08-1310-46/+43
| | | | | | | | | | | | | | | | | | To make explicit when vboot2 error codes should be returned, use the new vb2_error_t type on all functions which return VB2_ERROR_* constants. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Idd3ee8afe8c78347783ce5fa829cb78f1e5719e2 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728113, chromium:1728499 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728292 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: deprecate VbExError functionJoel Kitching2019-07-241-3/+3
| | | | | | | | | | | | | | | | Convert uses of this function to call VB2_DEBUG and manually exit if necessary. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I9006b1a9c66645757d33310d96207233b88eaed5 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1710340 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: remove vboot1 version of ARRAY_SIZE macroJoel Kitching2019-06-261-1/+1
| | | | | | | | | | | | | | | | Macro already exists in vboot2-style 2common.h. Relocate tests accordingly. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I6b96627a05e8c05ff49b8780fe4472890c2a2043 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675869 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: move vb2_packed_key and several functions from lib20 to 2libJoel Kitching2019-06-071-0/+2
| | | | | | | | | | | | | | | | | | | * Move vb2_packed_key from vb2_struct.h to 2struct.h * Move vb2_verify_member_inside from lib20/common.c to 2common.c * Move vb2_packed_key_data and vb2_verify_packed_key_inside from lib20/packed_key.c to 2packed_key.c * Relocate tests accordingly BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I6a9338ffdb640aad071941c3768427e15cd2aa93 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1642773 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: update display init to use vboot2 codeJoel Kitching2019-05-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* vboot: deprecate Alt OS codeJoel Kitching2019-05-141-13/+0
| | | | | | | | | | | | | | BUG=b:124141368, b:131663912 TEST=make clean && make runtests BRANCH=none Change-Id: I6aae5683b8306eede4388ff5ed6665e7769756dc Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1588026 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> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* Makefile: Enable more warnings for host utilities / testsJulius Werner2019-05-142-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* vboot/crossystem: deprecate devsw_virtualJoel Kitching2019-03-261-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | As part of chromium:942901, physical dev switch functionality is being deprecated. There is no longer any need to provide devsw_virtual flag in crossystem. BUG=b:124141368, b:124192753, chromium:942901 TEST=Build locally TEST=/work/vboot/src/repohooks/pre-upload.py TEST=make clean && make runtests TEST=make clean && COV=1 make coverage && make coverage_html TEST=Check for references to devsw_virtual in code search BRANCH=none Change-Id: Id80ec1de8c43909ce2ff661744622d2ea36030a6 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1526069 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: allocate nvram bit for diagnostic modeMatt Delco2019-03-201-0/+4
| | | | | | | | | | | | | | | | 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>
* vboot: move general constants to a separate headerJoel Kitching2019-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | coreboot uses the C preprocessor on its linker scripts to allow evaluation of macros when defining memory layout. Move constants from 2api.h to an independent file in order to allow for coreboot to use these constants in its memlayout file, without needing to include the entire vboot API. Note this commit creates two new header files: - firmware/2lib/include/2constants.h: contains the constants - firmware/include/vb2_constants.h: externally importable header Also, rename VB2_WORKBUF_RECOMMENDED_SIZE to VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE for clarity. BUG=b:124141368, b:124192753 TEST=Build locally TEST=/work/vboot/src/repohooks/pre-upload.py TEST=make clean && make runtests TEST=make clean && COV=1 make coverage && make coverage_html BRANCH=none Change-Id: Id17c6955b67e51cb048b10b4be0901c0e9110a1f Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1504490 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* futility: updater: Preserve all sections with FMAP_AREA_PRESERVE setHung-Te Lin2019-03-051-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many projects started their initial builds without knowing that some sections must be preserved when being updated. This may be solved by adding section name to 'preserved' list in firmware updater (for instance, CL:1239797), or include that section as sub area of {RO,RW}_PRESERVE. However, there are problems in both solutions. For example, installing an older image will run old updater, which will not preserve the new names. Also, if there are multiple sections must be preserved (and not contiguous - see CL:1493629) there will be problems. Additionally, changing FMAP layout usually causes more problems. As a result, adding the description in FMAP area would be the better idea. A new FMAP_AREA_PRESERVE suggests firmware updater to preserve a section if possible. In Coreboot, this can be easily set in *.fmd using flag (PRESERVE). See https://review.coreboot.org/31709 for example. BUG=chromium:936768 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ie56f65dd418faa97ffb78b1acff613e7d7e268b8 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1495054 Reviewed-by: Julius Werner <jwerner@chromium.org>