summaryrefslogtreecommitdiff
path: root/firmware
Commit message (Collapse)AuthorAgeFilesLines
* vboot/secdata: remove TPMClearAndReenable function mockJoel Kitching2019-09-051-6/+0
| | | | | | | | | | | | | | | | | | | This function is only used internally in rollback_index.c and thus does not need a mock. (It does need to be listed in rollback_index.h since it must be accessible by tests.) BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: Ib7ce907da82608de7e5c6c2be11c57bf353ca0b3 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1780088 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/secdata: fix up macros in rollback_index.cJoel Kitching2019-09-051-10/+6
| | | | | | | | | | | | | | | | Remove the unnecessary offsetof declaration in rollback_index.c, and fix some macro formatting. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I156a0561070e03f978fff307d3dbfafde09e0adf Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1773093 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: add mocked TlclDefineSpaceEx functionJoel Kitching2019-08-311-0/+11
| | | | | | | | | | | | | | | | | | | Allows the case of FIRMWARE_ARCH= TPM2_MODE= MOCK_TPM=1 to compile. Also wrap TlclUndefineSpace in #ifdef CHROMEOS_ENVIRONMENT to match its non-mocked definition. BUG=b:124141368, chromium:997132 TEST=make clean && TPM2_MODE= MOCK_TPM=1 make runtests BRANCH=none Change-Id: I681dcb239c0bff9530df84a0a4f848e73384c798 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1773095 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/secdata: fix 2secdata.h includesJoel Kitching2019-08-315-4/+4
| | | | | | | | | | | | | | | | | | | | Get rid of vb2_context forward declaration and vb2_error_t redefinition from 2secdata.h, and properly include 2api.h instead. Remove 2secdata.h from 2api.h (should not be publicly accessible), and add 2secdata.h include to appropriate files. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I15570488fdabfcd9a178a0cedc7868b8c23720e9 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776285 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/secdata: rename secdata and secdatakJoel Kitching2019-08-3118-411/+459
| | | | | | | | | | | | | | | | | | | | | | | For clarity's sake, rename: secdata -> secdata_firmware secdatak -> secdata_kernel secdata is now the general term to refer to any secure data spaces: firmware, kernel, and FWMP. Once coreboot code has been updated, the sections in 2api.h and 2constants.h may be removed. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I376acee552e8be37c75c340626a95462f81e198b Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1773079 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: deprecate fastboot supportJoel Kitching2019-08-308-68/+22
| | | | | | | | | | | | | BUG=b:124141368, chromium:995172 TEST=make clean && make runtests BRANCH=none Change-Id: I42e4ac8a21ac3be416d315a8a8cc914f997bab79 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758148 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* Fix fall through warning reported by ToT clang.Manoj Gupta2019-08-283-3/+24
| | | | | | | | | | | | | | | | | | | | Clang is diagnosing implicit fallthrough in C code past https://reviews.llvm.org/rL369414. Detect the support for the fallthrough attributes in gcc/clang and enable it as VBOOT_FALLTHROUGH (copied from boringssl). This is needed to fix ToT clang builds. Note: GCC apparently does not diagnose fallthrough to another case with break but clang does (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432). And clang does not detect the fallthrough based on code comments. Bug: chromium:997709 Test: CQ Change-Id: Id8b4be4deabca2d0f1b2efd80efa72a485a5dc8c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1772474 Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@chromium.org> Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
* vboot: remove more Alt OS codeJoel Kitching2019-08-284-10/+2
| | | | | | | | | | | | | | | BUG=b:124141368, b:131663912, b:139392536 TEST=make clean && make runtests BRANCH=none Change-Id: I91eab08130786188b0a7c514b35574c611863b03 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758147 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: remove DISABLE_ROLLBACK_TPM constantJoel Kitching2019-08-282-48/+5
| | | | | | | | | | | | | | | | | | | | | | | | | This constant triggered different implementations of the two functions RollbackFwmpRead and RollbackKernelLock, whose overridden implementation would then be relied on in various tests. Instead, directly override these functions within the tests where they are required. The overridden implementations were also used in utilities/load_kernel_test.c, but this utility is currently broken and not in active use. If we would like to get it working again, simply override these two functions directly in the C file, just as is done for unit tests. (See b:139839429.) BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I0a4d24ea4ae4182b7f4f258860de6f712dae1555 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1765169 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: fix up some headers, includes, comments, spacingJoel Kitching2019-08-2848-133/+143
| | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Id97f544da845f7070555e5e8cc6e782b2d45c300 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758151 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: remove VbUnlockDevice functionJoel Kitching2019-08-283-25/+4
| | | | | | | | | | | | | | | | VbUnlockDevice is only used in fastboot. Currently fastboot "unlocking" is disabled (see CL:1757973). BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I0de44c2bb8d8150dafb0b73e7a0be6e63564a26b Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758150 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: fix up 2secdata{,k} and testsJoel Kitching2019-08-285-47/+50
| | | | | | | | | | | | | | | | These are not yet used in production and need some fixing up first. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: Ifbd0e761cc5bc05437bfed774fb15d5e8ef1b8e7 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758149 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: add mocked TlclUndefineSpace functionJoel Kitching2019-08-261-0/+5
| | | | | | | | | | | | | | | | | | | vboot_reference fails to compile with MOCK_TPM=1 due to a lack of TlclUndefineSpace function in mocked_tlcl.c. Add the function to fix this issue. BUG=b:124141368, chromium:997132 TEST=make clean && make runtests BRANCH=none Change-Id: If290767a25f1ac6f02e3d8f78373a77da8567c87 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1768378 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: replace sysincludes.h with 2sysincludes.hJoel Kitching2019-08-2226-67/+15
| | | | | | | | | | | | | | | | | | | | | sysincludes.h and 2sysincludes.h are almost identical except for one extra header (ctype.h) in the vboot1 variant. Add this to 2sysincludes.h, and nuke sysincludes.h. Depends on: https://review.coreboot.org/c/coreboot/+/33525 BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Iaba21a9b8bb2ae0c081184019576663898317bd1 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1680325 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1659990 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Auto-Submit: Joel Kitching <kitching@chromium.org>
* vboot/secdata: move permissions and uid check to ReadSpaceKernelJoel Kitching2019-08-211-24/+19
| | | | | | | | | | | | | | | | | | Relocate permissions and uid check from RollbackKernelRead to ReadSpaceKernel. Restructure test code to set default values in ResetMocks. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I72c536042b89684c6db5099412344678e3d9d920 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758146 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: print secdata/secdatak on reads and writesJoel Kitching2019-08-211-0/+12
| | | | | | | | | | | | | | | | This makes it clear exactly when reads/writes are occurring, with what values. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I614204cc19d2c90d2ac5799f136daf251a45e251 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728299 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/secdata: fix up error reporting in rollback_index.cJoel Kitching2019-08-211-16/+42
| | | | | | | | | | | | | | | Every failure case should output some debug information. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I0f178fa72f7e227b3abc22ac1b0d2df5ed4a6dc8 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1738348 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: remove legacy version checks on rollback spacesJoel Kitching2019-08-211-30/+4
| | | | | | | | | | | | | | | | | The code to deal with version < 2 rollback spaces has been around since 2013. Legacy devices will not be updating to this code, thus we can remove the legacy silent upgrade. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I8ce22c37418ddc56cb74cc792540b54b3ee7bbd7 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1727949 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* 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>