summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Reland "crossystem: Add board_id property"release-R108-15183.BJack Rosenthal2023-03-054-23/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 87663c3bef0f6b198945cf3eb83632f461a5d6f8. The parent CL to this commit should be sufficient to resolve the failure that prevented "crossystem board_id" on ARM from working. Original change's description: > crossystem: Add board_id property > > futility is one of a few places in ChromeOS that uses "mosys platform > version". The goal is to remove this command from mosys. > > This commit adds a new property to crossystem, "board_id", which > reads the board revision from SMBIOS/FDT, and replaces the call in > futility with the appropriate VbGetSystemPropertyInt. > > BUG=b:187790074 > BRANCH=none > TEST="crossystem board_id" on hana and brya > > Change-Id: Id69c8e309c0e509a165aa6da2778573ac7de3455 > Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4029537 > Reviewed-by: Julius Werner <jwerner@chromium.org> BUG=b:187790074,b:270917040 BRANCH=none TEST="crossystem board_id" on hana and brya Change-Id: I37b4c622e3c1d294b5be8e0d98ef14175902acc3 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4045047 Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit 5bbd123cac5650dba0db6cc3c40c7cf33bfd7efc) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4300250 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* crossystem: arm: Make FDT_BASE_PATH /proc/device-treeJack Rosenthal2023-03-051-15/+16
| | | | | | | | | | | | | | | | | | | Hard-coding to /proc/device-tree/firmware/chromeos won't let us read device-tree properties outside of /firmware/chromeos. The follow-on CL reads from /firmware/coreboot. BUG=b:187790074,b:270917040 BRANCH=none TEST=CQ passes Change-Id: I752aa5a1e20db1dad7f2508852c7a1c982a4bcb4 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4045046 Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit edcc75666d8fab2e1be895ac87af87ee74ec0079) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4300249 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* sign_official_build: add AP RO signingstabilize-quickfix-15183.78.Bstabilize-15183.82.Bstabilize-15183.69.BVadim Bendebury2022-12-021-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When signing AP RO images, in cases when signer_config.csv manifest includes the brand code column add a futility invocation to sign the RO_GSCVD section of the image. If the <path to unpacked>/keyset directory is found, save the gscvd.<model> blob in that directory. BRANCH=none BUG=b:247652363 TEST=built ChromeOS test image for Nissa, then invoked $ scripts/image_signing/sign_official_build.sh \ base \ ~/trunk/src/build/images/nissa/latest/chromiumos_test_image.bin \ tests/devkeys \ /tmp/signed.bin and observed 'futility gscvd' invocation in the log. Cq-Depend: 3954963 Cq-Depend: 4063101 Change-Id: I55cec75794560662ed2cfb2dac7f44d972a8571f Signed-off-by: Vadim Bendebury <vbendeb@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3935034 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Auto-Submit: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> (cherry picked from commit befd35f018be4ff6465b15f7bc1bc64c8e65426d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4063103 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Knox Chiou <knoxchiou@chromium.org> Commit-Queue: Knox Chiou <knoxchiou@chromium.org>
* gscvd: presume GBB flags are zero when hashing the RO space contentsVadim Bendebury2022-12-026-7/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is still being debated who is supposed to make sure that the GBB flags are set to zero before the root of trust validation is granted to the AP firmware image, but as of today the approach is that the GBB flags must be zero at AP RO validation time. The problem is that when AP RO space signature is created GBB flags can be set to a non-zero value. With this patch when AP RO areas contents is hashed, in case GBB flags are included in one of the ranges, the flags are not read from the flash, and substituted with zero. During validation the real flags value is used. A unit test is added to verify various futility gscvd GBB related situations, the blobs for the unit test were extracted from a Nivviks firmware image. BRANCH=none BUG=b:245799496, b:253540670 TEST='./tests/futility/test_gscvd.sh' and 'make runfutiltests' succeed Change-Id: I2f047b990cf71ea24d191fc690da08e25ebb10cc Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3958581 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> (cherry picked from commit e18a6cda6b74df772f98daeefe1273807c3710d8) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4065621 Tested-by: Knox Chiou <knoxchiou@chromium.org> Commit-Queue: Knox Chiou <knoxchiou@chromium.org>
* gscvd: refactor discovering GBB in the imageVadim Bendebury2022-12-021-29/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | Separate GBB discovery into a function and cache GBB information in the ap_firmware_file structure for future use. BRANCH=none BUG=b:245799496 TEST=ran the following command ./build/futility/futility gscvd -G -R 00000000:00001000 \ --keyblock tests/devkeys/arv_platform.keyblock \ --platform_priv tests/devkeys/arv_platform.vbprivk \ --board_id XYZ1 \ --root_pub_key tests/devkeys/arv_root.vbpubk "${BIOS_FILE}" using 'futility' compiled before and after this patch was applied, verified that the resulting file is the same. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I3ab59536cfa75a303be3e9271d9b44b1de851f5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3958580 Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit 0b0aee9c0d1ef86833a07a0adabdfdc07d1d500b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4063102 Commit-Queue: Knox Chiou <knoxchiou@chromium.org> Tested-by: Knox Chiou <knoxchiou@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: add option to save ro_gscvd section in a blobVadim Bendebury2022-12-021-9/+35
| | | | | | | | | | | | | | | | | | | | | | | | | To support the "futility update" ability to put together firmware images for different targets, the pre-signed RO_GSCVD sections need to be included in the firmware tarball. This patch adds a command line option which will make 'futilty gscvd' save the signed section in a local file for inclusion in the tarball. BRANCH=none BUG=b:245799496 TEST=verified that passing the --gscvd_out command line option results in creating a file with the RO_GSCVD section contents, identical to the section in the signed binary file. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: Id4a75c74ad1e27c11a6005472708730b8051f036 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3954963 Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit ff1749cb9a3da80bb9f2783d7ac4efaf0b99da98) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4063101 Tested-by: Knox Chiou <knoxchiou@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Knox Chiou <knoxchiou@chromium.org>
* futility: updater: Support patching GSCVDHung-Te Lin2022-12-022-10/+25
| | | | | | | | | | | | | | | | | | | To support patching firmware image files with different GSCVD (GSC verified data for AP RO verification) per brand code, we want to read and load the data from keyset/gscvd.$model in the firmware archives. BRANCH=None BUG=b:248317123 TEST=make; run test Change-Id: I99ed4bae21b8909da2cbb1ebca0b9bbac268be5d Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3937842 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> (cherry picked from commit 6480322779fcb9e5126c0c99c24e3e4df731dcd3) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4063100 Tested-by: Knox Chiou <knoxchiou@chromium.org> Auto-Submit: Knox Chiou <knoxchiou@chromium.org>
* crossystem: arm: Retry if we fail to read a GPIODouglas Anderson2022-10-211-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that if two processes try to read the same GPIO at the same time that one of them will fail because the GPIO is "busy". This is really by design of the kernel's GPIO API. In order to read a value, each userspace process "requests" control of the GPIO and then queries it. There doesn't appear to be any way to "wait" for a GPIO that's been requested by someone else--we just need to wait a bit and try again later. ...so that's what we'll do. Without this patch, if you run the following script on a write-protected sc7180-trogdor class device in two shells at the same time: old_val="" while true; do val=$(crossystem wpsw_cur) if [[ "${val}" != "${old_val}" ]]; then echo "$(date): ${old_val} => ${val}" old_val="${val}" fi done Then you'll see stuff like this: GPIO_GET_LINEHANDLE_IOCTL: Device or resource busy Tue Oct 18 11:34:01 PDT 2022: 1 => 0 Tue Oct 18 11:34:01 PDT 2022: 0 => 1 GPIO_GET_LINEHANDLE_IOCTL: Device or resource busy Tue Oct 18 11:34:01 PDT 2022: 1 => 0 Tue Oct 18 11:34:01 PDT 2022: 0 => 1 The 0 actually comes from the fact that crossystem falls back to `GetVdatInt(VDAT_INT_HW_WPSW_BOOT)` if it fails to read the GPIO and that value isn't initted to anything on trogdor (VDAT_INT_HW_WPSW_BOOT is deprecated and not populated on trogdor). It is postulated that the above problem is causing some parts of the system to get confused about the write protect state of devices. BRANCH=none BUG=b:249498455 TEST=Run script in CL commit message and see no errors Change-Id: I307cdb4e290c27694690a19af60f4697ee0233e4 Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3963985 Reviewed-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> (cherry picked from commit 4ca43a34f5a936683ebcdc7b0edd059f313f61be) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3971702
* firmware: host: futility: Add CBFS metadata hash supportstabilize-15183.14.BJakub Czapiga2022-10-1217-140/+657
| | | | | | | | | | | | | | | | | | | | | | This patch adds support for signing and verification of coreboot images supporting VBOOT_CBFS_INTEGRATION. Images with config option CONFIG_VBOOT_CBFS_INTEGRATION=y will be signed with CBFS metadata hash in signature. vb2api_get_metadata_hash() should be used to extract hash value from VBLOCK and then should be used to verify CBFS metadata. To support full verification, CBFS file data verification should also be enabled and correctly handled. BUG=b:197114807 TEST=build with CB:66909 and boot on volteer/voxel with CONFIG_VBOOT_CBFS_INTEGRATION=y BRANCH=none Signed-off-by: Jakub Czapiga <czapiga@google.com> Change-Id: I4075c84820949be24c423ed14e291c89a0032863 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3811754 Commit-Queue: Julius Werner <jwerner@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: Use ccd update mode for suzyq ti50Evan Benn2022-10-101-1/+2
| | | | | | | | | | | | | | | | | | | A ti50 TPM works with a servov4 as it reports 'ccd_gsc'. With suzyq 'ccd_ti50' is reported. Special case that string in the same way as cr50. BUG=b:251281342 BRANCH=None TEST=sudo futility update -a ./chromeos-firmwareupdate -m factory \ --servo --servo_port=9994 -d before: Selected Servo V2. after: Selected CCD. Change-Id: I1333fac24a023c1c88e708d69196f8da89777ef9 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3929938 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
* vboot: gbb_flags_common should treat ccd_ti50 like ccd_cr50stabilize-15174.BTirath Ramdas2022-10-081-1/+1
| | | | | | | | | | | | | | BUG=b:251281342 BRANCH=None TEST=set_gbb_flags.sh --servo targeting a Nereid succeeded. Change-Id: Iea83ebacf2bbcdf9da70b38a94017811c07c063e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3929937 Tested-by: Tirath Ramdas <tirath@google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Allen Webb <allenwebb@google.com> Reviewed-by: Sam McNally <sammc@chromium.org> Commit-Queue: Tirath Ramdas <tirath@google.com>
* futility: Address double freestabilize-15167.BJon Murphy2022-10-052-2/+0
| | | | | | | | | | | | | | | | | | The body_sig pointer is being freed twice. This can lead to indeterminate behavior and could corrupt memory. Remove superfluous free to avoid memory corruption. BUG=b:250952592 TEST=NA BRANCH=None Change-Id: Ie4c11e940653550e24829f253d05be08d74620f6 Signed-off-by: Jon Murphy <jpmurphy@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3935032 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* treewide: Fix license headers to conform with linterJakub Czapiga2022-10-04283-286/+283
| | | | | | | | | | | | | BRANCH=none BUG=none TEST=cros lint Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I7710c43c8c70cf257a898f22c42ecbf350e125a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3925702 Commit-Queue: Jakub Czapiga <czapiga@google.com> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Jakub Czapiga <czapiga@google.com>
* DIR_METADATA: Add V2 Test Plans.firmware-duplo-15151.BNavil Perez2022-09-301-0/+34
| | | | | | | | | | | | | | | | | | Add the default set of test rules. V2 test plans will be verified in staging before being enabled in prod. See go/cros-cq-test-config for more details. BRANCH=None BUG=b:249150178 TEST=dirmd validate Change-Id: I7fb7967025019c8cf286294e48573445e3e90d5b Signed-off-by: Navil Perez <navil@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3927889 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility gscvd: add option to print out root key hashVadim Bendebury2022-09-291-19/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | The root public key hash needs to be incorporated into the GSC firmware. Before this patch the only way to get the hash was to preform an AP RO firmware signing operation, which, among other things requires access to the platform private key. This patch adds another invocation option where only the -r parameter is passed in, in which case the hash of the public key is printed. BRANCH=none BUG=b:247653513 TEST=verified printing root pubk hash: $ futility gscvd \ -r ./nivviksSigning-MP/root_key_arv_root.vbpubk Root key body sha256 hash: b3dba1f89e943d53206e2950e06c3764fe230ef883bb8fd2932a9fb21c281ba1 Change-Id: I41d8396309d43d9d48555453d3339b0b540000c0 Signed-off-by: Vadim Bendebury <vbendeb@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3906635 Auto-Submit: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* gscvd: add support for reading ranges from the imageVadim Bendebury2022-09-271-17/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It has been decided to communicate the list of ranges to cover by the signature through a preset ranges array in the RO_GSCVD FMAP section of the AP firmware image. This patch adds the ability to retrieve ranges from the image in case the -R command line parameter is not given on the command line when invoking 'futility gsvd'. BRANCH=none BUG=b:247653513 TEST=verified that both forms of invocation, with and without -R work as expected, as well as GSCVD verification invocations with and without the root public key hash without passing in the ranges: $ utility gscvd \ -k nivviksSigning-MP/arv_platform.keyblock \ -p nivviksSigning-MP/arv_platform.vbprivk \ -b 52435a5a \ -r nivviksSigning-MP/root_key_arv_root.vbpubk \ --outfile ~/tmp/bios/image-nivviks.signed.bin \ ~/tmp/bios/image-nivviks.serial.bin Will sign the following 3 ranges: 01fe4e00:0001b200 01c07000:00000030 01c07180:00002000 Root key body sha256 hash: b3dba1f89e943d53206e2950e06c3764fe230ef883bb8fd2932a9fb21c281ba1 with passing in the ranges: $ futility gscvd \ -R 1c77000:200,1c07000:400,1c16800:100,1c06000:1000,1c08000:100 \ -k nivviksSigning-MP/arv_platform.keyblock \ -p nivviksSigning-MP/arv_platform.vbprivk \ -b 52435a5a \ -r nivviksSigning-MP/root_key_arv_root.vbpubk \ --outfile ~/tmp/bios/image-nivviks.signed.bin \ ~/tmp/bios/image-nivviks.serial.bin Root key body sha256 hash: b3dba1f89e943d53206e2950e06c3764fe230ef883bb8fd2932a9fb21c281ba1 validate signed image without pub key hash: futility gscvd ~/tmp/bios/image-nivviks.signed.bin validate signed image with pub key hash: $ futility gscvd ~/tmp/bios/image-nivviks.signed.bin \ b3dba1f89e943d53206e2950e06c3764fe230ef883bb8fd2932a9fb21c281ba1 try validating signed image with a corrupted pub key hash: $ futility gscvd ~/tmp/bios/image-nivviks.signed.bin \ b3dba1f89e943d53206e2950e06c3764fe230ef883bb8fd2932a9fb21c281ba0 ERROR: validate_gscvd_or_read_ranges: Sha256 mismatch validate proper processing of uninitialized GVD: $ futility gscvd -k nivviksSigning-MP/arv_platform.keyblock \ -p nivviksSigning-MP/arv_platform.vbprivk \ -b 52435a5a \ -r nivviksSigning-MP/root_key_arv_root.vbpubk \ --outfile ~/tmp/bios/image-nivviks.signed.bin \ ~/tmp/bios/image-guybrush.serial.bin ERROR: validate_gvd: Incorrect gscvd magic ffffffff ERROR: do_gscvd: Missing --ranges argument and no ranges in... Change-Id: I586f97083f6d77fdddddd7327c61891197c3cc58 Signed-off-by: Vadim Bendebury <vbendeb@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3905178 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Alyssa Haroldsen <kupiakos@google.com>
* gbb_flags_common.sh: Restore tmpfile cleanup trapEvan Benn2022-09-231-1/+4
| | | | | | | | | | | | | | A trap to delete tempfiles was mistakenly masked. BUG=b:247920664 BRANCH=None TEST=get_gbb_flags.sh; ls /tmp/tmp.* | wc -l == 0 Change-Id: I3b783395309ea2acb1bc75ffa19df62f81b90450 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3907130 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* scripts/OWNERS: Fix engeg email chromium -> googleEvan Benn2022-09-231-1/+1
| | | | | | | | | | | | | BUG=None BRANCH=None TEST=None Signed-off-by: Evan Benn <evanbenn@chromium.org> Change-Id: Ia2d4426ad0807a51d4b0568bd6a750f8fb6021f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3907132 Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: George Engelbrecht <engeg@google.com> Commit-Queue: Mike Frysinger <vapier@chromium.org>
* tests: Remove --allow-multiple-definition linker optionYu-Ping Wu2022-09-2111-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | The --allow-multiple-definition linker option was added in CL:6770 to allow mocking functions. Now that we're exclusively using the weak attribute (or equivalently test_mockable in vboot_reference) in other firmware repositories (coreboot, depthcharge) for unit testing, the --allow-multiple-definition option should no longer be needed. In addition, one problem with --allow-multiple-definition is that, when a function being mocked is automatically inlined by compiler optimization, the mock function may not be called at all, leading to unexpected behavior. Marking that function as test_mockable can prevent this situation. Therefore, add test_mockable to all the functions being mocked, and remove the linker option from Makefile. BUG=none TEST=make -j32 test_setup && make runtests BRANCH=none Change-Id: Ifcd8138641d17bff689dd5093cdd69e4da9f0b0c Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3744746 Reviewed-by: Jakub Czapiga <czapiga@google.com> Commit-Queue: Jakub Czapiga <czapiga@google.com>
* futility: Skip picking apart an x86 kernel if has the EFI stubNicholas Bishop2022-09-201-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Crdyboot uses the kernel's own EFI boot stub to actually launch the kernel, so the "pick apart" operations done by futility on x86 kernels aren't desired. Skip those operations if the kernel contains the builtin EFI stub. This will only affect the reven board, as only the reven kernel config has CONFIG_EFI_STUB enabled. To detect whether the kernel was built with the EFI stub, check the first two bytes of kernel data for the COFF header magic bytes "MZ". Tested by running `vbutil_kernel --pack` on two amd64 kernels, one with CONFIG_EFI_STUB enabled and one with it disabled. Full command: futility --debug vbutil_kernel --pack out.img --keyblock /usr/share/vboot/devkeys/recovery_kernel.keyblock --signprivate /usr/share/vboot/devkeys/recovery_kernel_data_key.vbprivk --version 1 --config config.txt --bootloader /lib64/bootstub/bootstub.efi --vmlinuz vmlinuz.bin --arch amd64 In the kernel with the EFI stub the debug output includes "EFI boot stub detected", the other one does not. BUG=b:238316304 TEST=Test two kernels as described above TEST=Test booting through crdyboot BRANCH=none Signed-off-by: Nicholas Bishop <nicholasbishop@google.com> Change-Id: I14640eadce2a1e41a262921cb6ab96962b6b3a22 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3900403 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* Avoid build failures on recent distrosstabilize-15129.Bstabilize-15122.Bstabilize-15120.BSimon Glass2022-09-151-0/+19
| | | | | | | | | | | | | | | | Emit a warning and continue when OpenSSL is newer than expected. The chroot still uses an older version. BUG=b:245993083, b:246328810 BRANCH=none TEST=make -C ~/cosarm/src/platform/vboot_reference/ USE_FLASHROM=0 See that the errors become warnings Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I85afba4007da3bc7c37abc04d744185c3362ad99 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3887562 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* subprocess: Log subprocess arguments when runningstabilize-15117.86.Bstabilize-15117.48.Bstabilize-15117.111.Brelease-R107-15117.BJakub Czapiga2022-09-103-3/+27
| | | | | | | | | | | | | | | | | | | | | | Utility programs in vboot sometimes use subprocess_run to execute another program like flashrom or cbfstool. This change makes it easier to debug these utilities by logging executed subprocess and its arguments. This change also fixes futility vb2ex_printf() implementation. Previously use of VB2_DEBUG_RAW() calling vb2ex_printf(NULL, ...) was unnecessarily trying to print NULL as function name, which was not intended behavior. TEST=sign image and look for "Run: cbfstool ..." BUG=none BRANCH=none Signed-off-by: Jakub Czapiga <czapiga@google.com> Change-Id: I613d4af4af4370425cbbedc2d7de29a488533c6a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3878593 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* 2api: Add a new entry point for only loading and verifying the kernelNicholas Bishop2022-09-076-28/+483
| | | | | | | | | | | | | | | | | | | Add vb2api_inject_kernel_subkey for bootloaders that only want to use vboot for loading and verifying the kernel. The intended usage is: vb2api_init(); vb2api_inject_kernel_subkey(); vb2api_load_kernel(); BUG=b:237093169 BRANCH=none TEST=make && make runtests Change-Id: Iea6e31826f89ec754496427427d124a35285c463 Signed-off-by: Nicholas Bishop <nicholasbishop@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3732807 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests: Ensure auxfw sync runs after EC syncstabilize-15086.Bfirmware-ti50-prepvt-15086.Bfirmware-ti50-mp-15224.Bfirmware-ti50-mp-15090.BYu-Ping Wu2022-09-011-0/+2
| | | | | | | | | | | | | | | | Running auxfw sync after EC sync is intentional, and the order should not be swapped. Therefore add a check in the mock vb2api_auxfw_sync(). BUG=none TEST=make run2tests BRANCH=none Change-Id: I60104378d4abf509cd379dc30818d79dd0606ee3 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3863492 Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org> Commit-Queue: Hsuan Ting Chen <roccochen@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: 2sha: Integrate HW crypto directly into vb2_digest APIJulius Werner2022-09-0137-486/+474
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch moves the connection to the vb2ex_hwcrypto API further down the stack, into the low-level vb2_digest and vb2_hash APIs. These functions will now take an extra allow_hwcrypto argument that the caller can use to deny or allow hwcrypto by policy. If allowed, the function will try HW crypto first and fall back to the software implementation if the selected algorithm is not supported. vb2_hwcrypto_allowed() is made available to external callers as a vb2api function to make that decision in most cases (for others, like userspace tools and testing, HW crypto is generally not used anyway and they can just pass `false`). Since vb2ex_hwcrypto_digest_init() takes a data_size argument for the total amount of bytes expected, vb2_digest_init() will now also need to take this extra argument. But since the total data size cannot always be known in advance, callers are allowed to pass 0 to indicate that the size is unknown. The software implementations work either way, and HW crypto implementations will now need to check if data_size is 0 and return HWCRYPTO_UNSUPPORTED if they cannot handle this case. While we're touching everything anyway, let's take this opportunity to retire the vb2_digest_buffer() API in favor of the newer and usually more convenient vb2_hash_calculate(), so we can limit the amount of separate APIs we have to support going forward. BRANCH=none BUG=b:240624460 TEST=runtests Signed-off-by: Julius Werner <jwerner@chromium.org> Cq-Depend: chromium:3854282 Change-Id: I34c3f54e31742619d422d1cd871bdb77ad0439b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3825558 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* security_test_chromeos_image: Add support for ensure_amd_psp_flagsRobert Zieba2022-09-011-1/+13
| | | | | | | | | | | | | | This commits adds support for the `ensure_amd_psp_flags` script which only needs to be few on certain AMD boards. BRANCH=none BUG=b:202397678 TEST=Verified that ensure_amd_psp_flags executes correctly Change-Id: I6ae61083113497d1c63b5ed5a0bd608c525a0c6e Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3821000 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* scripts/image_signing/ensure_amd_psp_flags: Ignore non-AMD imagesRobert Zieba2022-09-011-10/+27
| | | | | | | | | | | | | | | | | This commit updates the `ensure_amd_psp_flags` script so that it will ignore any artifacts that do not contain valid AMD AP images as long as there are no soft-fuse bitsets present for the given board. This allows all logic to be contained within this script. BRANCH=none BUG=b:202397678 TEST=Verified that script still works on AMD artifacts, tested that Intel and ARM artifacts are ignored Change-Id: I17a9414a36fbeb4a0ae9792c2e036deccd089870 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3860383 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* firmware: 2api.h: Factor out 2context.hstabilize-15083.Bstabilize-15072.BJulius Werner2022-08-182-276/+290
| | | | | | | | | | | | | | | | | | Declaring struct vb2_context in 2api.h creates problems with circular dependencies if other API functions need to rely on data types in headers that in return need the vb2_context definition. This patch solves that problem by factoring vb2_context out into its own header. BRANCH=none BUG=b:240624460 TEST=none Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I3d6a94e6e3d69cfa29d1f1415552446051a50c57 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3825557 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Kangheui Won <khwon@chromium.org> Tested-by: Jakub Czapiga <czapiga@google.com>
* add -r alias for --remove_rootfs_verificationSteven 'Steve' Kendall2022-08-181-1/+2
| | | | | | | | | | | BUG=none TEST=Ran script with new arg and ensured it disabled verity BRANCH=none Change-Id: I2cf4ca1a0a7b3663b05f7b2ef35fb6f9261b00a9 Signed-off-by: Steven 'Steve' Kendall <skend@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3825117 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* vboot_reference: make flashrom_get_wp() use libflashromNikolai Artemiev2022-08-187-62/+69
| | | | | | | | | | | | | | | | | | | | This makes flashrom_get_wp() use the new libflashrom WP interface that was recently added to flashrom and moves it to host/lib/flashrom_drv.c with the other libflashrom wrapper functions. BUG=b:223291615 BRANCH=none TEST=flashrom --wp-disable; futility update -i image.bin \ futility prints: `Write protection: 0 (disabled; HW=0, SW=0).` TEST=flashrom --wp-enable; futility update -i image.bin \ futility prints: `Write protection: 0 (disabled; HW=0, SW=1).` Change-Id: Ib13eeb2f1f718443271b074969ff69e66149f401 Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3540785 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* tests/futility/test_update.sh: Document test_update functionstabilize-15054.98.Bstabilize-15054.26.Bstabilize-15054.115.Brelease-R106-15054.BEvan Benn2022-08-171-0/+6
| | | | | | | | | | | BUG=b:231084609 BRANCH=None TEST=None Change-Id: Id76f2469faa13c136c6ec2761577acec4ad810e5 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3831833 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* 2misc: Abort before using GBB if gbb_offset is not initializedNicholas Bishop2022-08-173-10/+46
| | | | | | | | | | | | | | | | | | | | | | | | In vb2_get_gbb, abort if gbb_offset is zero. This ensures that functions like vb2api_gbb_get_flags won't try to read garbage GBB data if the context hasn't been properly initialized. Some additional changes made to fix tests: 1. In vb2_set_boot_mode, don't access GBB unless needed. 2. In vb2api_get_dev_default_boot_target, use vb2api_gbb_get_flags instead of vb2_get_gbb to make it easier to mock. This is needed for depthcharge tests. 3. Make vb2api_get_debug_info tolerant of GBB not being set. This is needed for depthcharge tests. BUG=b:237093169 BRANCH=none TEST=make && make runtests Cq-Depend: chromium:3820402 Change-Id: I921d6cc4a5d91c8114c5e46748b4576a1e7716d0 Signed-off-by: Nicholas Bishop <nicholasbishop@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3817941 Reviewed-by: Julius Werner <jwerner@chromium.org>
* make_dev_ssd.sh: skip firmware checks on VMShao-Chuan Lee2022-08-161-3/+15
| | | | | | | | | | | | | | The script doesn't work on betty without --force. And in turn dev_features_rootfs_verification doesn't work as well. BUG=None TEST=copy the script to betty and run BRANCH=none Change-Id: I70f48b97b470bb04fb9f5fff751df83c44d7defe Signed-off-by: Shao-Chuan Lee <shaochuan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3818089 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* scripts/image_signing: Add general security test scriptRobert Zieba2022-08-161-0/+99
| | | | | | | | | | | | | | | | | This commit adds a general security test script. This allows some logic to be moved out of the signer as well as providing a single entry point for the security tests run by the signer. BRANCH=none BUG=b:202397678 TEST=Verified that correct security tests ran with/without `--keyset-is-mp` Change-Id: Ib4c779a90d2fe9160c278f20d7ec61242f1d68cc Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3820999 Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org>
* scripts/image_signing/ensure_amd_psp_flags: Change argument orderRobert Zieba2022-08-161-3/+3
| | | | | | | | | | | | | | | This commit changes the order of the arguments for this script from `<board> <image>` to `<image> <board>`. This brings the script in-line with the existing ensure scripts. BRANCH=none BUG=b:202397678 TEST=Verified that script works with guybrush image Change-Id: I7bf31eb0b6ab667b1c3c0e71c2388531bb3f1bc0 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3820998 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* futility: updater: Stop looking for zephyr.binstabilize-15033.Bstabilize-15032.BYu-Ping Wu2022-08-071-6/+2
| | | | | | | | | | | | | | | | In CL:3788136 the zephyr EC image is renamed from zephyr.bin to ec.bin. Therefore we don't need to check the existence of zephyr.bin anymore. BUG=b:239887568 TEST=make runtests -j BRANCH=none Cq-Depend: chromium:3788136 Change-Id: Icd82baff93d2019cfd90b982e9c25b45cbf611c3 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3795458 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yidi Lin <yidilin@chromium.org>
* host/lib/cbfstool: Fail on subprocess errorJakub Czapiga2022-08-051-2/+5
| | | | | | | | | | | | | | | | | | | Make cbfstool_truncate() fail critically on subprocess execution error. cbfstool is mandatory, so it should always be available. If subprocess_run(), then either cbfstool is not available, or code is incorrect, so it should not return. BUG=none TEST=make runfutiltests BRANCH=none Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I17089d0cc2512a25f25cafe616caa79845a7e078 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3804563 Commit-Queue: Jakub Czapiga <czapiga@google.com> Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Jakub Czapiga <czapiga@google.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
* futility: gscvd: Allow verification ranges in SI_ALL sectionJulius Werner2022-08-041-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | Recent discussions have brought us to the conclusion that we probably want to include the SI_DESC section on Intel mainboards in the GSCVD verified areas, since it contains soft straps that may affect pre-coreboot behavior. The problem is that while this section itself generally doesn't change, it is part of the larger Intel-specific SI_ALL section that also contains the ME code and data -- which _can_ be overwritten, so we usually place it in the RW part of the flash. The section is instead protected from unauthorized software access by platform-specific mechanisms. This patch modifies `futility gscvd` so that it will also accept verification ranges in an SI_ALL region (if it exists), not just in WP_RO. BRANCH=none BUG=none TEST=Modified coreboot to add SI_DESC range, verified ranges on Joxer. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Iacff931f7cb34a41d3d878eee395b97ba2452c2d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3794950 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* vboot_api.h: Remove VbExDiskGetInfo and VbExDiskFreeInfoHsin-Te Yuan2022-08-033-73/+0
| | | | | | | | | | | | | | | | | | | VbExDiskGetInfo and VbDiskFreeInfo are removed. Also, remove VB2_DISK_FLAG_REMOVABLE and VB2_DISK_FLAG_FIXED since depthcharge doesn't need them anymore. BUG=b:172339016 BRANCH=none TEST=make runtests TEST=make test-screenshot TEST=FW_NAME=tomato emerge-cherry depthcharge Cq-Depend: chromium:3760812 Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com> Change-Id: I30d142508992b8c634ab4f919cc1b1b1edb23f14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3762078 Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* 2load_kernel.c: Expose load kernel as vb2_apiHsin-Te Yuan2022-07-2929-1413/+511
| | | | | | | | | | | | | | | | | | | | | | | | | Move VbTryLoadKernel() and VbTryLoadMiniOsKernel() to depthcharge. In addition, expose LoadKernel() and LoadMiniOsKernel() as vb2api_load_kernel() and vb2api_load_minos_kernel(), respectively. Since we remove VbTryLoadKernel() in vb2api_normal_boot(), rename vb2api_normal_boot() to check_kernel_version() and call it in vb2api_kernel_finalize(). Also, rename VbSelectAndLoadKernelParams, VbDiskInfo, and VbExDiskHandle_t as vb2_kernel_params, vb2_disk_info, and vb2ex_disk_handle_t, respectively. BUG=b:172339016 BRANCH=none TEST=make runtests TEST=FW_NAME=tomato emerge-cherry depthcharge Cq-Depend: chromium:3758201 Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com> Change-Id: Iaf182ca81797fee24c6104dac9d4770ff75c7fb2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3755923 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware/2lib: Introduce `vb2api_get_fw_boot_info` APISubrata Banik2022-07-293-67/+203
| | | | | | | | | | | | | | | | | | | | | This patch introduces a new API named `vb2api_get_fw_boot_info` to get the FW slot information like tries, current boot slot, previous boot slot, previous boot status and boot mode. Additionally, moved the required data structures from 2api.h to newly created 2info.h file to keep vboot information and inline functions for coreboot/eventlog usage. BUG=b:215615970 TEST=Able to compile the Google/Kano board using the emerge command. Signed-off-by: Subrata Banik <subratabanik@google.com> Change-Id: Ib3f197c851dc4b445dbf64868c3f9157a4f6c9fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3737570 Auto-Submit: Subrata Banik <subratabanik@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Subrata Banik <subratabanik@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* signer: continue to use --sb_extract for shellballsJosh Horwich2022-07-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | crrev.com/c/3665477 started using `--unpack` rather than `--sb_extract` for self-extracting firmware update bundles. Unfortunately, existing prebuilt artifacts used by signer tests are old and only support `--sb_extract`, and hence fail with recent vboot_reference that includes this change. This change simply reverts the option back to `--sb_extract` for unpacking self-extracting bundles. BRANCH=None BUG=b:179170462 BUG=b:202397678 TEST=unittests Change-Id: I528346a5d593caba7ca822820b9a38e994f0ea94 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3792485 Commit-Queue: Josh Horwich <jhorwich@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Prameet Shah <phshah@chromium.org> Tested-by: Josh Horwich <jhorwich@chromium.org> Auto-Submit: Josh Horwich <jhorwich@chromium.org>
* futility: Add --keyset option to sign command for BIOS and kernelstabilize-14998.Bfactory-foobar-15000.BJakub Czapiga2022-07-225-55/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds --keyset option for sign command for BIOS_IMAGE, RAW_FIRMWARE, RAW_KERNEL and KERN_PREAMBLE file types. The default value of this option is '/usr/share/vboot/devkeys'. It allows futility to load public and private keys, and keyblocks from under this path, when they were not provided manually using their respective options. Files loaded by default for BIOS_IMAGE and RAW_FIRMWARE: - ${keysetdir}/firmware_data_key.vbprivk - ${keysetdir}/firmware.keyblock - ${keysetdir}/kernel_subkey.vbpubk Files loaded by default for RAW_KERNEL: - ${keysetdir}/kernel_data_key.vbprivk - ${keysetdir}/kernel.keyblock File loaded by default for KERN_PREAMBLE: - ${keysetdir}/kernel_data_key.vbprivk BUG=none BRANCH=none TEST=make runfutiltests Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ic4026d501d88e0de7d2c6f52c7494c639d08bd15 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3740601 Auto-Submit: Jakub Czapiga <czapiga@google.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Tested-by: Jakub Czapiga <czapiga@google.com>
* futility: updater: allow --fast to skip scanning archive in do_manifestHung-Te Lin2022-07-212-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | The `--manifest` (do_manifest) command needs to scan most firmware images in the archive to build up the right information. That can be ~2s for a 200MB archive even though we just need the version string. 2s is usually fast enough for developers when they want to check the archive contents, but that is too slow if the boot time scripts (for example, CSME updater) need to collect the information. As a result, we want to allow overriding how the updater gets the manifest. For most systems that the firmware archive is created by the buildbot or the signerbot, the scripts can use "--manifest --fast" to retrieve the cached JSON manifest file. BUG=b:238908603 TEST=make; run test BRANCH=None Change-Id: I5d7dead4d0a43129fd31dd035aac63deaee42a08 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3775703 Reviewed-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* 2kernel.c: check display request in vb2api_kernel_phase2stabilize-14989.85.Bstabilize-14989.107.Brelease-R105-14989.BHsin-Te Yuan2022-07-153-46/+15
| | | | | | | | | | | | | | | | In preparation for moving VbTryLoadKernel to depthcharge, move the VB2_NV_DISPLAY_REQUEST check from vb2api_normal_boot to vb2api_kernel_phase2. BUG=b:172339016 BRANCH=none TEST=make runtests Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com> Change-Id: I3629d8dbbcaba23220152543ba77558c8bbcdc7b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3752431 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org>
* tests/common/boot_mode.c: Introduce SET_BOOT_MODEHsin-Te Yuan2022-07-157-94/+142
| | | | | | | | | | | | | | | | Introduce set_boot_mode to set up the corresponding ctx flags and call vb2_set_boot_mode to set ctx->boot_mode to be consistent with those flags. BUG=none BRANCH=none TEST=make runtests Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com> Change-Id: I7020639521af30bcdb6edcfac4c1a5b21ca8815e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3750959 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org>
* tests/common/tests.h: rename test_common.h to common/tests.hHsin-Te Yuan2022-07-1556-62/+62
| | | | | | | | | | | | | | Create tests/common/ to put some common files. BUG=none BRANCH=none TEST=make runtests Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com> Change-Id: I8918b7a1e62d47fca6074ef123e2de6f46f1aa00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3754814 Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* Makefile: Hide coverage helper targets if COV is not setHsuan Ting Chen2022-07-131-5/+5
| | | | | | | | | | | | | | | | | | We only check COV=1 in `make coverage` before. This will result in deleting all files in the current working directory if we accidentally tried `make coverage_init`. Hide coverage_init and coverage_html if COV is not set. BUG=none BRANCH=none TEST=make coverage_init and see the error message TEST=make clean && COV=1 make coverage -j Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org> Change-Id: I2d22b211b3d9e59d12faa0ab3d1c2ca8433598f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3747419 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* Makefile: coverage: Fix build failureHsuan Ting Chen2022-07-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Currently, make coverage is broken due to two issues: 1. The optimization option -O0 ignores the inline specifier in firmware/2lib/2sha256_x86.c:46 and 52. This will violate the compile-time constraint "i" and cause a build failure. Fix this issue by using -Og instead of -O0. 2. The coverage_html requires ${COV_INFO}.* files which are generated in coverage_init and runtests. We need to add prerequisites to prevent potential errors while running with "-j". BUG=none BRANCH=none TEST=make clean && COV=1 make coverage -j Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org> Change-Id: If1f9de1dbc56f36afead9045c1f95349a5fa156c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3755927 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* 2lib/2auxfw_sync: Request recovery for missing auxfwYu-Ping Wu2022-07-132-6/+15
| | | | | | | | | | | | | | | | | | | | | | When the hash file of auxfw is not found in the CBFS, VB2_ERROR_UNKNOWN will be returned from vb2ex_auxfw_check(), causing the device to enter reboot loop. Similar to how we handle missing ecrw.hash, vb2api_fail() should be called, so that the device will try to boot from the other slot, and if the hash is still missing, recovery will be triggered. Call vb2api_fail() from vb2api_auxfw_sync() using the 3-argument form of VB2_TRY(). Add a unit test to prevent regression. BUG=b:237745301 TEST=make run2tests TEST=emerge-corsola libpayload BRANCH=none Change-Id: I789c63b10201bd1852bc087199ec7b226ec85ba8 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3742863 Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>