summaryrefslogtreecommitdiff
path: root/firmware/2lib/include/2return_codes.h
Commit message (Collapse)AuthorAgeFilesLines
* minidiag/ui: Prevent calling update action if there were no updatesstabilize-quickfix-13597.30.Bstabilize-ambassador-13597.79.Bstabilize-13597.97.Bstabilize-13597.95.Bstabilize-13597.94.Bstabilize-13597.90.Bstabilize-13597.85.Bstabilize-13597.84.Bstabilize-13597.71.Bstabilize-13597.70.Bstabilize-13597.69.Bstabilize-13597.68.Bstabilize-13597.67.Bstabilize-13597.66.Bstabilize-13597.105.Bstabilize-13597.103.Brelease-R88-13597.Bfactory-volteer-13600.BHsuan Ting Chen2020-11-121-1/+4
| | | | | | | | | | | | | | | | | Add a return code `VB2_ERROR_EX_DIAG_TEST_UPDATED` to determine if updating needed. BUG=b:168776970 BRANCH=none TEST=Build locally, boot recovery, select 'run diagnostics', enter memory test (quick) screen, and observe that the delay reduces while pressing keyboard Cq-Depend: chromium:2423699 Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org> Change-Id: I7606911bee7257e8eed4ec35d197efaa57b72e13 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2424370 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* minidiag: Add storage and memory diagnostic screensMeng-Huan Yu2020-09-101-0/+6
| | | | | | | | | | | | | | | | | BRANCH=none BUG=b:156692539, b:156693348 TEST=emerge-hatch vboot_reference TEST=unittest passed: ( export CC=x86_64-pc-linux-gnu-clang DEBUG=1 MENU_UI=1 DIAGNOSTIC_UI=1 MINIMAL=1 TPM2_MODE= MOCK_TPM=; make clean && make -j32 test_setup && make runtests; echo $? ) Cq-Depend: chromium:2322286, chromium:2328704, chromium:2336239 Cq-Depend: chromium:2361823, chromium:2361582 Signed-off-by: Meng-Huan Yu <menghuan@chromium.org> Change-Id: I8b875b09bd5bcdb65f08c11945b046d2b3c3a113 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2372022 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot/ui: Implement debug info screenHsuan Ting Chen2020-07-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Implement debug info screen with multiple pages. The debug info screen can be accessed using TAB as keyboard shortcut. The menu navigation will be added in a separate CL. The screen has one textbox for displaying one page of debug info, and three buttons: page up, page down, and back. BRANCH=puff BUG=b:146399181, b:144969088 TEST=CC=x86_64-pc-linux-gnu-clang; make clean && make runtests TEST=USE="menu_ui" emerge-nami depthcharge press tab, observe the debug info on the screen Cq-Depend: chromium:2251685 Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org> Change-Id: I6bc0a49c4d69817825f35435b643b006823b5c03 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2251868 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* host/lib: add lightweight flashrom wrapper libraryJack Rosenthal2020-06-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | 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
* vboot: create VB2_ERROR_EX_SET_VENDOR_DATAJoel Kitching2020-05-281-7/+3
| | | | | | | | | | | | | | | | | Create VB2_ERROR_EX_SET_VENDOR_DATA error code for use in VbExSetVendorData callback. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Cq-Depend: chromium:2218538 Change-Id: I9d75a608185e475837d9cb4a53b943fd2dae6438 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218537 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: move PERIPHERAL_BUSY to vboot2 namespaceJoel Kitching2020-05-281-2/+3
| | | | | | | | | | | | | | | | | Move VBERROR_PERIPHERAL_BUSY to vboot2 namespace as: VB2_ERROR_EX_AUXFW_PERIPHERAL_BUSY BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Iebc7d73e3a87a8bd4d999be56ad23d6b77d9785c Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:2158865 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2158512 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: move timer and beep functions to vboot2 namespaceJoel Kitching2020-05-281-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move these functions from vboot_api.h into 2api.h: VbExGetTimer --> vb2ex_mtime (usec -> msec) VbExSleepMs --> vb2ex_msleep VbExBeep --> vb2ex_beep Rename the constants: VB_USEC_PER_MSEC --> VB2_USEC_PER_MSEC VB_MSEC_PER_SEC --> VB2_MSEC_PER_SEC Remove the constant VB_USEC_PER_SEC. The error code VBERROR_NO_BACKGROUND_SOUND is dropped since it is not currently used. Update a few printf lines to use VB2_DEBUG instead. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I887112ffd5f68fb6a9c4d9ad624aa420cbd55b4b Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:2158665 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2158666 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: Remove reboot-related vboot1-style errorsYu-Ping Wu2020-05-051-13/+2
| | | | | | | | | | | | BRANCH=none BUG=b:124141368, chromium:988410 TEST=make runtests Cq-Depend: chromium:2154269, chromium:2175864 Change-Id: Ib3996ecc83a69ce6780d48f1aa446e81dfd75589 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2167622 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: Convert reboot-related errors to vboot2-styleYu-Ping Wu2020-04-281-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Error codes are renamed as follows: VBERROR_SHUTDOWN_REQUESTED --> VB2_REQUEST_SHUTDOWN VBERROR_REBOOT_REQUIRED --> VB2_REQUEST_REBOOT VBERROR_EC_REBOOT_TO_SWITCH_RW --> VB2_REQUEST_REBOOT_EC_SWITCH_RW VBERROR_EC_REBOOT_TO_RO_REQUIRED --> VB2_REQUEST_REBOOT_EC_TO_RO VBERROR_KEEP_LOOPING --> VB2_REQUEST_UI_CONTINUE Since these are not really "errors", they're renamed to VB2_REQUEST_* instead, with larger values to separate from real errors. The old vboot1-style errors will be removed once the errors are renamed in coreboot and depthcharge. BRANCH=none BUG=b:124141368, chromium:988410 TEST=make runtests Change-Id: Ide1328f9c0f2803534fb3f1f1ecd16ad8ea36a4e Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2143030 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: remove VBERROR_TPM_SET_BOOT_MODE_STATE error codeJoel Kitching2020-04-171-2/+0
| | | | | | | | | | | | | | | | | | | | | | Since secdata and nvdata get/set functions no longer return error codes, and instead use VB2_ASSERT and VB2_DIE to abort on failure, vb2_enable_developer_mode no longer has any error code to return. Change the function return type to void, and remove checks around the function call. As a result, VBERROR_TPM_SET_BOOT_MODE_STATE becomes unused and we may remove it. Finally, move the USB_BOOT_ON_DEV logic (enable USB boot when on transition to dev mode) into vb2_enable_developer_mode. Also add unit tests. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I286d9343c4c751ff24bf4c149a26fbe5306e383a Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2152212 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: Add VB2_ERROR_UI_MEMORY_ALLOC to vb2_error_tYu-Ping Wu2020-04-161-0/+3
| | | | | | | | | | | | | | Add VB2_ERROR_UI_MEMORY_ALLOC for memory allocation failure in UI. BRANCH=none BUG=b:146399181 TEST=emerge-nami vboot_reference Change-Id: Ib6d8ccbfe73f90297f400430b4ae1204adbf7ee4 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2152331 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: remove more unused pre-vboot1 and vboot1 error codesJoel Kitching2020-04-161-25/+0
| | | | | | | | | | | | | | BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I24c867af25726f84a4ada18477de66579975a383 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2150182 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: Add VB2_ERROR_UI_INVALID_LOCALE to vb2_error_tYu-Ping Wu2020-04-071-0/+3
| | | | | | | | | | BRANCH=none BUG=b:146399181 TEST=USE="menu_ui" emerge-nami depthcharge Change-Id: I8c0e37adc4f37900a5e426f24a581befb07c6a34 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2137152
* EFS: Implement EFS2 and NO_BOOT modeDaisuke Nojiri2020-03-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EFS v1 allowed Chromeboxes to verify RW without AP. EFS v2 will bring the benefts to Chromebooks, which are: - Reduce RO dependency and presence. Allow more code to be updated in the fields. - Remove jumptag and workarounds needed for late sysjump. Major imporvements over v1 are: - No A/B slot required. - No signature in RW or public key in RO. - Rollback-attack protection. For battery-equipped devices, additional benefts are: - Immediate boot on drained battery. - Support recovery mode regardless of battery condition. - Faster charge in S5/G3. EC-Cr50 communication is based on the shared UART (go/ec-cr50-comm). EFS2 is documented in go/ec-efs2. BUG=chromium:1020578,chromium:1045217 TEST=Boot Helios in NORMAL/RECOVERY/NO_BOOT mode. TEST=Verify EC is updated by software sync in Depthcharge. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ie07e6f6ce46c0955a6a0adf595633e65c4ffe724 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1901868
* Add vb2_secdata_kernel_v10dnojiri2020-03-051-0/+9
| | | | | | | | | | | | | This patch adds vb2_secdata_kernel_v10. It has ec_hash field to support EFS2. The secdata kernel APIs continue to support v0.2. BUG=chromium:1045217 TEST=emerge-hatch depthcharge TEST=make runtests Change-Id: I18d5097ed799e790a2742d54c25c89a7559cbcb2 Signed-off-by: dnojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2041695
* vboot: Convert more UI errors to vboot2-styleYu-Ping Wu2020-03-021-7/+9
| | | | | | | | | | | | | | | | | | | | | | Error codes are renamed as follows: VBERROR_INVALID_BMPFV --> VB2_ERROR_UI_INVALID_ARCHIVE VBERROR_NO_IMAGE_PRESENT --> VB2_ERROR_UI_MISSING_IMAGE Also remove unnecessary paddings 0x1000 for UI errors. BRANCH=none BUG=b:124141368, chromium:988410 TEST=emerge-nami depthcharge Cq-Depend: chromium:2082833 Change-Id: I8b7743d9ceecde6c9e3e88109422a99594ad6aab Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2082759 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: update vb2api_kernel_phase1 to use GBB interfaceJoel Kitching2020-02-091-2/+3
| | | | | | | | | | | | | | | | | | | | vb2api_kernel_phase1 was previously written to read the GBB headers, locate the recovery key, and then load it. GBB headers are now saved directly on workbuf in firmware phase. Simply use the vb2_gbb_read_recovery_key function to retrieve the key. Update LoadKernel to read kernel subkey from vboot2 workbuf. Update tests/verify_kernel.c to write subkey to vboot2 workbuf. BUG=b:124141368, chromium:954774, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: Ia85013da34bdab68bf486014a3401d48c95b3472 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1651221 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: Convert UI errors to vboot2-styleYu-Ping Wu2020-02-031-4/+15
| | | | | | | | | | | | | | | | | | | | | | Error codes are renamed as follows: VBERROR_INVALID_SCREEN_INDEX --> VB2_ERROR_UI_INVALID_SCREEN VBERROR_SCREEN_DRAW --> VB2_ERROR_UI_DRAW_FAILURE In addition, add new error code VB2_ERROR_UI_DISPLAY_INIT. BRANCH=none BUG=none TEST=emerge-nami depthcharge Cq-Depend: chromium:2002310 Change-Id: I1381762fbe1a9bb0c76e7e7d64a0732799c3bf0f Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2002309 Reviewed-by: Joel Kitching <kitching@chromium.org>
* 2sha: Add a vb2_hash type to make it easier to work with hashesJulius Werner2020-01-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | I'm prototyping some coreboot code to closer integrate vboot with CBFS (per-file hashing and that stuff). While doing that, I noticed that it would be neat to have a standardized serializable representation for any kind of vboot hash. We already have something like that in CBFS attributes, but if we want to use it more generally it makes more sense to put it in vboot. This patch adds a suitable structure defintion to 2sha.h and two utility functions that can be used to work with it. Also add alloca() because I need it and fix the return types of vb2_..._size(), because those are just plain wrong. BRANCH=None BUG=None TEST=make runtests Change-Id: I4b535ad43704693463fb114d6a81d2b5689a87b9 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1963614 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: fix up some host key functions for host_key2.cfactory-excelsior-12812.BJoel Kitching2019-12-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* vboot: migrate GBB-related error handling to vboot2Joel Kitching2019-12-061-2/+0
| | | | | | | | | | | | | | | | Pass on values returned from vb2_gbb_* functions instead of using VBERROR_INVALID_GBB on error. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I66b99393f0fcc9eabe629d08b35247764cfbcefb Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728296 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: convert LoadKernel and TryLoadKernel to vboot2-style errorsJoel Kitching2019-12-061-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert LoadKernel and TryLoadKernel to use vboot2-style error codes. Error codes are renamed as follows: VBERROR_NO_KERNEL_FOUND --> VB2_ERROR_LK_NO_KERNEL_FOUND VBERROR_INVALID_KERNEL_FOUND --> VB2_ERROR_LK_INVALID_KERNEL_FOUND VBERROR_NO_DISK_FOUND --> VB2_ERROR_LK_NO_DISK_FOUND Remove these error codes: VBERROR_LOAD_KERNEL_RECOVERY Remove VBSD_BOOT_DEV_SWITCH_ON check in vb2_developer_ui to align vboot_ui and vboot_ui_menu functionality. VBERROR_LOAD_KERNEL Unused. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I90389c6629cc6055c4a4acbbbdd358bb79b63bf7 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728297 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot/secdata: rewrite rollback_index and centralize reads/writesJoel Kitching2019-11-281-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In current kernel verification code, secdata reads and writes are spread throughout the code. vboot2's design is to use vb2_context.secdata_* for storing the state of secdata spaces, and have the caller (depthcharge) read/save this field when necessary. Centralize secdata reads/writes into the functions of secdata_tpm.c, previously known as rollback_index.c. Functions which directly read/write to the TPM space are modified to use vb2_secdata_*_get and vb2_secdata_*_set. The secure spaces get read/flushed by functions in vboot_api_kernel.c. These calls and the underlying functions from secdata_tpm.c will eventually be relocated to depthcharge. Create a new external function vb2ex_commit_data, which commits any modified nvdata/secdata. Currently the depthcharge implementation of this function only writes nvdata, but once secdata TPM drivers have been migrated from vboot_reference to depthcharge, it will also commit these data spaces. This CL also removes the VbExNvStorageRead call from vb2_kernel_setup, and the data is instead read in depthcharge CL:1819379, right before calling VbSelectAndLoadKernel. As such, both the VbExNvStorageRead and VbExNvStorageWrite functions may be removed. Finally, create a vb2_secdata_kernel_lock function, which should be used right before attempting to leave vboot (by booting an OS or chainloading to another firmware). This should eventually be exposed as a vb2ex_ API function and relocated to depthcharge. BUG=b:124141368, chromium:972956, chromium:1006689 TEST=make clean && make runtests BRANCH=none Change-Id: Ifbfb21122af0bf85e22a6d3a0d48a1db7f7c25b7 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1819380, chromium:1939168 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728298 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: add errors for nvdata read/write failuresJoel Kitching2019-11-251-0/+6
| | | | | | | | | | | | | BUG=b:124141368, chromium:1006689 TEST=make clean && make runtests BRANCH=none Change-Id: Ieb47f54f665299b5377077c8975611ba3e1b8dc9 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1921775 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: move vb2_context inside vb2_shared_data (persistent context)Joel Kitching2019-11-131-4/+7
| | | | | | | | | | | | | | | | | | | | | 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>
* vboot: merge pre-vboot1 error codes into vb2_return_codeJoel Kitching2019-10-231-0/+13
| | | | | | | | | | | | | | | | | | Since these pre-historic functions have already been updated to return vb2_error_t values, their error codes should be merged into vb2_return_code just like was done for vboot1 error codes in CL:1722913. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I5c64eca088a5f130fa5b420f94c85d04955948d2 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776292 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: update secdata accessors to match those of FWMPJoel Kitching2019-10-211-20/+30
| | | | | | | | | | | | | | | Instead of returning vb2_error_t, use VB2_DIE to exit on error. BUG=b:124141368, chromium:972956, chromium:1006689, TEST=make clean && make runtests BRANCH=none Change-Id: I9497eebb0b8815734fdf875ba4f9ef5eda5e82fd Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1833365 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: fix up some more includesJoel Kitching2019-09-231-0/+2
| | | | | | | | | | | | | | | | 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/secdata: implement vboot2 FWMP supportJoel Kitching2019-09-231-0/+12
| | | | | | | | | | | | | | | | | | | | | | Implement FWMP support in vboot2. Currently, the data structure is just accessed directly, checking to see whether its `flags` member contains particular flags. We'd like to change this to follow the same scheme as secdata_firmware and secdata_kernel. This CL also updates some functions, comments, and tests related to secdata_firmware and secdata_kernel to ensure consistency between code for the secdata spaces. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: Ia0d67532cc6e077e170ffb25d0bc587b1d53edf3 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1773088 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: rename secdata and secdatakJoel Kitching2019-08-311-30/+30
| | | | | | | | | | | | | | | | | | | | | | | For clarity's sake, rename: secdata -> secdata_firmware secdatak -> secdata_kernel secdata is now the general term to refer to any secure data spaces: firmware, kernel, and FWMP. Once coreboot code has been updated, the sections in 2api.h and 2constants.h may be removed. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I376acee552e8be37c75c340626a95462f81e198b Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1773079 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: fix up some headers, includes, comments, spacingJoel Kitching2019-08-281-3/+3
| | | | | | | | | | | | | 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/secdata: fix up 2secdata{,k} and testsJoel Kitching2019-08-281-2/+2
| | | | | | | | | | | | | | | | These are not yet used in production and need some fixing up first. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: Ifbd0e761cc5bc05437bfed774fb15d5e8ef1b8e7 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758149 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove unused and deprecated vboot1 error codesfirmware-mistral-12422.BJoel Kitching2019-08-131-33/+1
| | | | | | | | | | | | | BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I59b5646a79769cb9fafdecd904021a5df85906b6 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728295 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace VBERROR_INVALID_PARAMETER with vboot2 equivalentJoel Kitching2019-08-131-2/+0
| | | | | | | | | | | | | | | | | Replace vboot1-style VBERROR_INVALID_PARAMETER with vboot2 equivalent VB2_ERROR_INVALID_PARAMETER. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I46227cd3a7d7ce84654a0093f9d64883c9563381 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728116 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728294 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace VBERROR_SIMULATED with VB2_ERROR_MOCKJoel Kitching2019-08-131-2/+0
| | | | | | | | | | | | | | | Replace vboot1-style VBERROR_SIMULATED with VB2_ERROR_MOCK. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I9f7a21b957097672883a428a5210c14a27852085 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722917 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace VBERROR_UNKNOWN with VB2_ERROR_UNKNOWNJoel Kitching2019-08-131-2/+0
| | | | | | | | | | | | | | | | Replace vboot1-style VBERROR_UNKNOWN with VB2_ERROR_UNKNOWN. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Icd2158e328142cff69ce94b5396ab021a1f7839c Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728115 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722916 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace VBERROR_SUCCESS with VB2_SUCCESSJoel Kitching2019-08-131-3/+0
| | | | | | | | | | | | | | | | | 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>
* vboot: rename VbError_t typedef to vb2_error_tJoel Kitching2019-08-061-0/+6
| | | | | | | | | | | | | | | | | | | | | | 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>
* vboot: join vboot1 and vboot2 errors into same enumJoel Kitching2019-08-061-0/+97
| | | | | | | | | | | | | | | | | | | | It's extremely hard to accomplish anything with two different sets of error codes. Since the two error code sets don't overlap, merge them into the same enum (vb2_return_code). The next step is to get rid of VbError_t and have all functions consistently return vboot2-style int. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Ie34ac2c30e5d73fe886628e3150cf63543d520af Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728117, chromium:1735666 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722913 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: expose vb2api_secdatak_check and vb2api_secdatak_createJoel Kitching2019-06-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | Previously vb2api_secdatak_check and vb2api_secdatak_create had headers in 2api.h, but no definitions. Merge identical internal/external functions: vb2api_secdata_create, vb2_secdata_create_crc vb2api_secdata_check, vb2_secdata_check_crc vb2api_secdatak_create, vb2_secdatak_create_crc vb2api_secdatak_check, vb2_secdatak_check_crc BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I64a14d65e5d856ca0f819ef3ded50b4719abc8b3 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1652874 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* vboot: rewrite GBB functions and APIJoel Kitching2019-06-071-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Old vboot1-style GBB accessor functions were awkwardly located within region-init.c. Rewrite GBB accessor functions for vboot2, and formally expose HWID retrieval function via vboot2 API. workbuf is used for key retrieval functions, while a buffer provided by the caller is used for HWID retrieval function. Reintroduce vboot_display_tests to `make runtests` test suite. Move GBB tests from vboot_display_tests to vb2_gbb_tests. Properly propagate vb2_workbuf objects within the function call stack (vb2_load_partition). BUG=b:124141368, chromium:954774 TEST=Build and flash to eve, check that Chrome OS boots TEST=Build with CL:1627469 applied, check HWID TEST=make clean && make runtests BRANCH=none Change-Id: I398d1329f0b092de35aac73d98dfd9aee6e4e7de Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1584488 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Jason Clinton <jclinton@chromium.org>
* vboot: add magic and version to vb2_shared_dataJoel Kitching2019-04-151-0/+6
| | | | | | | | | | | | | | | | | | | | In order for vb2_shared_data to cross application boundaries, it needs magic and version fields. These can be initialized in vb2_init_context, which is called implicitly via vb2api_fw_phase1 and vb2api_fail. On re-init, check fields for validity. BUG=b:124141368, b:124192753 TEST=make clean && make runtests BRANCH=none Change-Id: I90005833836f13f60813bdf82f0e4dbb8d9afecd Reviewed-on: https://chromium-review.googlesource.com/1521406 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* 2lib: create generic return code for unimplemented external functionsJoel Kitching2019-03-281-4/+9
| | | | | | | | | | | | | | | | | | vboot_reference has a set of "external" functions which are defined by the client and linked in at compile time. Instead of creating a separate return code for each unimplemented external function, group them all into one. BUG=chromium:944804 TEST=make clean && make runtests BRANCH=None Change-Id: Ic3896572c71aabf99590758c7fc3848b61f9e078 Reviewed-on: https://chromium-review.googlesource.com/1539433 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>
* 2api: add callback for vb2ex_tpm_set_modeMatt Delco2019-03-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | Add vboot2 callback for tpm_set_mode. This is mostly a cherry-pick of these: https://chromium-review.googlesource.com/c/1354139 https://chromium-review.googlesource.com/c/1365293 The re-enable of the tpm is now performed by coreboot so this version doesn't implement tpm_get_mode. BUG=b:124358784 BRANCH=None TEST=compile vboot_reference and depthcharge CQ-DEPEND=CL:1471195 Change-Id: I4168b50650e22f35ad9c66d49f34b689c46a36e1 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1470962 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* vboot: bulk fix tabs and spacing inconsistencyJoel Kitching2018-08-031-18/+18
| | | | | | | | | | | | | | | | | | | Problem files were found with: find . -name '*.c' -o -name '*.h' | xargs grep '^ [^*]' and edited manually. Ignores utility/ and cgpt/, since they seem to globally adhere to a two-space tab convention. BUG=None TEST=make clean runtests TEST=emerge vboot_reference depthcharge Change-Id: I5a678484a119c8f1911f717e1968bdb4f1a0810f Reviewed-on: https://chromium-review.googlesource.com/1160131 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* firmware: Refactor and clean up ec_syncChromeOS Developer2017-01-121-0/+9
| | | | | | | | | | | | | | | | | | | | Previously, the EC software sync process called VbDisplayScreen() from several function calls deep. Refactor software sync so that the UI decisions are at a higher level (in ec_sync_all.c) and isolated from the low-level EC software sync functionality (in ec_sync.c). This is one in a series of changes which are more clearly separating out the UI, to make it easier to support multiple UI across a range of devices. BUG=chromium:611535 BRANCH=none TEST=make runtests; build_packages --board=reef chromeos-firmware; boot reef Change-Id: I40597abeb5b0cc8f5d8fc2098e4acbed4bf59bf6 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/411921 Reviewed-by: Shelley Chen <shchen@chromium.org>
* vboot: Split partition and vblock verification from LoadKernel()stabilize-8992.BRandall Spangler2016-11-141-0/+42
| | | | | | | | | | | | | | | | | | | LoadKernel() was a big function which did everything from looping over partitions on a drive to loading the data within them to calling the low-level verification functions on that data. Split it apart into more manageable chunks. This also reduces indentation of the inner parts of the code, whic increases readability. No outwardly-visible functionality changes. BUG=chromium:611535 BRANCH=none TEST=make runtests; emerge-kevin coreboot depthcharge Change-Id: Iea79e70163f5d9f1a9d0d897e4a9bacc925a742d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/404919 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot: Add vb2_unpack_key_bufferRandall Spangler2016-11-061-6/+9
| | | | | | | | | | | | | | | | | Previously, vb2_unpack_key() actually unpacked a key buffer. Callers that had a vb2_packed_key had to typecast it back to a uint8_t buffer to unpack it. Rename vb2_unpack_key() to vb2_unpack_key_buffer(), and make vb2_unpack_key() unpack a vb2_packed_key. BUG=chromium:611535 BRANCH=none TEST=make runtests; emerge-kevin coreboot depthcharge; emerge-samus and boot it Change-Id: I9ee38a819c59cc58a72ead78cf5ddf3d0f301ae7 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/400906 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tests: Fix coverity warningsRandall Spangler2016-09-151-0/+8
| | | | | | | | | | | | | | Assorted minor code issues, which we should fix so any new errors stand out more. BUG=chromium:643769 BRANCH=none TEST=make runtests Change-Id: I927571f8a30794c70228506afe4da3eda86f765b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/383953 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* futility: Use vboot 2.0 APIs for public keysRandall Spangler2016-09-021-0/+6
| | | | | | | | | | | | | | This replaces calls to the old vboot 1 APIs with their vboot 2.0 equivalents. BUG=chromium:611535 BRANCH=none TEST=make runtests Change-Id: Ieb1a127577c6428c47ac088c3aaa0d0dad6275a8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356541 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>