summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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-027-93/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* cr50_signing: add code to sign pre-pvt, pre-release and releaseVadim Bendebury2019-11-021-33/+59
| | | | | | | | | | | | | | | | | | | | | | | This patch adds checks necessary before various types of images signing could proceed. The checks include verifying that Board ID flags and major version number match the image type. Also, manifest modification for node locked images is enhanced by setting the least significant bit of the tag field to one. This will ensure that the prod key ladder is not available to node locked images even though they are signed with a prod key. BRANCH=none BUG=b:74100307 TEST=verified various cases by manually editing prod.json and signing_instructions.sh and observing results: either error messages or successful modification of the manifest and signing. Change-Id: I0bc4a8acae1ca4e983999fd47e515c48786ded6c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1894848
* cr50_signing: add code to process node locked imagesVadim Bendebury2019-10-301-26/+85
| | | | | | | | | | | | | | | | | | | | | Node locked images signed by the builder will have to come from the factory branch and have version of 0.3.22. Signing manifest will be processed to insert Device ID values, remove Board ID values and set the top bit of config1. BRANCH=none BUG=b:74100307 TEST=ran the script manually with proper input and verified that manifest is processed as expected. Change-Id: Ib8cbe0f1ae31e79c3228a662c02231caeb901adc Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1880572 Tested-by: George Engelbrecht <engeg@google.com> Reviewed-by: Ned Nguyen <nednguyen@google.com> Reviewed-by: George Engelbrecht <engeg@google.com> Commit-Queue: George Engelbrecht <engeg@google.com>
* OWNERS: engeg@ is owner.LaMont Jones2019-10-291-1/+1
| | | | | | | | | | | | | | BRANCH=None BUG=None TEST=None Change-Id: I6e10fd839e256454ce3671228116d8c3a9ec6092 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1888274 Tested-by: LaMont Jones <lamontjones@chromium.org> Tested-by: George Engelbrecht <engeg@google.com> Auto-Submit: LaMont Jones <lamontjones@chromium.org> Reviewed-by: George Engelbrecht <engeg@google.com> Commit-Queue: George Engelbrecht <engeg@google.com>
* vboot: deprecate ARM's VbGetVarGpioJoel Kitching2019-10-291-71/+2
| | | | | | | | | | | | | | | | | | | | This was originally used for some U-Boot devices which have already reached AUE. Keep gpiod_read (the current method), and VbGetPlatformGpioStatus (deprecated, but still used in current devices). BUG=chromium:942901 TEST=make clean && make runtests BRANCH=none Change-Id: I2a7b97f2ead0294027407cb4e9349cc5265f8f82 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1539434 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* vboot: remove unused PublicKey and Signature helper functionsJoel Kitching2019-10-292-63/+0
| | | | | | | | | | | | | | | | | | | | Functions are replaced by their vboot2 equivalents: GetPublicKeyData --> vb2_packed_key_data GetSignatureData --> vb2_signature_data VerifyPublicKeyInside --> vb2_verify_packed_key_inside VerifySignatureInside --> vb2_verify_signature_inside BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: Idcae0510070242315bdcd843f29d0662ed0ea3ad Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1786387 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: keep const and non-const signature and key accessorsJoel Kitching2019-10-2912-48/+48
| | | | | | | | | | | | | | | | | | | | | 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>
* futility: update: Try EC-RO software sync if availableHung-Te Lin2019-10-291-41/+154
| | | | | | | | | | | | | | | | | | | For devices with EC that will reset TCPC when updating RO, dogfood units without write protection will always see failure in recovery process. To fix this, we want to apply EC RO software sync if available. BRANCH=None BUG=b:141965252 TEST=Boot device in recovery mode, same EC RO and run futility -i image.bin -e ec.bin # see EC RO in next boot Change-Id: I60552facc059b894a4922738207fd885008cb40c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1864534 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Auto-Submit: Hung-Te Lin <hungte@chromium.org>
* Always pass "-g" when building.Manoj Gupta2019-10-281-1/+1
| | | | | | | | | | | | | | | | Always build vboot_reference with "-g" irrespective of debug mode. Building with "-g" will allow much better stack traces and debug information when debugging. Portage will strip the debug binaries so the size of final files installed on DUT will stay unchanged. BUG=chromium:1017793 TEST="-g" is passed to builds. Change-Id: Id6a718bc31afe4a12243ddbb1c45d411ab9791f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1884690 Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: Fix more UBSAN left shift errors.Manoj Gupta2019-10-281-1/+2
| | | | | | | | | | | | | | | | | Follow up commit to CL:1867970. Shifting a uint8_t left by 24 promotes to an int, not an unsigned int (and shifts into the sign bit are undefined). Probably doesn't make a difference in assembly but still doesn't hurt to fix. Courtesy of UBSAN. BRANCH=None BUG=chromium:1015908 TEST=No more shift errors in unit test Change-Id: I10060df6b23da81388db34973b831c09c8d61bff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1881475 Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tofactory.sh: remove usage of "mosys vpd" commandJack Rosenthal2019-10-261-6/+0
| | | | | | | | | | | | | | | No platforms support vpd in mosys anymore, so this will always fail. Drop the warning message and let the user extract it from the BIOS backup if they need. BUG=chromium:990438 BRANCH=none TEST=verified no platform offers cmd_vpd in mosys Change-Id: I5550724f13120202775245cfd252c988edd5b21f Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1881473 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* vboot: move ec_sync to vboot2 namespaceJoel Kitching2019-10-258-14/+13
| | | | | | | | | | | | | | | | | 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 ec_sync and ec_sync_allJoel Kitching2019-10-253-99/+83
| | | | | | | | | | | | | | | | | | | Merge ec_sync and ec_sync_all in preparation for EC and auxfw refactoring. This CL just moves code around without actually making any modifications. BUG=b:124141368, chromium:1016688, b:112198832, b:143094352 TEST=make clean && make runtests BRANCH=none Change-Id: I833c429e36a8f75e9b6d8f21aeb4c8c92c860256 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1872253 Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Sean Abraham <seanabraham@chromium.org>
* firmware: Fix various UBSAN left shift errorsJulius Werner2019-10-254-5/+6
| | | | | | | | | | | | | | | | | Shifting a uint8_t left by 24 promotes to an int, not an unsigned int (and shifts into the sign bit are undefined). Probably doesn't make a difference in assembly but still doesn't hurt to fix. Courtesy of UBSAN. BRANCH=None BUG=chromium:1015908 TEST=None Change-Id: I92db432eebc52c0432d38dc5fc15a80f3d5527c1 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1867970 Commit-Queue: Stefan Reinauer <reinauer@google.com> Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Mattias Nissler <mnissler@chromium.org>
* vboot: remove some unused pre-historic functionsJoel Kitching2019-10-232-48/+0
| | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I5643176ff6979408a81df5fce6de6a002f025a60 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776293 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: merge pre-vboot1 error codes into vb2_return_codeJoel Kitching2019-10-235-45/+24
| | | | | | | | | | | | | | | | | | 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: use inline instead of __inlineJoel Kitching2019-10-234-6/+6
| | | | | | | | | | | | | | | | Use official inline keyword instead of compiler-specific __inline. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ica2b2bd5f2af5188209dad6b5ba6f317b8229b99 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1872252 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove extraneous SHA256_HASH_SIZE constantJoel Kitching2019-10-231-2/+0
| | | | | | | | | | | | | | | Added in CL:26875 for unknown reasons. BUG=b:124141368, TEST=make clean && make runtests BRANCH=none Change-Id: Ic44852ab98af4318f3e54cc1335f659ec38c4d9b Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1819086 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove BUILD_ASSERT macroJoel Kitching2019-10-234-23/+10
| | | | | | | | | | | | | | | 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-2317-306/+203
| | | | | | | | | | | | | | | 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-2337-231/+231
| | | | | | | | | | | | | | | | 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-235-660/+583
| | | | | | | | | | | | | | | | | 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: remove timers from VbSelectAndLoadKernel and crossystemJoel Kitching2019-10-234-30/+4
| | | | | | | | | | | | | | | | These timers have not been used in eons, and an alternative already exists (coreboot's tstamp_table). BUG=b:124141368, chromium:1014102 TEST=make clean && make runtests BRANCH=none Change-Id: Ic0d3e14028315d6f343388c7c1c9d105b7bd58a2 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1860254 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: format hex numbers with %#x instead of 0x%xJoel Kitching2019-10-2335-123/+123
| | | | | | | | | | | | | | | | Also standardize on using hex for printing ASCII key values across vboot_ui.c and vboot_ui_menu.c. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ib10288d95e29c248ebe807d99108aea75775b155 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1840191 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: make BROKEN screen code for saving nvdata more consistentJoel Kitching2019-10-234-23/+16
| | | | | | | | | | | | | | | | | | | | Remove SAVE_LOCALE_IMMEDIATELY. Check for VB2_CONTEXT_RECOVERY_MODE and !vb2_allow_recovery() before committing nvdata. Ensure comments are consistent. BUG=b:124141368, chromium:1006689 TEST=make clean && make runtests BRANCH=none Change-Id: I6919fb858f999c6d8b81a090dc1f271756bc7dc4 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1840192 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: ui: Unify delays, remove DISK/KEY split in recovery modeJulius Werner2019-10-225-123/+77
| | | | | | | | | | | | | | | | | | | | | | | 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-224-41/+47
| | | | | | | | | | | | | | | | | | | | | | 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-225-56/+103
| | | | | | | | | | | | | | | | | | | | | | | 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-227-135/+94
| | | | | | | | | | | | | | 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-223-1/+196
| | | | | | | | | | | | | | | 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>
* vboot: update secdata accessors to match those of FWMPJoel Kitching2019-10-2115-239/+212
| | | | | | | | | | | | | | | Instead of returning vb2_error_t, use VB2_DIE to exit on error. BUG=b:124141368, chromium:972956, chromium:1006689, TEST=make clean && make runtests BRANCH=none Change-Id: I9497eebb0b8815734fdf875ba4f9ef5eda5e82fd Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1833365 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove VbSetRecoveryRequestJoel Kitching2019-10-212-52/+63
| | | | | | | | | | | | | | | | | | | | | | Remove VbSetRecoveryRequest and use vb2api_fail instead. When failure is encountered in kernel verification, it's very possible that there is a bug in updated RW firmware. The other firmware slot should always be attempted before falling back to recovery mode. Call vb2api_fail to invoke this behaviour, rather than setting the recovery request directly with VbSetRecoveryRequest. BUG=b:124141368, chromium:1007999 TEST=make clean && make runtests BRANCH=none Change-Id: I69c457f37d1f58c1eef33dec436fb77b2a77030f Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1833364 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove some more junk from vboot_struct.hJoel Kitching2019-10-211-19/+2
| | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: If322882e53aabb9e488a393a0053f16fcabd626c Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1839732 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: mark some more vboot1 VBSD flags as deprecatedJoel Kitching2019-10-211-17/+23
| | | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ie00678b9045b0a93ee7d0baaf285e9aed68917c4 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1839731 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: deprecate legacy vboot1 FWB_TRIED flagJoel Kitching2019-10-204-39/+17
| | | | | | | | | | | | | | | | | | | | | vboot1 FWB_TRIED flag is unused and replaced by vboot2 TRY_COUNT. Remove related test cases. Rewrite a special case for preventing kernel version roll-forward with combined firmware+kernel updates. BUG=b:124141368, chromium:1010389, b:35575422 TEST=make clean && make runtests BRANCH=none Change-Id: I9300def8bb426868b5e4d687d9c86e85c0c9b2c0 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1833369 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* tests: Add cgpt fuzzer.stabilize-12607.6.Bstabilize-12607.5.Bstabilize-12607.3.Bstabilize-12607.15.BMattias Nissler2019-10-172-0/+108
| | | | | | | | | | | | | | This adds a fuzzer binary to exercise GPT parsing. BUG=chromium:1014101 TEST=Build and run fuzzer. BRANCH=none Change-Id: Idecc0ddf491e976d4e01f5778e51a01ac317d961 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1859595 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Manoj Gupta <manojgupta@chromium.org> Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
* futility: updater: Try to update only EC RO when software sync is availableHung-Te Lin2019-10-161-1/+43
| | | | | | | | | | | | | | | | | | | | | For devices with EC that will reset TCPC during sysjump, updating firmware in recovery mode may cause problems. However, for developers manually updating firmware in developer mode (Ctrl-U), the EC firmware should be running in EC RO and we may have a chance to update successfully. BRANCH=None BUG=b:141965252 TEST=Boot device in recovery mode and run futility -i image.bin -e ec.bin; see correct message and then I/O error. Boot device in developer mode (Ctrl-U) and run futility -i image.bin -e ec.bin; see correct message. Cq-Depend: chromium:1837564 Change-Id: I9aa79df35094ab0c8eecc68c6652327d3325246a Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1835487 Reviewed-by: Joel Kitching <kitching@chromium.org>
* cgpt: Change stateful partition type GUID to TYPE_LINUX_FSstabilize-12593.Bfactory-kukui-12587.BHung-Te Lin2019-10-093-3/+5
| | | | | | | | | | | | | | | | | | | | | The TYPE_BASIC_DATA (called TYPE_LINUX_DATA before) is used by both Windows and Linux systems, and has caused problems when dual-booting. Modern Linux systems have been changed to TYPE_LINUX_FS. In Chrome OS, we usually find the stateful partition by number (1) instead of searching by type, so it should be fine simply replacing default mapping in the cgpt tool. BUG=chromium:944389 TEST=sudo emerge vboot_reference; make runtests BRANCH=None Change-Id: If18ff5180cbae5cdea8104f36203cffcf34db934 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1535456 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Matt Delco <delco@google.com> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Make vboot_version extern in headerLeonard Chan2019-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | When enabling `-fno-common` in Fuchsia, we get a bunch of linker errors when linking futility: ``` ld.lld: error: duplicate symbol: vboot_version >>> defined at futility.h:43 (../../third_party/vboot_reference/futility/futility.h:43) >>> host_x63-asan_no_detect_leaks/obj/third_party/vboot_reference/futility/futility.cmd_bdb.c.o:(vboot_version) >>> defined at futility.h:43 (../../third_party/vboot_reference/futility/futility.h:43) >>> host_x64-asan_no_detect_leaks/obj/third_party/vboot_reference/futility/futility.cmd_create.c.o:(.bss.vboot_version+0x0) ``` and think this is because -fno-common places vboot_version for unitialized global variables in the BSS section of each object file. Making it extern instead resolves each reference to its definition in futility/misc.c. Change-Id: I591f07abd1f975a8a9d078bb4366e2e0861390b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1839207 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Tested-by: Julius Werner <jwerner@chromium.org>
* vboot: remove VbVerifyMemoryBootImage functionJoel Kitching2019-10-024-490/+0
| | | | | | | | | | | | | | | Previously used for fastboot. BUG=b:124141368, chromium:995172 TEST=make clean && make runtests BRANCH=none Change-Id: I960932526bbd4482707125700cfa63e94c9f356b Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776290 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove linktest filesJoel Kitching2019-10-024-180/+4
| | | | | | | | | | | | | | | | Remove linktest files, which were previously used to ensure that firmware lib doesn't rely on outside libraries. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I694ca51007b05213d4b105f183bb34ad25e2ddbd Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1813123 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: join vb2_fail and vb2api_failJoel Kitching2019-10-0211-69/+58
| | | | | | | | | | | | | | | | As previously discussed with jwerner@, API functions should not distinguish between "internal" and "external" versions. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Iea4fb430dbd56110639f52bdb7d8d3aaae7ee293 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1830240 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: fix compile error with MOCK_TPMstabilize-12560.BJoel Kitching2019-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | In CL:1773088, we jumped the gun on an update to using the context object in RollbackFwmpRead, before actually updating the function to take vb2_context as an argument (which will occur in CL:1728298). BUG=b:124141368, chromium:972956 TEST=make clean && MOCK_TPM=1 make runtests BRANCH=none Change-Id: I0e1db6eafea169e73a806094ec6f385254fa563f Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1830238 Tested-by: Joel Kitching <kitching@chromium.org> Tested-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Ronak Kanabar <ronak.kanabar@intel.corp-partner.google.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* x86/crossystem_arch: Free file descriptor if we fail to use itPatrick Georgi2019-09-271-2/+6
| | | | | | | | | | | | | | | Found by Coverity Scan #204275 BUG=none BRANCH=none TEST=Coverity run after this merged marks #204275 fixed Change-Id: I50e6300eabaf6bd0c1230b0cbd2d375ab1daf5d2 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1827293 Reviewed-by: Duncan Laurie <dlaurie@google.com> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org>