summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* vboot: Set VB2_SD_STATUS_EC_SYNC_COMPLETE in shared data statusfirmware-hatch-12672.Bfirmware-hatch-12672.117.BYu-Ping Wu2020-03-051-3/+3
| | | | | | | | | | | | | | | | | | | | CL:1877066 introduced shared data status VB2_SD_STATUS_EC_SYNC_COMPLETE, but incorrectly saved it in shared data flags. BRANCH=hatch BUG=chromium:1057517 TEST=make runtests Change-Id: Idc993304760c419f80c6b160b30763142cf47234 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2082756 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2090580 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* futility: updater: move system-related utility functions to updater_utilsHung-Te Lin2020-01-056-760/+854
| | | | | | | | | | | | | | | | | | | | | | | | | | The firmware updater (updater.c) is bloated so we should move functions that are not really related to 'updating logic' to a new file, updater_utils.c. Refactor only by moving functions (and renamed few functions), no changes in updater logic. BRANCH=none BUG=chromium:1024401 TEST=make clean && make runtests Change-Id: I98339c5c4a81845b36daf842c79625fa2389c7f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1926009 Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Auto-Submit: Hung-Te Lin <hungte@chromium.org> (cherry picked from commit e8618380056e338d563501e2c9e03e9ff7102cc5) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1987578 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: Append periods to function descriptions in 2api.hYu-Ping Wu2020-01-031-2/+2
| | | | | | | | | | | | | | | BRANCH=none BUG=none TEST=FEATURES=test emerge-nami vboot_reference Change-Id: Id02f4a20a95c3653c4327b9cd7620b24bafb50a0 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1957999 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1987000 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: merge vb2_struct.h into 2struct.hJoel Kitching2020-01-0316-305/+199
| | | | | | | | | | | | | | | | | | | 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> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986999 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: remove definition of VB_INIT_OUT flagsJoel Kitching2020-01-031-23/+0
| | | | | | | | | | | | | | | | | | | | These flags are no longer used. BUG=b:124141368, chromium:960226 TEST=make clean && make runtests BRANCH=none Change-Id: I0964ea834a190358ae10289c2746304369a79ff8 Cq-Depend: chromium:1957764 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1957725 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986998 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: remove static linking support from MakefileJoel Kitching2020-01-031-12/+3
| | | | | | | | | | | | | | | | | | | | | | Previously, futility and crossystem needed to be statically linked. (futility had both futility and futility_s.) Since there's no longer any need to statically link any binaries built by vboot_reference, remove this support from the Makefile. BUG=b:124141368, chromium:765499 TEST=make clean && make runtests BRANCH=none Change-Id: I8c2b5c5b5aa86bbecb0c264f688dfdac4b19ca7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1954976 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986997 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: remove VbExOverrideGptEntryPriorityJoel Kitching2020-01-034-108/+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> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986996 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: move vb2_allow_recovery function to 2miscJoel Kitching2020-01-037-36/+35
| | | | | | | | | | | | | | | | | | | | | Previously in vboot_common.c. This function "almost" only reads vboot2 data. As we would like to deprecate and remove the vboot_common.c file, find a new home for it. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ice980604be3537741293bb9f6d31385c1d915887 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844596 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986995 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: remove unnecessary vboot_common.h includesJoel Kitching2020-01-0331-27/+6
| | | | | | | | | | | | | | | | | | 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> (cherry picked from commit b85ce0705d92d693fff590a9d5efd4af118d54e4) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986930 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: migrate GBB-related error handling to vboot2Joel Kitching2020-01-032-9/+5
| | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 09f6670674639ef81eb695802a347b8be2dac20a) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1984854 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: convert LoadKernel and TryLoadKernel to vboot2-style errorsJoel Kitching2020-01-0310-148/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 99b15d64f9b15a487fd871fcd527d00c3641509c) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986992 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: Add const modifier to vb2api_relocate argumentYu-Ping Wu2020-01-032-15/+16
| | | | | | | | | | | | | | | | BRANCH=none BUG=none TEST=emerge-nami vboot_reference coreboot Change-Id: I83a82a8b931c074e83ced8ea41c215d70825881e Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1935272 Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 16e6fe39f94e802cadcd67ae0ac612aa6ec1ee7f) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986987 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* Makefile: Make loop unrolling fully controllable by the callerJulius Werner2020-01-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We recently reactivated the -DUNROLL_LOOPS code for x86 devices. Unfortunatley, this seems to lead to code size problems for early firmware stages on certain x86 boards (CB:37475). The biggest speedup with unrolled loops was observed during kernel verification anyway (which hashes orders of magnitude more data than firmware verification), so let's make this fully configurable by the calling firmware and only enable it from depthcharge. Pre-RAM coreboot changes are probably better served with the smaller implementation anyway (and this will only become more important as we move to CBFS per-file hashing and need hash algorithms in every stage). BRANCH=None BUG=None TEST=None Cq-Depend: chromium:1951413 Change-Id: I87eaa14299cae0ee0d0b4a098d638b6bccdaf75b Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1951782 Reviewed-by: Aaron Durbin <adurbin@google.com> Reviewed-by: Subrata Banik <subrata.banik@intel.com> (cherry picked from commit 695c56dc50a59e5c9098c94f41b3d86b8f99baf1) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986929 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: fix up vboot_api_kernel2_testsJoel Kitching2020-01-031-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> (cherry picked from commit fa6298dfd85fda32617a5f54434085563027bd01) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986986 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* 2lib: Move firmware body size reporting to separate functionJulius Werner2019-12-125-27/+50
| | | | | | | | | | | | | | | | | | | | 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,kukui BUG=b:143994765 TEST=make runtests Cq-Depend: CB:37680 when it's done reviewing Change-Id: I2bc968cd163016fd0130416c2679724caad895a2 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1965922 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot/altfw: fix up some altfw codeJoel Kitching2019-12-034-45/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than the caller picking and choosing between vb2_run_altfw and vb2_try_alt_fw, always use the "try" function, and manually specify the `allowed` argument. Fix up some comment styles. Reverse the order of vb2_commit_data and secdata_kernel_lock calls, and check the return value of vb2_commit_data. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ib6b2752ba1b9be66401612a46f9c1b9353669c27 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776286 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit 7d64b93ccf13623fa26ee865674e3b443ce253bd) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947717 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* firmware: Add static keyword to power_button_stateYu-Ping Wu2019-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | Since power_button_state is only used within vboot_ui.c, it should be declared static. BRANCH=none BUG=none TEST=emerge-nami vboot_reference Change-Id: I392f137af15b36cf343817c681b18434e33e53e4 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1937048 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 03072bf685a25485259bae62c8e223377a797f85) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947716 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot/secdata: rewrite rollback_index and centralize reads/writesJoel Kitching2019-12-0328-856/+832
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit adb418310d2e51e2f2a0f22607989fd3f66c4433) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947715 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* Remove inflags from VbSelectAndLoadKernelParamsYu-Ping Wu2019-12-032-10/+0
| | | | | | | | | | | | | | | | | | | | | Since vendor data flag in vb2_context is set from depthcharge directly (CL:1933685), VB_SALK_INFLAGS_VENDOR_DATA_SETTABLE can be removed. The inflags field is also removed from struct VbSelectAndLoadKernelParams. BRANCH=none BUG=chromium:953656 TEST=emerge-kukui depthcharge vboot_reference Cq-Depend: chromium:1933685 Change-Id: If5cdf11d1fd27603b22b2c71183847a0987e5fc8 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1932279 Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 45facd54087232ef3f354108e8429932e6f0355f) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947714 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: Don't warn user if enter key is pressed if rec switch is physicalMathew King2019-12-031-10/+20
| | | | | | | | | | | | | | | | | | | | | | | When the recovery switch is physical then the propmt to enter dev mode will say to press the recovery switch not the enter key. In this case we do not want to warn the user that an internal keyboard is needed to confirm we will just silently ignore the enter key. BUG=b:144034020 TEST=On Drallion enter key does not work to switch to dev mode and does not beep or print a warning when the enter key is pressed BRANCH=none Change-Id: I250ea2622c9c38bfc0d7463eb95ca65a12b41153 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1929601 Tested-by: Mathew King <mathewk@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Mathew King <mathewk@chromium.org> (cherry picked from commit 292b9a6f6ab27a3c520090e0e0d8aba4522abca8) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947348 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: add errors for nvdata read/write failuresJoel Kitching2019-12-031-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> (cherry picked from commit a93aa4a3cc14ca11f2833f7b803f1442aa8a4d06) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947712 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: workbuf alignment should always use 8Joel Kitching2019-12-032-27/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit c7d266e0d6e66a23adfd7681efa39e08f6ccf51b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947711 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: fix workbuf_used value after storing GBB headerJoel Kitching2019-12-032-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 30481361d88718fa6eead75508c552cc70c728dc) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1947347 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* Recovery mode: Skip EC software syncTim Wawrzynczak2019-11-281-0/+9
| | | | | | | | | | | | | | | | 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/+/1941038 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org>
* PRESUMBIT: enable signoff_checkJett Rink2019-11-241-0/+1
| | | | | | | | | | | | | | | | | | The default in pre-upload.py was changed to warn about Signed-Off-By lines: https://crrev.com/c/1917972. BRANCH=none BUG=none TEST=repo upload --cbr . Change-Id: Ie54b95251a751134c8824d3720e2fe73ef79fbc9 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1926520 Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 1a7113ba615baf78e3e17a8c949e5e2143b771f2) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1932278 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: Add vb2_context_flags VB2_CONTEXT_DETACHABLE_UIYu-Ping Wu2019-11-243-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently VB_SALK_INFLAGS_ENABLE_DETACHABLE_UI in VbSelectAndLoadKernelParams.inflags controls whether to enable detachable ui. However, it doesn't have much to do with the specifics of "loading a kernel", and would fit better in vb2_context.flags, which is also passed to VbSelectAndLoadKernel(). This patch replaces the usage of VB_SALK_INFLAGS_ENABLE_DETACHABLE_UI with vb2_context_flags VB2_CONTEXT_DETACHABLE_UI, which is set from depthcharge. BRANCH=none BUG=chromium:953656 TEST=emerge-kukui depthcharge vboot_reference Cq-Depend: chromium:1918868 Change-Id: Iafe0f9fe0a90bcb5a7fa557fac75e0856796769d Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1921769 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> (cherry picked from commit b68640501703dab98681916c8bef02a25548cbf9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1932277 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* Makefile: Fix typo for MOCK_TPMJulius Werner2019-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | CL:1900560 broke MOCK_TPM due to a typo in the Makefile. This patch fixes it. BRANCH=None BUG=None TEST=None Change-Id: Ifd23ad764029b72af3fb03cf9dd52faefa586a80 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1922491 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 1c4dbaa08419e13366db32ed20244f63c34388a0) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924304 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* Makefile: Define UNROLL_LOOPS to save ~50ms of boot timeSubrata Banik2019-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | TEST=Able to save ~50ms of bootime with this CL Without this CL 1100:finished vboot kernel verification 802,443 (148,108) With this CL 1100:finished vboot kernel verification 775,914 (102,601) Signed-off-by: Subrata Banik <subrata.banik@intel.com> Change-Id: I96bea22667ebf45b446a26d84de96e52f3d28aa0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1919094 Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org> (cherry picked from commit 7dedd9a88847a7b10ecb75e7c3fd0b28c3f86609) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924303 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* Split TLCL functionality out into a new libraryTim Wawrzynczak2019-11-201-7/+20
| | | | | | | | | | | | | | | | | | | | | This patch splits out the TPM functionality into a separate library called TLCL (TPM lightweight command library). This is to avoid linking in TLCL code two times and causing duplicate references. BUG=none BRANCH=none TEST=make clean && make runtests Cq-Depend: chromium:1901882 Change-Id: I56e961c066b2df1d1e19f632b834b11625454f59 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1900560 Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit 6ab29e142da126a22e8098f822653a004662f60e) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924302 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* futility: updater: Check and use larger regions in EC RO updateHung-Te Lin2019-11-201-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike STM32 (used on ARM Chromebooks), EC images on most x86 Chromebooks used to have a header before EC_RO section describing the size and attributes of firmware to load. However, partial updating with only 'EC_RO' by flashrom will not include those data. So we should use 'WP_RO' to update whole RO area. This also implies EC RO software sync, which usually only updates ec.RO.bin in EC_RO, is not safe on devices with extra data. A quick solution is to only allow RO software sync when EC_RO is aligned to top of EC firmware image. Also in future devices cannot run EC software sync may skip generating EC RO blobs in AP coreboot CBFS so the updater won't try to do RO software sync. BUG=chromium:1024401 TEST=(kukui) chromeos-firmwareupdate --mode=recovery # updated and boot (laser) chromeos-firmwareupdate --mode=recovery # updated and boot also verified we can update from old x86 EC (EC_RO does not include header) to new style (EC_RO contains header). Change-Id: I2c90320ffbfd79ba0cbaf70016446d8ab489e6ac Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1919097 Reviewed-by: Shelley Chen <shchen@chromium.org> (cherry picked from commit 6737b9e9a771fa14c6d90dc9197f054b69a85c1b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924301 Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* chromeos-tpm-recovery: Clarify error message for boot modeJulius Werner2019-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | chromeos-tpm-recovery only works when it's actually booted in recovery mode, not when just running a recovery image in developer mode with Ctrl+U. This distinction is often not super clear to non-firmware people, so make the error message more explicit. BRANCH=None BUG=None TEST=None Change-Id: I18afa933f624f26d1f7949b9b586ab01daf7c801 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1913491 Reviewed-by: Curtis Malainey <cujomalainey@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 32b5c34d13334b4fe7924a48cdf97b1f8daab635) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924300 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* battery cutoff: Move cutoff handling from EC sync to kernel loadTim Wawrzynczak2019-11-202-33/+28
| | | | | | | | | | | | | | | | | | | | | | Currently, battery cutoff is handled at the end of a successful EC software sync. Now that auxiliary firmware sync is separate from the EC, this patch moves it back to after both EC and auxfw updates are successful, to ensure all firmware is up-to-date before entering ship mode. BUG=none BRANCH=none TEST=make runtests Change-Id: I96bea22667ebf45b446a26d84de96e52f3d289a5 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1889430 Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit 14128c66d5ad2c2caf50dbee1b19282497274a70) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924299 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* Auxfw sync: Move auxfw specific tests to a new fileTim Wawrzynczak2019-11-203-119/+197
| | | | | | | | | | | | | | | | 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> (cherry picked from commit c8333506d434cb3126f4bb60700e41a834415648) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924298 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* EC sync: Add a new shared flag VB2_SD_STATUS_EC_SYNC_COMPLETETim Wawrzynczak2019-11-202-1/+22
| | | | | | | | | | | | | | | | | | | | | The new flag can be set by any firmware which updates the EC to let further stages know that the EC sync has already been completed during this boot. BUG=none BRANCH=none TEST=make runtests Change-Id: Ide14efe7091631b62d240ddc984c8c70527a6d37 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1877066 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit 38796a80f76d6ff0c5c4947a4cf217fd20742855) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924297 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* crossystem: Add a fake workbuffer for the fake contextJulius Werner2019-11-203-29/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 49428f49143ba0357693f4ace9b169ce63cfa42c) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924296 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* 2lib: Move context-related functions from 2misc.c into 2context.cJulius Werner2019-11-203-89/+101
| | | | | | | | | | | | | | | | | | | | | | | | | This patch separates out some code into an extra file so that it's easier to link into hostlib without pulling in all additional dependencies from the random 2misc.c crap. The functions are copied wholesale with no changes. BRANCH=None BUG=chromium:1024732 TEST=make runtests Change-Id: Ia00d1da277e5fc0956c8a1ae608d842224016c91 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1917819 Tested-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org> Commit-Queue: Brian Norris <briannorris@chromium.org> (cherry picked from commit 54fc81cf692dbcb4496fa9664103564a9c386c05) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924295 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* ec_sync: Remove vb2ex_get_expected_image() callbackTim Wawrzynczak2019-11-206-49/+19
| | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 19ff28bd95b79e421059fdccf6b07e0a23f12aa3) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924294 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* EC software sync: Split up EC and auxfw syncTim Wawrzynczak2019-11-2012-305/+424
| | | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 5d874c2f45c991651a3c66be64e4139f56c69d25) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924292 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* futility: updater: Correct EC RO name in CBFSHung-Te Lin2019-11-201-2/+2
| | | | | | | | | | | | | | | | | | | The EC RO name inside CBFS is actually 'ecro' instead of 'ec_ro'. BRANCH=None BUG=b:141965252 TEST=make clean && make runtests Run 'futility update -i image.bin -e ec.bin --mode=recovery' Change-Id: I2ede0bfbd550d343726df893ce707e82d77d5f30 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1913689 Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 26cb4f2d56ade573588aaa8f20ca38402da09c86) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924293 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: simplify ec_sync code to only handle one deviceJoel Kitching2019-11-208-172/+139
| | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 35edb575304447c68be8c7298610203ee98d94e0) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924291 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: align workbuf to VB2_WORKBUF_ALIGNJoel Kitching2019-11-1446-57/+75
| | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 92ea19ae091482484c84d7b09049f7dc74bf6f42) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1918007 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* futility: updater: sync mtimesMike Frysinger2019-11-143-21/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | When unpacking files, unzip will retain timestamps on the outputs. This makes it easy to recreate the firmware unpacker with the same exact contents. futility doesn't copy update timestamps anywhere, so all the mtimes are $now, which makes it impossible to recreate the same archive. Update the API to pass around mtimes by reading them from inputs, setting them on outputs, and copying them across. BUG=None TEST=`futility update -a chromeos-firmwareupdate --unpack out` has timestamps on outputs BRANCH=None Change-Id: Icc0ae833390115082e1677d190d1b2a029b78439 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1913067 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> (cherry picked from commit c48a593b26d2353eb8788dd85ba8618555180f55) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1918004 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* EC sync: Drop support for "PD" software sync.Tim Wawrzynczak2019-11-147-51/+30
| | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit b35c2d1012625593c5a4a8be67ca6368aa3304df) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1918264 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* lib20/misc: Small robustness improvements to vb2_load_fw_keyblock()Julius Werner2019-11-141-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes an issue discovered while fuzzing vb2_load_fw_keyblock(): the data key contained in the keyblock is not sanity-checked before moving it around on the work buffer, resulting in a potential overflow if it's key_size flows over the end of the keyblock. This is not exploitable since the keyblock was already verified, so only signed (=trusted) keyblocks can get to this stage, but there's nothing wrong with double-checking anyway. This patch also rewrites the data_key moving code a bit to just move the whole key rather than individually copying the header elements and then just memmove()ing the data (and keeping the previous key_offset from the root key rather than the one from the data key). None of these issues affect correctness but it seems simpler and cleaner to me this way. Finally, remove an instance where the keyblock was accessed after the memmove(). This would be bad if the data key was so much larger than the keyblock that memmove()ing it overwrites the keyblock header. Like an existing comment points out, that doesn't happen with the key sizes we choose in practice, but it's still better to not rely on that. BRANCH=none BUG=chromium:1017793 TEST=make runtests and reran failing fuzz testcase Change-Id: I78ded43ad999e0883a69cbb2ea7e876888a9fa22 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1880015 Reviewed-by: Joel Kitching <kitching@chromium.org> (cherry picked from commit 2cc38ec1b74cf7db7357fc177d2be813cca9fe06) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1918003 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* vboot: move vb2_context inside vb2_shared_data (persistent context)Joel Kitching2019-11-1437-1543/+1637
| | | | | | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit ecdca931ae0637d1a9498f64862939bd5bb99e0b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1918263 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* futility: updater: Clean up hard-coded section names to preservestabilize-volteer-12665.Bstabilize-12669.Bfirmware-hatch-12669.BHung-Te Lin2019-11-081-13/+1
| | | | | | | | | | | | | | | | | | The following sections can be now deleted from hard-coded list: - RO_PRESERVE: no boards use it. - RO_FSG: new images have set the PRESERVE flag in CBFS. - SI_GBE, SI_PDR: already using PRESERVE flag since fw branch is cut. BUG=b:116326638,chromium:936768 TEST=make clean && make runtests Change-Id: I99759949104bf4f1c1db3556e273923dcb1c5887 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1902841 Tested-by: Hung-Te Lin <hungte@chromium.org> Auto-Submit: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org>
* vboot: remove VbExEcEnteringMode and friendsJoel Kitching2019-11-066-38/+5
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Revert "Clean up implicit fall through."Mathew King2019-11-056-7/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-056-28/+7
| | | | | | | | | | | | | | | | 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: Remove the never called breakEric Lai2019-11-051-3/+0
| | | | | | | | | | | | | Clean up the code. BUG=none BRANCH=none TEST=N/A Change-Id: If4ef76edf5f97fc51a21740e1ca51475b27b5f1a Signed-off-by: Eric Lai <ericr_lai@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1897416 Reviewed-by: Julius Werner <jwerner@chromium.org>