summaryrefslogtreecommitdiff
path: root/firmware
Commit message (Collapse)AuthorAgeFilesLines
* Makefile: Enable linker garbage collectionJulius Werner2019-08-163-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enables -ffunction-sections, -fdata-sections and -Wl,--gc-sections for host builds. These flags already get passed by firmware builds anyway, so having host builds match that behavior should be a good idea in general. They may also occasionally help save a bit of code size (though not much since vboot is a library, but I still get about half a KB out of futility), and they will prevent clang from omitting relocations for function calls inside the same file, which means we don't have to splatter test_mockable all over our codebase anymore. (We still need it for vb2_get_gbb() since that is so small that both GCC and clang want to inline it, even if they are outputting a discrete copy anyway.) (Also add a comment about why GenerateGuid() has nothing do to with this even though it is also a weak function, and why it is like that.) BRANCH=None BUG=chromium:991812 TEST=make runtests with both GCC and clang Change-Id: Iede9d29e20b99b75a0c86bc7ecb907d2a0e5e3a1 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1754969 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* vboot: vb2_shared_data offsets should hang off parentstabilize-12428.BJoel Kitching2019-08-1610-96/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | vb2_shared_data struct has many offsets to other objects in the workbuf. They are all prefixed with `workbuf_`, e.g.: uint32_t workbuf_data_key_offset; uint32_t workbuf_data_key_size; In order to adhere to a hierarchical structure on the workbuf, remove the workbuf_ prefix from these symbols to reflect the relationship between vb2_shared_data and its children more accurately. Create a helper function vb2_member_of to safely look up a child of a particular object in the workbuf by offset. Pointer arithmetic to find vb2_shared_data children is replaced with calls to this function. BUG=b:124141368, chromium:994060 TEST=make clean && make runtests BRANCH=none Change-Id: Ia82417a35d2067ee5e4f42fea0396e6325127223 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1753400 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1718264 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/secdata: rename identifier in RollbackFwmpRead for clarityJoel Kitching2019-08-141-12/+12
| | | | | | | | | | | | | | | | | | A union is used with a buffer and a pointer to the RollbackSpaceFwmp object in question. Rename `bf` to `fwmp` to reduce confusion between the two identifiers which are presumably both abbreviations for "buffer". BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I0cdd8fed77087ff36cc4ca74ec847e65398f8a6b Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1751062 Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: remove unused and deprecated vboot1 error codesfirmware-mistral-12422.BJoel Kitching2019-08-131-33/+1
| | | | | | | | | | | | | BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I59b5646a79769cb9fafdecd904021a5df85906b6 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728295 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: properly check failure from VbExGetLocalizationCountJoel Kitching2019-08-131-3/+2
| | | | | | | | | | | | | | | | | Check the return value and result of calling VbExGetLocalizationCount. If something is awry, fall back to using one language entry. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ieeea54bfed303a98d16f15aceab47f1ffdd10d6d Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1729773 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/secdata: remove retries from rollback functionsJoel Kitching2019-08-131-156/+84
| | | | | | | | | | | | | | | | Assume that transport-layer communication to Cr50 is reliable. No need for retries on reads/writes, or verification after write. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: Ie57d1eeaa44c338bca289e371c516540aacf9437 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1729713 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: replace VBERROR_INVALID_PARAMETER with vboot2 equivalentJoel Kitching2019-08-132-3/+1
| | | | | | | | | | | | | | | | | Replace vboot1-style VBERROR_INVALID_PARAMETER with vboot2 equivalent VB2_ERROR_INVALID_PARAMETER. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I46227cd3a7d7ce84654a0093f9d64883c9563381 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728116 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728294 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace VBERROR_SIMULATED with VB2_ERROR_MOCKJoel Kitching2019-08-131-2/+0
| | | | | | | | | | | | | | | Replace vboot1-style VBERROR_SIMULATED with VB2_ERROR_MOCK. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I9f7a21b957097672883a428a5210c14a27852085 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722917 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace VBERROR_UNKNOWN with VB2_ERROR_UNKNOWNJoel Kitching2019-08-137-13/+12
| | | | | | | | | | | | | | | | Replace vboot1-style VBERROR_UNKNOWN with VB2_ERROR_UNKNOWN. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Icd2158e328142cff69ce94b5396ab021a1f7839c Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728115 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722916 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace VBERROR_SUCCESS with VB2_SUCCESSJoel Kitching2019-08-1319-124/+121
| | | | | | | | | | | | | | | | | Replace vboot1-style VBERROR_SUCCESS with VB2_SUCCESS (trivial change since both are equal values). BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: I46e02471a031e9f36ec869d11d0b957d1c1b5769 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728114 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722915 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: fix use of SetVirtualDevMode return valuesJoel Kitching2019-08-134-4/+4
| | | | | | | | | | | | | | | | | SetVirtualDevMode returns vboot error codes, and not TPM error codes. Existing code just so happens to work, since TPM_SUCCESS == VBERROR_SUCCESS. BUG=b:124141368, chromium:988410 TEST=Build locally BRANCH=none Change-Id: Ifc819fdea4e23824d8e6fcf211d7bf66f33cd069 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728293 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: update vboot2 functions to use new vb2_error_tJoel Kitching2019-08-1345-460/+410
| | | | | | | | | | | | | | | | | | To make explicit when vboot2 error codes should be returned, use the new vb2_error_t type on all functions which return VB2_ERROR_* constants. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Idd3ee8afe8c78347783ce5fa829cb78f1e5719e2 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728113, chromium:1728499 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728292 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* firmware/lib: Add fall through commentsJacob Garber2019-08-072-0/+3
| | | | | | | | | | | | | | | | Implicit fall throughs are a source of Coverity Scan issues, so add comments to mark these instances as intentional. BUG=none TEST=make clean && make runtests BRANCH=none Change-Id: Ic302dcf8998fb1081e5b8258ba703a7527911eee Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 198900 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1740446 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: rename VbError_t typedef to vb2_error_tJoel Kitching2019-08-0619-216/+213
| | | | | | | | | | | | | | | | | | | | | | As part of the conversion of error codes from vboot1 to vboot2, replace all instances of VbError_t with vb2_error_t. vboot2 currently uses the int type for return values, but we would like to implement the use of vb2_error_t instead, which is potentially clearer than simply using an int. Existing functions will be converted to use vb2_error_t in a subsequent CL. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Iee90d9a1f46bcf5f088e981ba6ddbcf886ff0f18 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728112 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722914 Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot/tpm: fix return type inconsistenciesJoel Kitching2019-08-064-15/+26
| | | | | | | | | | | | | | | | | | | TPM errors and vboot errors were getting mixed up. Note that this patch changes a function signature in the vboot1 API. Any callers of the function should be updated accordingly. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Idf332ca9ac61b5771fccf9e2ce75e8689c0aace9 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1730374 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1729712 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: join vboot1 and vboot2 errors into same enumJoel Kitching2019-08-066-104/+101
| | | | | | | | | | | | | | | | | | | | It's extremely hard to accomplish anything with two different sets of error codes. Since the two error code sets don't overlap, merge them into the same enum (vb2_return_code). The next step is to get rid of VbError_t and have all functions consistently return vboot2-style int. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Ie34ac2c30e5d73fe886628e3150cf63543d520af Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728117, chromium:1735666 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722913 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: deprecate VbExError functionJoel Kitching2019-07-243-39/+4
| | | | | | | | | | | | | | | | Convert uses of this function to call VB2_DEBUG and manually exit if necessary. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I9006b1a9c66645757d33310d96207233b88eaed5 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1710340 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: remove Boot Descriptor Block (BDB) library and utilitiesJoel Kitching2019-07-2421-3451/+0
| | | | | | | | | | | | | | | | Remove unused BDB code, previously created for a cancelled SoC project. BUG=b:124141368, chromium:986177 TEST=make clean && make runtests BRANCH=none Change-Id: I91faf97d9850f8afb816fa324ad9a4d9f3842888 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1710336 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/vboot_display: retrieve from vboot2 data structures when availableJoel Kitching2019-07-221-6/+6
| | | | | | | | | | | | | | | | | | | Preference for vboot2 data structures when available: sd->recovery_reason sd->fw_version_secdata sd->kernel_version_secdatak BUG=b:124141368, b:124192753 TEST=make clean && make runtests BRANCH=none Change-Id: Ifdd77947cabb75e8ac5a838b75cbcd643c6e481e Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1680190 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: remove VbPublicKey structJoel Kitching2019-07-104-33/+32
| | | | | | | | | | | | | | | Update all references to vboot2-style struct vb2_packed_key. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I55a5f6bf315bdb4b83a998759d3732077283998e Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675871 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: replace Min macro with VB2_MINstabilize-12331.BJoel Kitching2019-07-063-13/+14
| | | | | | | | | | | | | | | | Replace old vboot1-style Min macro with VB2_MIN, and relocate tests accordingly. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I73d630147eaf23f97dd750769fb1e911dae01848 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675866 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* firmware: Print GBB flags at the start of kernel verificationJulius Werner2019-06-281-0/+2
| | | | | | | | | | | | | | | I've had dozens of instances over the years where I had been wondering what GBB flags a given firmware log was running with. Let's just print them. BRANCH=None BUG=None TEST=Booted Cheza. Change-Id: I631dbcffd16f189731ed5881782722e1eec8eb83 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1674967 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: remove VerifyMemberInside functionstabilize-12301.BJoel Kitching2019-06-263-42/+7
| | | | | | | | | | | | | | | | | | Use vboot2-style vb2_verify_member_inside instead. Correct some strings in vboot2 tests to refer to new vboot2 functions instead. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Idb3bcf1657c9d955acc6f93983c7b0c7f06427e3 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675870 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove vboot1 version of ARRAY_SIZE macroJoel Kitching2019-06-261-4/+0
| | | | | | | | | | | | | | | | Macro already exists in vboot2-style 2common.h. Relocate tests accordingly. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I6b96627a05e8c05ff49b8780fe4472890c2a2043 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675869 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: remove OffsetOf functionJoel Kitching2019-06-263-13/+2
| | | | | | | | | | | | | | | Should use vboot2 equivalent instead: vb2_offset_of BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I64afc88477cbb615a661833f45761030c55fcdf6 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675868 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: remove unused CombineUint16Pair functionJoel Kitching2019-06-261-7/+0
| | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ifd7dcc1414248b025a8a4bc2942db11814bc8be5 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675865 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: remove vboot1-style VbExDebug functionJoel Kitching2019-06-262-15/+0
| | | | | | | | | | | | | | | Should use VB2_DEBUG macro instead (which uses vb2ex_printf). BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ia6da51b597cb02d178ab3906022f1f4075b99a60 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675864 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: remove VbCommonParams structJoel Kitching2019-06-242-39/+0
| | | | | | | | | | | | | | | | | | | | | | VbCommonParams is now a relic of the past. It was originally used to pass data to VbInit, VbSelectFirmware, VbSelectAndLoadKernel, and VbVerifyMemoryBootImage. The former two are long deprecated and removed, while the latter two now pass information via the vb2_context struct. BUG=b:124141368, b:124192753 TEST=make clean && make runtests BRANCH=none Change-Id: Ie72f1a5308dea4f9abf2738f104cf373d1030623 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1663749 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1663893 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Auto-Submit: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* lib/ec_sync_all: Reboot EC to RO after successful AUX FW updateKarthikeyan Ramasubramanian2019-06-191-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | Currently some chips that require AUX FW update request EC reboot to RO after the FW update is applied successfully while some chips do not. It is safe to request EC reboot to RO whenever AUX FW update is applied successfully so that all the chips that require AUX FW update gets reset to a clean state. Update tests to handle the updated code flow and return code correctly. BUG=b:128820536,b:119046668 BRANCH=None TEST=Ensure that the device boots to ChromeOS. Force a TCPC FW update and ensure that after it is successfully applied EC reboots to RO. Cq-Depend: chromium:1625866 Change-Id: I72849620d90284e49cd1a9b31fc5eadede455c51 Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/1627302 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Commit-Ready: Karthikeyan Ramasubramanian <kramasub@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: fix vb2_gbb_read_recovery_key to save into intJoel Kitching2019-06-182-20/+22
| | | | | | | | | | | | | | | | | Return value of vb2_gbb_read_recovery_key should be saved into an integer, not into vboot1-style VbError_t. BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: Icbe622c9958d3f303da0faf7b52b0ce52c2b16a5 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1648093 Tested-by: Joel Kitching <kitching@chromium.org> Auto-Submit: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* lib/vboot_kernel: Log speed at which kernel was loadedRaul E Rangel2019-06-181-1/+9
| | | | | | | | | | | | | | | | | | | This makes it easy to spot the speed at which the eMMC controller is running. vb2_load_partition: read 8419 KB in 48 ms at 174342 KB/s. The calculation looks a little funky because I wanted to perform all multiplications before the division to avoid losing any precision. BRANCH=grunt BUG=b:122244718 TEST=Verified it on grunt Change-Id: I5fac584994bc478bfb27cbd4e2ea34af0be7f1d9 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1661366 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: add vb2api_gbb_get_flags functionJoel Kitching2019-06-142-0/+17
| | | | | | | | | | | | | | BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: I7b422e8a26621720a6b7efc5211629996a6aa385 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1659989 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Auto-Submit: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: export offset and type of GBB struct flags memberJoel Kitching2019-06-142-6/+16
| | | | | | | | | | | | | | | | | | | Export information about vb2_gbb_header's flags member: * vb2_gbb_flags_t * VB2_GBB_FLAGS_OFFSET BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: I2923156edd06df02751ccded5dcbb5bf8fe0207d Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1657503 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Auto-Submit: Joel Kitching <kitching@chromium.org>
* vboot: correct VB2_SECDATAK_SIZE constant to 13Joel Kitching2019-06-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This constant was incorrectly set to 14, whereas sizeof(vb2_secdatak) is 13. Update the constant its correct value, and add a test for each of secdata and secdatak to check the constant values. Previously, this constant was not used anywhere. The secdatak space is created and initialized in coreboot with a hard-coded (correct) size and initial value. So there should be no worry about devices out in the field with TPM secdatak size set to 14. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I0a6072aef2de401bd3cd40ac3b002f754da19560 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1655049 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* vboot: expose vb2api_secdatak_check and vb2api_secdatak_createJoel Kitching2019-06-136-75/+19
| | | | | | | | | | | | | | | | | | | | | | Previously vb2api_secdatak_check and vb2api_secdatak_create had headers in 2api.h, but no definitions. Merge identical internal/external functions: vb2api_secdata_create, vb2_secdata_create_crc vb2api_secdata_check, vb2_secdata_check_crc vb2api_secdatak_create, vb2_secdatak_create_crc vb2api_secdatak_check, vb2_secdatak_check_crc BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I64a14d65e5d856ca0f819ef3ded50b4719abc8b3 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1652874 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* vboot: rewrite GBB functions and APIJoel Kitching2019-06-0714-194/+257
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Old vboot1-style GBB accessor functions were awkwardly located within region-init.c. Rewrite GBB accessor functions for vboot2, and formally expose HWID retrieval function via vboot2 API. workbuf is used for key retrieval functions, while a buffer provided by the caller is used for HWID retrieval function. Reintroduce vboot_display_tests to `make runtests` test suite. Move GBB tests from vboot_display_tests to vb2_gbb_tests. Properly propagate vb2_workbuf objects within the function call stack (vb2_load_partition). BUG=b:124141368, chromium:954774 TEST=Build and flash to eve, check that Chrome OS boots TEST=Build with CL:1627469 applied, check HWID TEST=make clean && make runtests BRANCH=none Change-Id: I398d1329f0b092de35aac73d98dfd9aee6e4e7de Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1584488 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Jason Clinton <jclinton@chromium.org>
* vboot: don't unset VB2_NV_DISPLAY_REQUEST in EC syncJoel Kitching2019-06-072-38/+5
| | | | | | | | | | | | | | | | | | | | | | VB2_NV_DISPLAY_REQUEST disabling code has been relocated to VbBootNormal. Remove from EC sync code. Remove the vb2_shared_data argument from check_reboot_for_display. Avoid calling ec_sync_check_aux_fw after phase 1 if already certain that a reboot is required. BUG=b:124141368, chromium:948592, chromium:967298 TEST=make clean && make runtests BRANCH=none Change-Id: Ia5472aceb0b2a415f24dd76d26179632009d07cb Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1634453 Commit-Queue: Jason Clinton <jclinton@chromium.org> Tested-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: don't use VB2_NV_DISPLAY_REQUEST for diagnostic modeJoel Kitching2019-06-072-28/+15
| | | | | | | | | | | | | | | | | Display initialization code now directly checks VB2_NV_DIAG_REQUEST. There is no need for diagnostic mode flow to set VB2_NV_DISPLAY_REQUEST. BUG=b:124141368, chromium:948592, chromium:967298, b:133175864 TEST=make clean && make runtests BRANCH=none Change-Id: I9748bf03c11c5698c181c177634d73fb34fd2d59 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1634452 Commit-Queue: Jason Clinton <jclinton@chromium.org> Tested-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: check display init when entering normal modeJoel Kitching2019-06-071-0/+30
| | | | | | | | | | | | | | | | | | In order to simplify code which uses VB2_NV_DISPLAY_REQUEST, centralize disabling this NVRAM flag to a function called at the start of VbBootNormal. Also disable VB2_NV_DIAG_REQUEST here, since display init is enabled for this request as well. BUG=b:124141368, chromium:948592, chromium:967298, b:133175864 TEST=make clean && make runtests BRANCH=none Change-Id: I8aa7c44671ada23c0500cd8a0c5d7f737298bb11 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1634451 Commit-Queue: Jason Clinton <jclinton@chromium.org> Tested-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: check for VB2_NV_DIAG_REQUEST when enabling displayJoel Kitching2019-06-071-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | VB2_NV_DISPLAY_REQUEST should only be used for cases where there is no other way for coreboot to tell that display initialization is required. In the case of developer, recovery, and diagnostic modes, display should always be initialized without looking at VB2_NV_DISPLAY_REQUEST. In the case of EC slow sync, VB2_NV_DISPLAY_REQUEST should still be used. BUG=b:124141368, chromium:948592, chromium:967298, b:133175864 TEST=make clean && make runtests BRANCH=none Change-Id: I56e7d50bfd7de596d25ba232251f73ccd2d5df9b Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1634450 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Jason Clinton <jclinton@chromium.org>
* vboot: move vb2_packed_key and several functions from lib20 to 2libJoel Kitching2019-06-079-122/+142
| | | | | | | | | | | | | | | | | | | * Move vb2_packed_key from vb2_struct.h to 2struct.h * Move vb2_verify_member_inside from lib20/common.c to 2common.c * Move vb2_packed_key_data and vb2_verify_packed_key_inside from lib20/packed_key.c to 2packed_key.c * Relocate tests accordingly BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I6a9338ffdb640aad071941c3768427e15cd2aa93 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1642773 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: deprecate and remove VbInitParamsstabilize-12249.Bstabilize-12239.19.BJoel Kitching2019-05-291-17/+1
| | | | | | | | | | | | | | | | | | | Keep VB_INIT_OUT_* constants which are still currently used by vboot_handoff.out_flags. They can be removed once vboot_handoff has been completely sunsetted. BUG=b:124141368, chromium:960226 TEST=make clean && make runtests BRANCH=none Change-Id: I8bf2d3330a09c971fd26406737a656b4b3221779 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1599565, chromium:1598588 Reviewed-on: https://chromium-review.googlesource.com/1597369 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Joel Kitching <kitching@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware/lib/ec_sync_all: Refactor the EC SW Sync flowKarthikeyan Ramasubramanian2019-05-281-28/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Perform all the operations regarding EC AUX FW update once the EC update is applied and EC has jumped to the updated image. This way the information regarding the devices that require EC AUX FW update can be probed and obtained from EC consistently. BUG=b:128820536,b:119046668 BRANCH=None TEST=Ensure that the device boots to ChromeOS. Ensure that the Aux FW update is handled after EC update is applied and jumped to the updated EC image. Casta: sync_one_ec: jumping to EC-RW send_packet: CrosEC result code 12 EC returned from reboot after 53061us ps8751.0: vendor 0x1da0 product 0x8751 device 0x0001 fw_rev 0x39 ps8751.1: vendor 0x1da0 product 0x8751 device 0x0001 fw_rev 0x39 Bobba: sync_one_ec: jumping to EC-RW send_packet: CrosEC result code 12 EC returned from reboot after 52271us ps8751.1: vendor 0x1da0 product 0x8751 device 0x0001 fw_rev 0x39 Ampton: sync_one_ec: jumping to EC-RW EC returned from reboot after 43019us vb2_developer_ui: Entering vboot_draw_screen: screen=0x101 locale=0 Change-Id: I28956543dfe1e059e15212dceada8bc517c0e7fc Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/1592472 Commit-Ready: Karthikeyan Ramasubramanian <kramasub@chromium.org> Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* vboot: do not use cparams for VBSDJoel Kitching2019-05-283-30/+19
| | | | | | | | | | | | | | | | | | | | | Pass VbSharedDataHeader struct directly as an argument for the functions VbVerifyMemoryBootImage and VbSelectAndLoadKernel, instead of retrieving from cparams. After any remaining references are removed from depthcharge, the VbCommonParams struct may be deprecated and removed. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I4dceb539516b62b5817987359705bb8e27ddb6f3 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1585505 Reviewed-on: https://chromium-review.googlesource.com/1584489 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: save GBB header in workbuf during firmware verificationJoel Kitching2019-05-2815-87/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since GBB header will be needed for subsequent GBB reads later on (in kernel verification stage), and since GBB header is relatively small (128 bytes), save the full GBB header onto workbuf during firmware verification stage, and store an offset pointer to it in vb2_shared_data. vb2_gbb_header object may be accessed via the vb2_get_gbb function. Additionally, update functions in firmware/lib/region-init.c to read GBB data from flash, rather than using cparams passed in by depthcharge, which is slated for deprecation. BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: I6e6218231299ce3a5b383663bc3480b20f929840 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1585500 Reviewed-on: https://chromium-review.googlesource.com/1627430 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: remove deprecated GoogleBinaryBlockHeaderJoel Kitching2019-05-171-114/+0
| | | | | | | | | | | | | | | | | Use vboot vb2_gbb_header instead. Struct contents are identical. BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: I9047c683af176384da3ec135faecf35870351973 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1583943, chromium:1599828 Reviewed-on: https://chromium-review.googlesource.com/1583827 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* vboot: deprecate v1 GoogleBinaryBlockHeader structJoel Kitching2019-05-177-9/+2
| | | | | | | | | | | | | | | | | Deprecate internal usage of GoogleBinaryBlockHeader struct in favour of vb2_gbb_header struct. Keep the v1 struct around until we remove references in other repos. BUG=b:124141368, chromium:954774 TEST=make clean && make runtests BRANCH=none Change-Id: I396d2e624bd5dcac9c461cc86e8175e8f7692d26 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1583826 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: remove NEED_VB2_SHA_LIBRARY switchJoel Kitching2019-05-171-15/+1
| | | | | | | | | | | | | | | | Replaced with the external-facing header vb2_sha.h. BUG=b:124141368, chromium:956474 TEST=make clean && make runtests BRANCH=none Change-Id: Ib31c816ed8e2eb91c30080e854ec9245d59c98f2 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1599567, chromium:1583941, chromium:1610164 Reviewed-on: https://chromium-review.googlesource.com/1583825 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: de-externalize vb2_digest_buffer functionJoel Kitching2019-05-172-25/+0
| | | | | | | | | | | | | | | | | | | | | | Clients which wish to use this function may simply import the vb2_sha.h header to make all SHA library functionality available. Whether or not to make a full vb2api_ set of functions for SHA library should be considered in the future, but individual functions should not be added to the API as was done. BUG=b:124141368, chromium:956474 TEST=make clean && make runtests BRANCH=none Change-Id: I1dc8ed84ecfb621a57411975f312e96a695b68f4 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1583942 Reviewed-on: https://chromium-review.googlesource.com/1583822 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* vboot: hide 2common.h from external APIJoel Kitching2019-05-173-18/+17
| | | | | | | | | | | | | | | | | | 2common.h contains code which should be internal to vboot. Most notably of which is 2struct.h, which contains the vb2_shared_data data structure. BUG=b:124141368, chromium:956474 TEST=make clean && make runtests BRANCH=none Cq-Depend: chromium:1587981, chromium:1599567, chromium:1610164 Change-Id: I712f51915bb9b0b03dce558e2b843eb83662f434 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1583819 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>