summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* vboot: translate recovery reason info from vboot 2->1Joel Kitching2020-01-211-4/+4
| | | | | | | | | | | | | | | | | | | Recovery reason should be passed into vboot kernel verification API using vboot 2 data structures. Upon arrival, translate to vboot 1 data structures for legacy purposes. Also switch to using vboot 2 recovery_reason field in other parts of vboot code. BUG=b:124141368, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: Ic590db46d57ffbd8829f8f3ad784ea46184ceabc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2008534 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* vboot: Set VBSD_EC_SOFTWARE_SYNC flag in vbootYu-Ping Wu2020-01-201-4/+4
| | | | | | | | | | | | | | | | With CL:1988245, vb2_context flag VB2_CONTEXT_EC_SYNC_SUPPORTED is set in depthcharge. Set VBSD_EC_SOFTWARE_SYNC in shared data based on the presence of VB2_CONTEXT_EC_SYNC_SUPPORTED. BRANCH=none BUG=chromium:1038259, chromium:1042135 TEST=FEATURES=test emerge-nami vboot_reference Cq-Depend: chromium:1988245 Change-Id: Ia1dd57858234bbc43f25517f416b7506c1b7919a Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1988246 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: deprecate EC_EFS and EC_SYNC_SLOW flagsJoel Kitching2020-01-171-32/+32
| | | | | | | | | | | | | | | | | The vboot 1 flags are not used in userspace, so they may be deprecated. The vboot 2 flags are converted to use compile-time options instead. BUG=b:124141368, chromium:1038259 TEST=make clean && make runtests BRANCH=none Change-Id: I0bd63a6f4dd0f29d416beacb966c99b16b5efabd Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2004256 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* Auxfw sync: Remove dependency on EC syncTim Wawrzynczak2020-01-161-4/+4
| | | | | | | | | | | | | | | | Auxfw sync used to be guarded by both VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC and VB2_CONTEXT_EC_SYNC_SUPPORTED. Now that the EC and AUXFW sync are fully decoupled, there are scenarios where it may make sense to do auxfw sync independent of EC sync, such as early bringup. BUG=chromium:1041879 BRANCH=none TEST=make runtests Change-Id: I07948b0317119231ec0287d663a3d8b92259fd6b Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2004942 Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests/vb2_firmware_tests: Improve workbuffer usage testJulius Werner2020-01-163-36/+89
| | | | | | | | | | | | | | | | | | | | | | | This patch changes vb2_firmware_tests to run multiple times with different combinations of signature and hash algorithms. The goal is to have more confidence that our recommended work buffer size is still big enough even if we changed algorithm combinations in an RW update. It also changes the underlying vb20_verify_fw to not just print the amount of work buffer used at the end, but to detect the actual high water mark of work buffer used during the test. Also add some fallback definitions for undefined environment variables to tests/common.sh which helps running individual test scripts without the Makefile harness. BRANCH=None BUG=None TEST=make runtests Change-Id: I14519cd7c76a9886bd11ebf5312458ab658e6f75 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1967976 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/+115
| | | | | | | | | | | | | | | | | | | | | | 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 kernel tests: Refactored vendor-data-specific testsPranay Shoroff2020-01-141-50/+56
| | | | | | | | | | | | | | | No additional features added, simply moved tests relating to setting vendor data to a separate function BUG=b:138812835 BRANCH=none TEST=Run 'FEATURES=test emerge-drallion vboot_reference' and verify tests run Change-Id: Ib9c1d32a4cd149c0e5eb464b7f9b4b17839c42d3 Signed-off-by: Pranay Shoroff <pshoroff@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1999043 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: remove VBSD from tests that don't need itJoel Kitching2020-01-116-25/+0
| | | | | | | | | | | | | | | Also clean up a few lines setting unneeded flags and fields in tests, and add conditionals to check for VBSD in vboot_display.c. BUG=b:124141368, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: I84438d00777516354529b1e6ee4d04f7947ff971 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1992856 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: use vboot 2 flags for checking rec/dev modeJoel Kitching2020-01-103-31/+31
| | | | | | | | | | | | | | | | | | Use vboot 2 flags for checking whether dev mode is enabled, and whether manual recovery was requested. VBSD_BOOT_DEV_SWITCH_ON --> VB2_SD_FLAG_DEV_MODE_ENABLED VBSD_BOOT_REC_SWITCH_ON --> VB2_SD_FLAG_MANUAL_RECOVERY BUG=b:124141368, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: Idb439f658391f46170704a0fd614853054e1c64d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1992852 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: fix up some host key functions for host_key2.cfactory-excelsior-12812.BJoel Kitching2019-12-253-26/+20
| | | | | | | | | | | | | | | | | | | | | | | | | 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: fold lib20/common.c into 2lib/2common.cJoel Kitching2019-12-243-29/+0
| | | | | | | | | | | | | | | Also rename tests. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: Ic79e7bc233ab93283d2be78ca9a08322b317d11d Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844600 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: change USB_BOOT_ON_DEV to use build flagJoel Kitching2019-12-241-0/+2
| | | | | | | | | | | | | | | | | | | | | Instead of calling VbExGetSwitches to essentially retrieve a compile-time config value from depthcharge, send this config value to vboot_reference as a build flag. Add a test based on the value of USB_BOOT_ON_DEV. BUG=b:124141368, chromium:1035761 TEST=make clean && make runtests TEST=Add CONFIG_USB_BOOT_ON_DEV to defconfig and flash to device Switch to dev mode and confirm dev_boot_usb with crossystem BRANCH=none Change-Id: I70a2e3fcd8c5cc252ca3d0eed81490a08503d7b3 Cq-Depend: chromium:1975346 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1975450 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: remove some vboot1 SharedData-related functionsJoel Kitching2019-12-1710-81/+14
| | | | | | | | | | | | | | | | | | | | 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>
* 2lib: Move firmware body size reporting to separate functionJulius Werner2019-12-132-18/+26
| | | | | | | | | | | | | | | | | | | We used to return the firmware body size as part of vb2api_init_hash(). With persistent context and other recent developments, coreboot is caching less data itself and relying more on vboot's data structures, so it may now need this information at more points than just during the hashing process. So let's create a custom function to return this. BRANCH=hatch BUG=b:143994765 TEST=make runtests Cq-Depend: chromium:1965837 Change-Id: I2bc968cd163016fd0130416c2679724caad895a2 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1965920 Reviewed-by: Mathew King <mathewk@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: Publicize check_reboot_for_display()Yu-Ping Wu2019-12-131-0/+19
| | | | | | | | | | | | | | Publicize check_reboot_for_display() and rename it to vb2api_need_reboot_for_display() for depthcharge to use. BRANCH=none BUG=chromium:1030608 TEST=FEATURES=test emerge-nami vboot_reference Change-Id: Ie6c734850b67b29c8a098c3f232888f3ab47fddf Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1957726 Reviewed-by: Joel Kitching <kitching@chromium.org>
* lib/subprocess: add callback feature to the subprocess libraryJack Rosenthal2019-12-111-1/+110
| | | | | | | | | | | | | | | | | | 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-7/+1
| | | | | | | | | | | | | | | 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-101-3/+1
| | | | | | | | | | | | | | | 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>
* host/lib: add a subprocess libraryJack Rosenthal2019-12-071-0/+185
| | | | | | | | | | | | | | | | | | | 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 VbExOverrideGptEntryPriorityJoel Kitching2019-12-071-84/+1
| | | | | | | | | | | | | | | | | This function was added with the sole intended user being BCB support on the depthcharge side. Now that BCB is deprecated, we can remove it. BUG=b:124141368, chromium:956474 TEST=make clean && make runtests BRANCH=none Change-Id: I4a99c540951b5e160bf50bcb790091d1df6eefc3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1954975 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: 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>
* vboot: convert LoadKernel and TryLoadKernel to vboot2-style errorsJoel Kitching2019-12-064-77/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Recovery mode: Skip EC software syncTim Wawrzynczak2019-12-041-0/+10
| | | | | | | | | | | | | | | EC software sync should not be performed in recovery mode, as it breaks the vboot model. BUG=b:145310842 BRANCH=firmware-hatch-12672.B TEST=Verify that EC sync is skipped in recovery mode (coreboot & depthcharge) Change-Id: I771b970b044ed2b13a1cd79f5649af92b0177ac7 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1941037 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: fix up vboot_api_kernel2_testsJoel Kitching2019-12-041-124/+186
| | | | | | | | | | | | | | | | | | | | Stop magically checking get_info_flags by subtracting the expected value from vbtlk_retval. Introduce two globals vbtlk_expect_fixed and vbtlk_expect_removable which are checked when the mocked VbTryLoadKernel function is called. Update some comment style and fix spacing. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I038aa03dcff24ec06f68f6a175f992ed99feddb9 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1836612 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: rewrite rollback_index and centralize reads/writesJoel Kitching2019-11-288-366/+445
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: workbuf alignment should always use 8Joel Kitching2019-11-251-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | Rather than depending on the architecture and environment to provide the correct memory alignment (__BIGGEST_ALIGNMENT__), hardcode to 8, which should be sufficient for all cases. (Previously, by using __BIGGEST_ALIGNMENT__, this is set to 16 in all known cases, which is unnecessarily large.) Update vb2_workbuf tests to be more flexible according to VB2_WORKBUF_ALIGN value. BUG=b:124141368 TEST=make clean && make runtests TEST=Try values of VB2_WORKBUF_ALIGN=2,4,8,16,32,64 BRANCH=none Change-Id: I819586119fa3102fa423a01e0737e6864c05d752 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1911921 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: fix workbuf_used value after storing GBB headerJoel Kitching2019-11-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | After storing the GBB header on the workbuf, the offset of wb.buf is stored into workbuf_used by incorrectly using ctx as the pointer base, rather than sd (which corresponds to the start of the workbuf). This subtracts 8 bytes from the correct value of workbuf_used, and leaves the last 8 bytes of the GBB header vulnerable to being overwritten with any VB2_WORKBUF_ALIGN values less than 16. Also update the relevant vb2_misc_tests check to account for GBB headers with non-aligned sizes (currently it is 128 bytes). BUG=b:124141368, chromium:1027846 TEST=Test with various VB2_WORKBUF_ALIGN values BRANCH=none Change-Id: I862d29155ce08df6911c277f8ce8c703ffaf1df7 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1932276 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* Auxfw sync: Move auxfw specific tests to a new fileTim Wawrzynczak2019-11-152-119/+195
| | | | | | | | | | | BUG=b:143094352 BRANCH=none TEST=make clean && make runtests Change-Id: I3665bfb10c66e2fbe3906e99cc72346748123cfb Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1873879 Reviewed-by: Julius Werner <jwerner@chromium.org>
* ec_sync: Remove vb2ex_get_expected_image() callbackTim Wawrzynczak2019-11-141-11/+1
| | | | | | | | | | | | | | | | | | This callback is redundant, because vboot takes the buffer pointer and just passes it straight into vb2ex_ec_update_image(), so clearly the platform must be able to find the image on its own. Remove it, and also remove the arguments to vb2ex_ec_update_image which were the image and its size. BUG=none BRANCH=none TEST=make runtests Cq-Depend: chromium:1910562 Change-Id: I35548cc0bde761cf08337489af0772bbdf46de4d Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1877065 Reviewed-by: Julius Werner <jwerner@chromium.org>
* EC software sync: Split up EC and auxfw syncTim Wawrzynczak2019-11-142-56/+76
| | | | | | | | | | | | | | | | | | | Currently, the logic for updating auxfw is entangled with the logic for performing EC software sync. This patch attempts to split them apart, so that they can be used separately. VbSelectAndLoadKernel() currently still performs both, EC first and then auxfw. The intended use-case for this functionality is to perform EC software sync only in coreboot's romstage. Unit tests were updated to ensure functionality is effectively unchanged. BUG=b:143094352, chromium:1016688 BRANCH=none TEST=make clean && make runtests Change-Id: I7bdf38694cfed83b18dd8189b8516780184ecc8e Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1867314 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: simplify ec_sync code to only handle one deviceJoel Kitching2019-11-143-21/+20
| | | | | | | | | | | | | | | | | Remove devidx argument from internal and external functions. Rename external API functions to vboot2 scheme (vb2ex_...). Rename external EC-related data types to vboot2 scheme (vb2_...). BUG=b:124141368, chromium:1016688, chromium:1017093, b:112198832, b:143094352 TEST=make clean && make runtests BRANCH=none Cq-Depend: chromium:1910562 Change-Id: I4ca9858a0f91a0365288c04cdb90aad0efdd7647 Signed-off-by: Joel Kitching <kitching@google.com> Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1872255 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: align workbuf to VB2_WORKBUF_ALIGNJoel Kitching2019-11-1333-41/+51
| | | | | | | | | | | | | | | 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>
* EC sync: Drop support for "PD" software sync.Tim Wawrzynczak2019-11-131-2/+2
| | | | | | | | | | | | | | | | All devices which have a PD chip running CrOS EC code have already shipped, and there is no intention to go back to using an "EC" for a TCPC anymore. BUG=b:143762298,chromium:1017093 BRANCH=none TEST=make runtests Change-Id: I177c00581089de59e4f35608b97ef5432e8b492b Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1895712 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: move vb2_context inside vb2_shared_data (persistent context)Joel Kitching2019-11-1324-1408/+1435
| | | | | | | | | | | | | | | | | | | | | 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: remove VbExEcEnteringMode and friendsJoel Kitching2019-11-062-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | After informing EC of the mode chosen by vboot, it is stored in a global and never accessed again. Remove this function, its calls, and its tests. Also note some significant issues which existed: (1) Using accessor VbGetMode for tests, rather than just overriding VbExEcEnteringMode when needed. (2) The tests checking the value sent to VbExEcEnteringMode (vboot_api_kernel2_tests and vboot_detach_menu_tests) actually call the function themselves. BUG=b:124141368, chromium:1014379 TEST=make clean && make runtests BRANCH=none Change-Id: Ib8e510a1e1c663bb3f8238a9ad15e3e64d7350b0 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1864533 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1830239 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* tests: Update futility show expected test outputJulius Werner2019-11-021-1/+1
| | | | | | | | | | | | | | | | | | If you read the manpage for printf *really* closely, it seems that the %#x token only prints the 0x prefix for non-zero values. Huh... never knew that (and our firmware implementations in fact don't honor that, but glibc does). Anyway, I think we're fine with either behavior but this broke the expected output for one of our futility tests, which this patch fixes (originally broken in CL:1840191). BRANCH=None BUG=None TEST=make runtests Change-Id: Id54ff6f56e02333ab01b09b75deb16f47da01bc3 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1885411 Reviewed-by: Joel Kitching <kitching@chromium.org>
* cgptlib: Minor edge case fixesJulius Werner2019-11-021-34/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a sanitizer issue in cgpt where a GPT entries array may have been passed even though it was not loaded from disk (parsing an uninitialized buffer). The GPT library seems to have been written with the assumption that both headers and entries would always be loaded and it could recover even if only the primary header and the secondary entries were valid. In practice, this doesn't really work because the caller doesn't know how to read entries for an invalid header. Therefore, change the code so that entries are only assumed to be loaded for valid headers. Also fix some minor problems with loading GPTs by aligning sizes up (not down) to the next sector boundary and making sure we always allocate the maximum amount of space for entry arrays, even if the current header may not need that much (in case a repair wants to overwrite it). This practically reverts CL:276766 which becomes obsolete (and was really just a dirty hack to hide an underlying problem). BRANCH=none BUG=chromium:1017797 TEST=make runtests Change-Id: I86c601dc074261d53f013b98ae214efdc44f3563 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1885098 Reviewed-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: keep const and non-const signature and key accessorsJoel Kitching2019-10-293-4/+5
| | | | | | | | | | | | | | | | | | | | | 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: move ec_sync to vboot2 namespaceJoel Kitching2019-10-252-2/+2
| | | | | | | | | | | | | | | | | Move ec_sync.c to vboot2 namespace. Keep its API in vboot_api.h for the time being. BUG=b:124141368, chromium:1016688, b:112198832, b:143094352 TEST=make clean && make runtests BRANCH=none Change-Id: Ia925e93ecdcdb1a2a2724336774f48dbe0439743 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1872254 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Sean Abraham <seanabraham@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* vboot: merge pre-vboot1 error codes into vb2_return_codeJoel Kitching2019-10-231-4/+4
| | | | | | | | | | | | | | | | | | 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: remove BUILD_ASSERT macroJoel Kitching2019-10-231-1/+2
| | | | | | | | | | | | | | | Use _Static_assert() instead. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I42a18442a8bff1ab346f8ba784e9e6fc0366de9a Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1786388 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-235-88/+46
| | | | | | | | | | | | | | | 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-2313-65/+65
| | | | | | | | | | | | | | | | 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: fold lib20/api.c into 2lib/2api.cJoel Kitching2019-10-232-441/+382
| | | | | | | | | | | | | | | | | All of the functions in lib20/api.c are actively used in coreboot verstage firmware verification. Fold the functions and their test suite into 2lib. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I2dbad2715246a8a16ee85dac553a751ae1590afa Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1659991 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-2310-22/+22
| | | | | | | | | | | | | | | | 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>
* firmware: ui: Unify delays, remove DISK/KEY split in recovery modeJulius Werner2019-10-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | | The reason for having a separate REC_DISK_DELAY and REC_KEY_DELAY has long been lost in time... in fact, with our current coreboot firmware stack, polling for keys will always also poll for disks, so we're already polling for disks in the inner loop anyway. Removing this distinction will resolve some weirdness in certain error cases. An unintended side effect is that the usual recovery mode console spam goes from annoying at 4 times a second to unbearable at 50 times a second. Let's just remove it instead and get the console output more in line with what our developer and BROKEN screens show (i.e. nothing, unless there's any change or user input). BRANCH=None BUG=chromium:1009850 TEST=Booted Kevin Change-Id: Ie1754646e7d17a661c9adebf43483df1785e6127 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1856831 Reviewed-by: Joel Kitching <kitching@chromium.org>
* firmware: Don't set recovery reason for removable boot in TryLoadKernelJulius Werner2019-10-221-0/+32
| | | | | | | | | | | | | | | | | | | | | | Right now TryLoadKernel() always sets a recovery reason when it did not manage to load a kernel for any reason. In many cases (e.g. we're already in recovery mode, or we're trying to boot off some random USB stick in dev mode) we don't actually want that to happen, so there are four different instances of code unconditionally clearing the recovery reason again right after calling TryLoadKernel(). This is confusing and there's a far simpler solution: only set the recovery reason when we're booting off a fixed disk. We never want to set it when trying to boot a removable disk anyway, so centralizing this distinction right in TryLoadKernel() makes the logic easier to follow. BRANCH=None BUG=None TEST=make runtests, played around with a Kevin Change-Id: I9d56356b0f3547b3690be2c24cf6936e57e4cf1f Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1859687
* firmware: Do not set recovery reason directly in LoadKernel()Julius Werner2019-10-222-19/+72
| | | | | | | | | | | | | | | | | | | | | | | LoadKernel() currently contains code that sets the recovery reason directly (via direct nvdata access, bypassing the usual VbSetRecoveryReason() helper) whenever it has a problem loading a kernel. This seems to be an ancient vestige from the time when LoadKernel() (and not VbSelectAndLoadKernel()) was still the external API. In our current use, VbTryLoadKernel() will always immediately override any recovery reason set this way. This patch removes this pointless code to avoid confusion. Instead, TryLoadKernel() is expanded to be able to tell the difference between LoadKernel() return codes and set a more precise recovery reason based on that. BRANCH=None BUG=chromium:692715 TEST=make runtests Change-Id: Idd8bd6e16d5ef1472aa3b2b66468248726d5c889 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1859686
* firmware: Clean up and deprecate recovery reasonsJulius Werner2019-10-222-10/+1
| | | | | | | | | | | | | | This patch deprecates a bunch of recovery reasons we no longer use and removes the display strings associated with them. BRANCH=None BUG=None TEST=make runtests Change-Id: I0350784f810c68d52bc972575b8c3f57539b8094 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1863624 Reviewed-by: Joel Kitching <kitching@chromium.org>
* tests: Add fuzzers for payload and preamble parsingJulius Werner2019-10-222-0/+193
| | | | | | | | | | | | | | | This patch adds fuzzers for vb2_load_fw_keyblock() and vb2_load_fw_preamble(). I'm new at fuzzing so please let me know if I did something dumb. BRANCH=None BUG=None TEST=Ran them manually with cros_fuzz. Change-Id: Ica39fcf4a3d250e69c51214afcee9e9815667ff8 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1867969 Commit-Queue: Manoj Gupta <manojgupta@chromium.org>