summaryrefslogtreecommitdiff
path: root/host
Commit message (Collapse)AuthorAgeFilesLines
* vboot: move lib20/packed_key.c into 2lib namespaceJoel Kitching2021-01-205-5/+0
| | | | | | | | | | | | | | | | | | | lib20/packed_key.c functions are currently called throughout 2lib namespace, so move to 2lib/2packed_key.c. Move function declarations from vb2_common.h to 2packed_key.h, and include 2packed_key.h from 2common.h. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Signed-off-by: Joel Kitching <kitching@google.com> Change-Id: I151b2d41cbbfa1bfd03de301bd4ee69c49e81f3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2635220 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* Revert "Reland: Clean up implicit fall through."stabilize-rust-13613.BJulius Werner2020-11-201-1/+1
| | | | | | | | | | | | | | | | | | | This reverts commit 6208b9aa9c4e8b7c9ff8063965c9f9aa519c1740. Upstream coreboot has raised concerns that relying on GCC 7+ features for host utilities is too restrictive, so revert this and go back to customizing fallthrough annotations by compiler. Cleaned out some of the C++-specific stuff because vboot isn't built with C++. BRANCH=None BUG=None TEST=Built with clang and GCC. Change-Id: I75d796d289b0a6c249fc8ac2dadb1453be468642 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2547821 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem: support clear_tpm_owner_request on TPM2.0 simulatorYi Chou2020-10-281-3/+31
| | | | | | | | | | | | | | | | | | | | | | | | | This CL would give VM boards the ability to hard reset TPM. When clearing TPM ownership on real devices, there are two things would happen: 1. TPM reset all of its NVRAM data. 2. mount-encrypted can't decrypt old encrypted partition. The TPM2.0 simulator put its NV space at "/var/lib/trunks/NVChip". And "/var/lib" is under encrypted partition. Remove the mount-encrypted key would cause mount-encrypted lost the encrypted partition on next boot, and it would simply achieve those two targets. BUG=b:170785530 BRANCH=none TEST=crossystem clear_tpm_owner_request=1 Cq-Depend: chromium:2501904 Signed-off-by: Yi Chou <yich@google.com> Change-Id: Ifeff0cf03bf76706849905816d22024f3d1b952f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2470577 Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem: remove mosys nvstorage implementationJack Rosenthal2020-10-143-88/+0
| | | | | | | | | | | | | | As promised, it's October 2020, nyan_kitty went AUE with M85, and M86 just got pushed stable. That means we can now delete this code :) BUG=chromium:1090803 BRANCH=none TEST=compiles Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I5a15ef1e1ad02885af135d8e42d02d492bdd6c05 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2469604 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* lib21: always append '\0' in vb2_readfilestabilize-rust-13514.BHung-Te Lin2020-10-052-1/+3
| | | | | | | | | | | | | | | For utilities reading text file, it is easier to process as ASCIIZ input if vb2_readfile can always return a buffer ends with '\0' so we don't need to pass and check the size. BUG=None TEST=make clean && make runtests BRANCH=None Signed-off-by: Hung-Te Lin <hungte@chromium.org> Change-Id: Ib6294969fb325b9b7899e6295fb1817ad91a9952 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2426092 Reviewed-by: Joel Kitching <kitching@chromium.org>
* host: Make gpiochip path buffer largerJacob Garber2020-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | The name of a gpiochip can in theory be up to NAME_MAX characters long (usually 255), which exceeds the length of the 30 byte buffer allocated for it. In practice we won't need more than the 30 bytes, but the smaller buffer trips a -Wformat-truncation warning from GCC that makes the build fail. Make the buffer bigger to keep GCC happy. BUG=none BRANCH=none TEST=make utillib compiles on BeagleBone Black Change-Id: I528f395033f58057846e717ff126e7a5dca504e3 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2393193 Tested-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Commit-Queue: Joel Kitching <kitching@chromium.org>
* portability fixes: support building vboot on FreeBSDIdwer Vollering2020-09-112-0/+10
| | | | | | | | | | | Built on FreeBSD 12.1-RELEASE, 13-CURRENT, using gcc9 installed from packages. Change-Id: Ifa8bb343c7e916c1b545cf6c1e4bd0a18ea391cd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2382790 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* crossystem: allow last nvdata entry to be filledJack Rosenthal2020-09-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mosys used to have code (below), which led me to believe that we always try and leave the last entry unfilled: memset(blank, 0xff, VBNV_BLOCK_SIZE); for (index = 0; index < len / VBNV_BLOCK_SIZE; index++) { unsigned int offset = index * VBNV_BLOCK_SIZE; if (!memcmp(blank, &data[offset], VBNV_BLOCK_SIZE)) break; } if (index == 0) { lprintf(LOG_ERR, "VBNV is uninitialized\n"); return -1; } else if (index >= len) { <---- SEE NOTE lprintf(LOG_ERR, "VBNV is full\n"); <--- unreachable return -1; } else { return index - 1; } The statement at "SEE NOTE" will always be false, so this code fooled me to believe that we consider VBNV without a row of 0xFF*16 to be empty. And so I implemented and wrote unit tests for what I believed the correct behavior to be :/ Anyway, this is causing us issues since AP firmware does not implement it that way. So allow the last row to be filled. BUG=chromium:1112578 BRANCH=none TEST=unit tests Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ib3da78eddef69a688d081cdb5391a25000dac9d3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2402385 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* inclusive: change usage of sanityDaisuke Nojiri2020-08-194-4/+4
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the term "sanity" with inclusive alternatives. BUG=b:163883397 BRANCH=None TEST=grep -ir sanity TEST=make runtests Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I708a044d89050c442f14fb11a8ae5e98490d56af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2353420 Reviewed-by: Julius Werner <jwerner@chromium.org>
* host/lib/include/subprocess.h: Add `extern` to globalsAngel Pons2020-07-281-4/+4
| | | | | | | | | | | This prevents linker errors regarding multiple definitions. Change-Id: I62d6132c20ca2b9620a9f3b1539a1a0109c5aa26 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2318026 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* flashrom: set umask before creating temporary filesJack Rosenthal2020-07-201-0/+6
| | | | | | | | | | | | | | | Good security practice. Set to 077; resultant file permissions are: -rw------- BUG=b:160717634 BRANCH=none TEST=unit tests Change-Id: Ib3b853c824be4c98e7b9ddd31797104ec4ab67a9 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2302962 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* Allow building for non-CrOS environmentsPatrick Georgi2020-07-021-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's some code that is architecture specific, but looking at it, it's code for Chrome OS devices that just happens to be split along ISA lines. When building on systems that we don't ship crossystems integration for, these parts are replaced by stubs that always return error conditions, which allows building on unsupported ISA (such as POWER). The issue was reported at https://ticket.coreboot.org/issues/145 where a coreboot user wanted to build a vboot-enabled coreboot configuration (which builds futility for the signing part) on a POWER host system, which failed because we lack an implementation of the crossystem interfaces for POWER. BUG=none BRANCH=none TEST=Built upstream coreboot with a vboot-enabled target inside qemu-user-ppc64. Doing so works with these patches applied while it failed without them. Change-Id: I4aaeb56d4521c426a520bc9a1bb49497bec86c35 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2270096 Commit-Queue: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* host/lib/subprocess: replace constructor function & perror with VB2_DEBUGJack Rosenthal2020-06-181-13/+3
| | | | | | | | | | | | | | | | | | | | Currently this had perror to print the error message, but we can get rid of this and the constructor function reasonably if we switch to VB2_DEBUG. This was changed since the Loonix team cannot rely on glibc-specific behaviors, and passing argv to constructor functions is glibc-specific. See the notes on cl/316913250 for a little bit of background. BUG=none BRANCH=none TEST=unit tests Change-Id: I5de76306d5a8615fdc3afcfb772a2eb32557aa87 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2251039 Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem: arm: reland nvstorage using flashromJack Rosenthal2020-06-181-4/+6
| | | | | | | | | | | | | | | | | | This relands CL:2218891, which was reverted as the "mkbp" case was forgotten, and lit all sorts of stuff on fire when the CQ skipped hardware tests and the lab was accidentally soaked in gasoline. The devices which this affected are re-enabled in the lab, the CQ is now configured to enable hardware tests, so let's land it again ;) BUG=chromium:1032351,chromium:1030473,chromium:789276 BRANCH=none TEST=On scarlet and nyan_kitty, read and write using crossystem Change-Id: Ife4d17eeca484a2784f7e2b2f7c22fef27b9d083 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2251049 Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem - remove fmap_base utilityAaron Massey2020-06-162-13/+1
| | | | | | | | | | | | | | | | fmap_base utility no longer needed since b:157897361 BUG=chromium:1091253 BRANCH=none TEST=Compiled, cros_workon_make test, and cros deploy to kindred device to confirm there was no fmap_parameter. Change-Id: Idc89c82555531030beaf8f84ce483a5f49a86fbe Signed-off-by: Aaron Massey <aaronmassey@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2241386 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* host/lib/flashrom: enable --fast-verify for write operationsJack Rosenthal2020-06-161-0/+1
| | | | | | | | | | | | | | | | | | | We caused a boot-speed regression as we are currently verifying the entire flash chip after any write. Flashrom has an option --fast-verify which verifies only the region written, which is significantly faster. It also looks like this is the way mosys used to handle flashrom writes, so we can align with the old behavior this way. BUG=chromium:1091903 BRANCH=none TEST=unit tests, and boot speed regression went away (on octopus) Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: If8d2288cb0c08e8644b6e05f7b174c3c21542f94 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2242738 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: rename USB to more accurate EXTERNALYu-Ping Wu2020-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename enumerators of the vb2_dev_default_boot_target enum as follows, because the term USB is not quite accurate (we can also boot from an SD card). VB2_DEV_DEFAULT_BOOT_TARGET_DISK --> VB2_DEV_DEFAULT_BOOT_TARGET_INTERNAL VB2_DEV_DEFAULT_BOOT_TARGET_USB --> VB2_DEV_DEFAULT_BOOT_TARGET_EXTERNAL Also perform similar renaming for the following. enum vb2_nv_param: VB2_NV_DEV_BOOT_USB --> VB2_NV_DEV_BOOT_EXTERNAL enum vb2_secdata_fwmp_flags: VB2_SECDATA_FWMP_DEV_ENABLE_USB --> VB2_SECDATA_FWMP_DEV_ENABLE_EXTERNAL constants: VB2_NV_DEV_FLAG_USB --> VB2_NV_DEV_FLAG_EXTERNAL functions: vb2_dev_boot_usb_allowed --> vb2_dev_boot_external_allowed BRANCH=none BUG=none TEST=make runtests Change-Id: Iad16fcf34d76da08c6d8a81e150c7fde927c743b Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2237622 Reviewed-by: Joel Kitching <kitching@chromium.org>
* Revert "crossystem: arm: switch to VBNV using flashrom from mosys"Shik Chen2020-06-101-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 9a923c7dba003a5ddbc55937469c975689effa62. Reason for revert: https://crbug.com/1093191 Original change's description: > crossystem: arm: switch to VBNV using flashrom from mosys > > Most ARM platforms will store VBNV in SPI flash by calling out to > mosys, which in turn calls out to flashrom. > > The set of parent CLs to this commit port this functionality from > mosys directly to vboot's host libraries. This CL switches to use the > new functionality. > > (The CL to switch is provided as a separate CL for ARM only so it's an > easy and clean revert should something go wrong.) > > BUG=chromium:1032351,chromium:1030473,chromium:789276 > BRANCH=none > TEST=On scarlet, read and write VBNV using crossystem > > Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> > Change-Id: I1949522b665170ebeb35f3c46177f1957980d6a3 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218891 > Reviewed-by: Joel Kitching <kitching@chromium.org> Bug: chromium:1032351, chromium:1030473, chromium:789276 Change-Id: I3ccb6c6653e24e61072ee9227e870a2f211cd114 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2237617 Reviewed-by: Shik Chen <shik@chromium.org> Commit-Queue: Shik Chen <shik@chromium.org> Commit-Queue: Stimim Chen <stimim@chromium.org> Tested-by: Stimim Chen <stimim@chromium.org>
* crossystem: arm: switch to VBNV using flashrom from mosysstabilize-lazor-13278.BJack Rosenthal2020-06-091-4/+8
| | | | | | | | | | | | | | | | | | | | | Most ARM platforms will store VBNV in SPI flash by calling out to mosys, which in turn calls out to flashrom. The set of parent CLs to this commit port this functionality from mosys directly to vboot's host libraries. This CL switches to use the new functionality. (The CL to switch is provided as a separate CL for ARM only so it's an easy and clean revert should something go wrong.) BUG=chromium:1032351,chromium:1030473,chromium:789276 BRANCH=none TEST=On scarlet, read and write VBNV using crossystem Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I1949522b665170ebeb35f3c46177f1957980d6a3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218891 Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem: x86: switch to VBNV backup using flashrom instead of mosysJack Rosenthal2020-06-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Previously, x86 platforms with vboot2 will backup VBNV in SPI flash using mosys, which will in turn execute flashrom to preform the underlying operation. The set of parent CLs to this commit port this functionality from mosys directly to vboot's host libraries. This CL switches to use the new functionality. (The CL to switch is provided as a separate CL for x86 only so it's an easy and clean revert should something go wrong.) BUG=chromium:1032351,chromium:1030473,chromium:789276 BRANCH=none TEST=On octupus, write VBNV using crossystem and manually inspect RW_NVRAM region in SPI flash. Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I9f945dca99ebd394abea1490fa25d3763834bfa1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218890 Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem: add functions to read and write VBNV via flashromJack Rosenthal2020-06-092-0/+116
| | | | | | | | | | | | | | | | | | | | This will replace the usage of "mosys nvram vboot {read,write}" on x86 platforms, and all ARM platforms except veyron (chromebooks only) and nyan_kitty (which use VBNV storage in the ChromeOS EC, deprecated for new platforms). These affected ARM devices will be going AUE sometime this summer, and we can expect to remove the mosys usage in crossystem later this year. The code to find the active VBNV in SPI flash was modeled to match the logic in mosys (see mosys/lib/vbnv/vbnv_flash.c). BUG=chromium:1032351,chromium:1030473,chromium:789276 BRANCH=none TEST=provided unit tests Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I4f42af2f9a6b0703302635f8d8ebb2d7599d9847 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218889
* host/lib: add lightweight flashrom wrapper libraryJack Rosenthal2020-06-092-0/+208
| | | | | | | | | | | | | | | | | | | | | | Lightweight wrapper around flashrom, exposing two APIs: flashrom_read(programmer, region, data_out, size_out) flashrom_write(programmer, region, data, size) |region| can be NULL, in which case operate on the whole flash chip. The intended usage of this wrapper library is to read/write VBNV from SPI flash directly, avoiding the call thru mosys (which has deprecated the command). Bringing this logic into crossystem directly will also help with expanding VBNV to 64-bytes. BUG=chromium:1032351,chromium:1030473,chromium:789276 BRANCH=none TEST=provided unit tests Change-Id: I3997bd03a2db7e58e4e76fc200c637dd3b5b20a4 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2218888
* crossystem: add support for ADL gpiochipSubrata Banik2020-04-281-0/+3
| | | | | | | | | | | | | | On Alderlake platform, the pinctrl (gpiochip) driver label is "INTC105x:00", hence declare it properly. TEST=run 'crossystem wpsw_cur' and see '0' rather than an error on ADLRVP platform. Change-Id: I7c8ead83717b7be35ce68026768f6f0f5b1efa1c Signed-off-by: Subrata Banik <subrata.banik@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2167671 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Tested-by: Subrata Banik <subrata.banik@intel.corp-partner.google.com>
* crossystem: Add quirk reading wpsw_curLukasz Majczak2020-04-231-1/+46
| | | | | | | | | | | | | | | | | | | | | | | | As GPIO numbering has changed with kernel 4.16, so we have to change the finall offset when reading wpsw_cur. Before there was a gap (3.18): 0: INT33FF:02 GPIOS [373 - 384] PINS [0 - 11] and 12: INT33FF:02 GPIOS [385 - 396] PINS [15 - 26]a with 4.19 it looks like below: 0: INT33FF:02 GPIOS [314 - 325] PINS [0 - 11] and 12: INT33FF:02 GPIOS [329 - 340] PINS [15 - 26] BUG=b:143174998 BRANCH=none TEST=crossystem wpsw_cur (on Kefka) 1. with wp present it should return 1 2. without present wp it should return 0 Change-Id: I7c8ead83717b7be35ce68026768f6f0f5b0ff91c Signed-off-by: Lukasz Majczak <lma@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2153155 Reviewed-by: Brian Norris <briannorris@chromium.org> Commit-Queue: Brian Norris <briannorris@chromium.org>
* Rewrite algorithm type parsers and make them globally availableJulius Werner2020-04-065-158/+67
| | | | | | | | | | | | | | | | | | | | | There is some code strewn around between futility and the vb21-specific part of hostlib to allow parsing of textual algorithm names to vboot enums, but it is somewhat disorganized and not written in a super efficient way. This patch rewrites it and centralizes all the algorithm mapping stuff under 2crypto.c so it can be a single source of truth for all of vboot. (String parsing routines still need to stay in hostlib since not all firmware targets support things like stroul() and strcasecmp().) BRANCH=None BUG=None TEST=make runtests Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I719b2499992a6e4395a29231bc8b9a7680c5b174 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2099447 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: stop using StrnAppend and Uint64ToStringJoel Kitching2020-03-316-6/+0
| | | | | | | | | | | | | | | | | | | Use snprintf instead. Remove utility_string library. Also, prepare VbDisplayDebugInfo to handle 64-byte nvdata. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests TEST=boot with 16-byte nvdata, check <TAB> output (one line) TEST=boot with 64-byte nvdata, check <TAB> output (five lines) BRANCH=none Change-Id: If6c4b3a4e9fa7b71cb2d8ca7ccd37e4f36b97fd6 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:2122061 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2104880 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* host: add host library for accessing chromeos-configrelease-R82-12974.BJack Rosenthal2020-03-132-0/+164
| | | | | | | | | | | | | | | | | | | | Host side library for accessing chromeos-config. Initially, this will be used by futility to access the /firmware:image-name property during a firmware update. More background: go/mosys-firmware-name (note: despite the name "mosys" in the design doc, this is an effort to *not* rely on mosys during the firmware update) BUG=chromium:1061192 BRANCH=none TEST=provided unit tests Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ib8e5f8f836a93695e3b30731ae227501f37c4633 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2099449 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: stop reading from ACPI for wpsw_bootJoel Kitching2020-03-111-4/+0
| | | | | | | | | | | | | | | | Stop reading wpsw_boot value from ACPI as fallback for wpsw_cur. wpsw_cur is available on all non-EOL'd devices. BUG=b:124141368, chromium:950273, chromium:1059670 TEST=make clean && make runtests BRANCH=none Change-Id: I9c6f21b9f341a61e85db3e6e45b553b1ab4293e3 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2094807 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: stop using wpsw_boot and remove it from crossystemJoel Kitching2020-02-273-12/+1
| | | | | | | | | | | | | | | | | | wpsw_boot is being deprecated, so just use wpsw_cur. BUG=b:124141368, chromium:950273 TEST=make clean && make runtests BRANCH=none Change-Id: Iae63b2a76b19629a9ecd9b87e5dd6367767860b3 Cq-Depend: chromium:2066154, chromium:2068241, chromium:2068209 Cq-Depend: chromium:2068297, chromium:2067229, chromium:2067231 Cq-Depend: chromium:2068242 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2066192 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: clean up vboot_struct.hJoel Kitching2020-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | It only needs to contain VbSharedDataHeader definition, and it can be made private to vboot_reference now. Move kernel verification-related structs to vboot_kernel.h. Also, since the related constants VBSD_LF_CHECK_* are being removed in this CL, deprecate the RO_INVALID_RW_CHECK_MIN recovery reason, which was originally dismantled in CL:1863624. BUG=b:124141368, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: Ie6937cda6c3ba987031ba770ec9f1fb0ffa9cf3a Cq-Depend: chromium:2070292, chromium:2073461, chrome-internal:2634199 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2066302 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* crossystem: use wpsw_boot as fallback for wpsw_curJoel Kitching2020-02-262-0/+6
| | | | | | | | | | | | | | | | | | | In preparation for deprecating wpsw_boot, update wpsw_cur to use wpsw_boot as a fallback value. The source of wpsw_boot will still be deprecated on devices using new firmware, but in those cases, we are absolutely certain that wpsw_cur will work. BUG=b:124141368, chromium:950723 TEST=make clean && make runtests BRANCH=none Change-Id: I77ab9c6b827ef2c033ae46b7b01b12465101c0a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2071633 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: unmarry LoadKernel from VBSDJoel Kitching2020-02-141-104/+3
| | | | | | | | | | | | | | | | Create a function-local copy of VbSharedDataKernelCall rather than using the memory built-in to VBSD. Stop making any reference to vboot1 VBSD from LoadKernel. BUG=b:124141368, chromium:1038260 TEST=make clean && make runtests BRANCH=none Change-Id: I5dabfb33a0eb05c1f40509dcf00a4c5751af1ef5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2053182 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: move vboot 2.1 functions and structs into host codeJoel Kitching2020-02-1118-16/+792
| | | | | | | | | | | | | | | | | | These structs and functions need to stick around for futility to use, but they are no longer supported in firmware code. Rename host/lib21/include/* files to end in 21 instead of 2. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I01e181e2f03553d60724fbdc826f5ada63777303 Cq-Depend: chromium:1969172 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1963621 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: purge unused vboot 2.1 codeJoel Kitching2020-02-114-223/+0
| | | | | | | | | | | | | | Only keep vboot 2.1 code that futility uses. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: Iee45d7a0f7c6a6d4b27997b2eff3117a12a48dcf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1961715 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/crossystem: Deprecate recoverysw_is_virtualYu-Ping Wu2020-02-061-9/+0
| | | | | | | | | | | | | | | | | | | | | | As part of chromium:943150, virtual recovery switch functionality is being deprecated. Physical presence should be chosen by specifying one of the following USE flags: - physical_presence_keyboard - physical_presence_recovery - physical_presence_power Fields VDAT_INT_DEPRECATED_DEVSW_VIRTUAL and VDAT_INT_RECSW_VIRTUAL are also removed from VdatIntField. BRANCH=none BUG=chromium:943150 TEST=make runtests Cq-Depend: chromium:2004370 Change-Id: I4342a2607538d1b4480d601073eb531e93e74b38 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2037268 Reviewed-by: Joel Kitching <kitching@chromium.org>
* Reland: Clean up implicit fall through.Manoj Gupta2020-02-011-1/+1
| | | | | | | | | | | | | | | | Directly use the __attribute__ ((fallthrough)) instead of a macro. This was suggested in CL:1772474. BUG=chromium:997709 TEST=CQ BRANCH=None Change-Id: Ifcdcd3822eddea41aeb88f4a55bd09aa483f6054 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2031766 Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
* crossystem: Add support for JSL gpiochipUsha P2020-01-221-0/+1
| | | | | | | | | | | | | | On JSL platform, the pinctrl (gpiochip) driver label is "INT34C8:00", hence declare it properly. Change-Id: I401f095f262739dcb872b7fe9d64f52ee9ff17ce Signed-off-by: Usha P <usha.p@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1966885 Reviewed-by: Subrata Banik <subrata.banik@intel.com> Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Kirtika Ruchandani <kirtika@chromium.org> Commit-Queue: Kirtika Ruchandani <kirtika@chromium.org> Tested-by: Kirtika Ruchandani <kirtika@chromium.org>
* vboot: fix up some host key functions for host_key2.cfactory-excelsior-12812.BJoel Kitching2019-12-253-45/+23
| | | | | | | | | | | | | | | | | | | | | | | | | Deprecate: PublicKeyInit --> vb2_init_packed_key PublicKeyCopy --> vb2_copy_packed_key Rename: packed_key_looks_ok --> vb2_packed_key_looks_ok Move vb2_packed_key_looks_ok from host_key.c to host_key2.c. Move tests/vboot_common_tests.c to tests/vb2_host_key_tests.c. Remove firmware/lib/vboot_common.c. Remove host/lib/host_key.c. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I627b2af0416ac69460f9860614a69cad8bdb76a7 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844597 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* lib/subprocess: add callback feature to the subprocess libraryJack Rosenthal2019-12-112-33/+141
| | | | | | | | | | | | | | | | | | For the libflashrom-compatible interface I'm working on, I needed the ability to process data from the flashrom subprocess in a callback function. This adds a new type of subprocess_target, TARGET_CALLBACK, which can read and write to/from a callback function. BUG=chromium:478356 BRANCH=none TEST=provided unit tests Change-Id: I20b71000fc2b6b297a8617d2b03d0e91813007d1 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1959944 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: merge vb2_struct.h into 2struct.hJoel Kitching2019-12-103-6/+4
| | | | | | | | | | | | | | | Also remove unused preamble structs in vboot_struct.h. BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I8b41f24b55eba91b1f952415eda1b532732848eb Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844601 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* lib/subprocess: style updatesstabilize-12748.BJack Rosenthal2019-12-102-19/+24
| | | | | | | | | | | | | | | Just resolving some style comments left on CL:1955805. The CL merged by CQ before I noticed the comments. BUG=none BRANCH=none TEST=compiles Change-Id: I286343e3ee2ecb4cb6092ca99fa46c4a80442e03 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1957760 Tested-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: change mosys calls to use the subprocess libraryJack Rosenthal2019-12-101-70/+17
| | | | | | | | | | | | | | | The new subprocess_run library function provides a unit-tested way to call subprocesses and collect output. BUG=chromium:1030473 BRANCH=none TEST=On drallion and druwl, crossystem works for both reading and writing Change-Id: I072d91cf68ee91c663652d2c0433ef8bbedad7d7 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1955806 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* host/lib: add a subprocess libraryJack Rosenthal2019-12-072-0/+347
| | | | | | | | | | | | | | | | | | | This is a powerful library for interacting with processes. We'll be able to clean up much of the code which manually sets up the pipes and calls exec* with this well-tested and expressive abstraction. This code will initially be used in crossystem for calling out to flashrom instead of relying on mosys. BUG=chromium:1030473 BRANCH=none TEST=provided unit tests Change-Id: I56f28419406d0b1299bb91058dd4500079b2435e Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1955805 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: remove unnecessary vboot_common.h includesJoel Kitching2019-12-0610-10/+0
| | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I7daf97a88c71ff188c5812a30ca71d6c84823ae9 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1844595 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: drop support for AndroidJack Rosenthal2019-12-041-28/+4
| | | | | | | | | | | | | | This was for the Ryu project, which was cancelled (at least for CrOS). It's safe to assume crossystem will never be used on Android. BUG=chromium:990438 BRANCH=none TEST=crossystem still functions on samus Change-Id: Ide5b4ad105e9f36972067c125176ae5a08444ceb Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1949427 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* crossystem: Add a fake workbuffer for the fake contextJulius Werner2019-11-141-14/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | crossystem functions just make up a fake vb2_context for calling into things like vb2_nv_init(), but that function actually accesses vb2_shared_data as well. This used to work because vb2_get_sd() would return NULL in that case and vb2_nv_init() actually checks for that, but with the persistent context model this is no longer possible and making up directly allocated contexts is always illegal. This patch adds a small fake workbuffer to the fake context so we can have real backing storage for shared data. (This might not be the final way we want to fix it but should work as a quick band-aid over the crashes.) Also remove the now pointless (sd == NULL) checks from vb2_nv_init(). BRANCH=None BUG=chromium:1024732 TEST=make runtests Change-Id: I91247013f092bbfc41cf1974b82cf70a29fa4734 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1917486 Tested-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Brian Norris <briannorris@chromium.org>
* vboot: align workbuf to VB2_WORKBUF_ALIGNJoel Kitching2019-11-131-1/+2
| | | | | | | | | | | | | | | Also standardize on position and spacing of __attribute__. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ic61d6193c2413824837a51af98eb2dcd9ea4ab85 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1902843 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* Revert "Clean up implicit fall through."Mathew King2019-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-051-1/+1
| | | | | | | | | | | | | | | | 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: 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>