summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* vboot2: Add more precise recovery reasons to firmware verificationstabilize-6783.BJulius Werner2015-02-124-28/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vboot1 kept track of an internal "LoadFirmware() check" value for both firmware slots and encoded the value for the slot that managed to go further in the verification flow into a special range of recovery reasons. vboot2 instead uses the generic "invalid RW" reason for all firmware verification failures and communicates further information through the subcode. While the subcode may be good enough for developers, it's difficult to communicate failure reasons to "normal" users (like non-firmware developers) on the TAB screen. Currently we just display a couple of numbers that people won't know how to interpret and "RW firmware failed signature check" for any verification error (including rollback, which might be the most commonly encountered in practice). Since our recovery reason space is big enough (and we don't reuse old numbers anyway), we might as well reuse the more precise numbers (and strings) from vboot1 to communicate the failure reason, even if we don't implement its "which slot came further" algorithm. This patch translates the most common/useful VBSD_LF_CHECK numbers into plain VB2_RECOVERY reasons and uses them where appropriate. CQ-DEPEND=CL:248400 BRANCH=veyron BUG=None TEST=make runtests VBOOT2=1 test_that my_jerry firmware_CorruptBothFwSigAB firmware_CorruptBothFwBodyAB firmware_RollbackFirmware (Confirmed that matched recovery reasons are the more precise ones in the 0x10-0x1F range.) Change-Id: I51ecf1b820d1faa40405cb84377380d6f3f6ca1d Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/248392 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Changes to compile signing tools on darwinDavid Riley2015-02-119-4/+39
| | | | | | | | | | | | | | | | | | | The following works from a Mac with these changes: make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility Only vbutil_keyblock and vbutil_kernel have been exercised. BUG=none TEST='make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility' BRANCH=none Signed-off-by: David Riley <davidriley@chromium.org> Change-Id: Ie69cfee0c650d4ff96be6322083a2fea1543ee39 Reviewed-on: https://chromium-review.googlesource.com/246773 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: David Riley <davidriley@chromium.org> Commit-Queue: David Riley <davidriley@chromium.org>
* Add LINUX_FS_GUID to list of GUIDs.Furquan Shaikh2015-02-111-0/+2
| | | | | | | | | | | | | | | | | This is for experimental purpose. BUG=chrome-os-partner:35861 BRANCH=None TEST=Compiles successfully. Change-Id: I53ce56f3728b72473a42581665969c90598ffd62 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/242924 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
* vboot1: Add vboot2 recovery reason strings and subcode to TAB displayJulius Werner2015-02-112-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | vboot2 added a few new recovery reasons (and abolished many old ones). In the current vboot2/vboot1 hybrid architecture used on Veyron, the vboot1 kernel verification part controls the status display when pressing the TAB key, which may try to show recovery reasons set by the vboot2 firmware verification part. These currently result in the not very helpful "We have no idea what this means", so lets hack a few more strings into vboot1 which will be otherwise harmless. Also add the recovery_subcode field to the display, which is used much more extensively by vboot2 and often very useful in firguring out what really went wrong. BRANCH=veyron BUG=None TEST=Manually set a few recovery reasons and subcodes through crossystem and made sure they get displayed correctly on my Jerry. Change-Id: I3f3e6c6ae6e7981337841c0c5e3cd767628472c3 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/248391 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* crossystem: read recovery switch status from chromeos_arm deviceKen Chang2015-02-101-0/+5
| | | | | | | | | | | | | | | | | | | | | The kernel chromeos_arm platform device provides the recovery status with the consideration of active polarity. Thus make crossystem to read from chromeos_arm device first. If this is not available, read directly from gpio pin status. BUG=chrome-os-partner:36425 BRANCH=none TEST=ran on kitty, 'crossystem recoverysw_cur' return 0 with recovery switch off 'crossystem recoverysw_cur' return 1 with recovery switch on Change-Id: Ie20630d7d07aeadf24044cd3ffc495df7cdd8a4a Signed-off-by: Ken Chang <kenc@nvidia.com> Reviewed-on: https://chromium-review.googlesource.com/246883 Tested-by: Titan Lee <titanlee@nvidia.com> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Titan Lee <titanlee@nvidia.com>
* Check the correct length of the GPT header signaturestabilize-6771.Bfactory-auron-6772.BBill Richardson2015-02-091-9/+12
| | | | | | | | | | | | | | | | | | | The length of the signature is 8 bytes. We've been checking 9 bytes instead, pretty much forever. All the tests have passed because although the signature we're looking for is an 8-byte string followed by a '\0', the next field in the header contains the revision number 0x00010000, so the 9th byte is always zero. We should follow the spec, though. BUG=none BRANCH=none TEST=make runtests Change-Id: I7cc6370250fa36a193f4a9fa5bc0099aea465618 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/247331 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: Fail vb2_secdata_(get|set) when secdata was not initializedJulius Werner2015-02-043-16/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a check to vboot2 secdata accessor functions that returns an error if vb2_secdata_init() has not yet been called or failed for some reason. This avoids a problem where vboot may misinterpret random garbage (e.g. from transient read failures) as valid secdata in recovery mode and write it back to the TPM (bricking the device in a way that requires manual repair). Also removes VB2_ERROR_SECDATA_VERSION check. This check was not terribly useful since there should be no way a vboot2 device could ever have secdata version 1 (and if it did, it should still fail CRC checks). This error can trigger for cases when secdata contains random garbage (e.g. all zeroes) and prevent the much more appropriate VB2_ERROR_SECDATA_CRC error from even being checked for, which just creates confusion and makes it harder to determine the real problem. BRANCH=veyron BUG=chrome-os-partner:34871 TEST=Emulated TPM read errors by just manually memset()ing secdata to 0 in coreboot, verified that vboot does not write back to the TPM and the device will start working fine again once the disruption is removed. Change-Id: I76bcbdbcd8106a0d34717cc91a8f2d7cda303c3f Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/244846
* keygeneration: fix typos in previous commitMike Frysinger2015-02-031-9/+9
| | | | | | | | | | | | | | Forgot to update the bitsizes in the variable constants. BUG=chromium:454651 TEST=`./create_new_keys.sh` still generates 8k keys TEST=`./create_new_keys.sh --4k` now generates 4k keys BRANCH=None Change-Id: Ie285649f4d58ad2e2cba71f4cab737cc2235e3ab Reviewed-on: https://chromium-review.googlesource.com/245890 Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
* create_new_keys: add options for generating 4k keysMike Frysinger2015-02-032-28/+59
| | | | | | | | | | | | | BUG=chromium:454651 TEST=`./create_new_keys.sh` still generates 8k keys TEST=`./create_new_keys.sh --4k` now generates 4k keys BRANCH=None Change-Id: I2203536880b9320959fd741c4bbcf814aded603c Reviewed-on: https://chromium-review.googlesource.com/245318 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
* vboot_reference: fix pointer issue in vmlinuz recontructionShelley Chen2015-02-031-11/+21
| | | | | | | | | | | | | | | | | vmlinuz_header_address was using an offset as opposed to a pointer. BUG=None BRANCH=None TEST=Take a kernel block and reconstruction the vmlinuz image: "vbutil_kernel --get-vmlinuz kern0 --vmlinuz-out vm.out" Then, try to kexec vm.out. Change-Id: Ifb41a00fd73f3222673467eef370c7abdbd0fd9c Reviewed-on: https://chromium-review.googlesource.com/245441 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
* create_new_keys: add a proper main funcstabilize-6752.BMike Frysinger2015-02-031-61/+95
| | | | | | | | | | | | | | | | | | | | | While we do this, clean up: - use braces everywhere - convert local vars from $VAR to $var - parse all command line args properly - run in `set -e` mode BUG=chromium:454651 TEST=`./create_new_keys.sh` still generates sane keys TEST=`./create_new_keys.sh --help` shows help output TEST=`./create_new_keys.sh --asdfasdf` shows an error TEST=`./create_new_keys.sh` outside chroot (w/out vboot binaries) aborts after first failure BRANCH=None Change-Id: I1ba0db0b24c0f2f10cf397b47115f0e98384d991 Reviewed-on: https://chromium-review.googlesource.com/245317 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
* futility: show .vbprivk filesBill Richardson2015-02-036-4/+53
| | | | | | | | | | | | | BUG=none BRANCH=none TEST=make runtests futility show tests/devkeys/*.vbprivk Change-Id: Ic062a193c7ee3d7f9837698e1c8fc6bb1e3d7757 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245503 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Restore lost dependenciesBill Richardson2015-02-031-0/+2
| | | | | | | | | | | | | | | | Oops. Somehow the Makefile stopped including the generated dependencies. As long as we're building from scratch this didn't matter, but rebuilding following local changes wouldn't always work. Let's fix it. BUG=none BRANCH=none TEST=make runtests Change-Id: I80bd30d1847734a288cddf61f28bb33ae9906525 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245501 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: handle truncated BIOS images without segfaultBill Richardson2015-02-036-8/+41
| | | | | | | | | | | | | | A truncated BIOS with an otherwise valid FMAP that now points way off the end of the file shouldn't cause coredumps. BUG=none BRANCH=ToT TEST=make runtests Change-Id: Idf96e1e6a381bf0fe0b1cb2d16e3dad39ce7a0dc Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245500 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: Add sd->fw_version_secdata field to communicate to crossystemJulius Werner2015-01-316-32/+21
| | | | | | | | | | | | | | | | | | | This patchs adds a new vb2_shared_data field to store the current rollback prevention version number stored in secdata (TPM). This information needs to be retrieved from there by coreboot (current hack) or vboot2 kernel verification (bright shiny future) so it can be passed along to the operating system and user space. BRANCH=veyron BUG=chrome-os-partner:35941 TEST=make runtests. Booted Jerry in recovery mode (with corresponding coreboot patch), ensured that crossystem tpm_fwver still shows the correct value. Change-Id: I2a0c3e51b158a35ac129d2abce19b40c6c6381a6 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/244601 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* add vb2api_get_pcr_digestDaisuke Nojiri2015-01-319-2/+198
| | | | | | | | | | | | this api allows firmware to get the digest indicating boot mode status. BUG=chromium:451609 TEST=VBOOT2=1 make run2tests BRANCH=tot Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Idca7bc5f6aed947689ad7cf219805aad35047c7d Reviewed-on: https://chromium-review.googlesource.com/244542
* futility: refactor file type detection into new filesBill Richardson2015-01-3111-184/+356
| | | | | | | | | | | | | | | | This moves the what-kind-of-file-is-this logic into a separate file, and makes it work by calling distinct recognizers until one hits. A new "-t" option to the show command prints what it's doing. BUG=chromium:228932 BRANCH=ToT TEST=make runtests Change-Id: Id8f60bdf3fe6a9adf41b4555b3448a261fa52fea Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245122 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* crossystem: Add fw_prev_tried and fw_prev_result to output valuesJulius Werner2015-01-311-0/+2
| | | | | | | | | | | | | | | | | | CL:221230 added the new NVRAM fields fw_prev_tried and fw_prev_result. It also provided support in the crossystem library to decode these values, but it forgot to add them to the table of allowed crossystem options so they actually cannot be queried by the command line tool. Fix that since this information is useful to debug failures after updating. BRANCH=R41 BUG=chrome-os-partner:36183 TEST=make runtests VBOOT2=1. cros deployed onto Jerry and confirmed fw_prev_tried and fw_prev_result are correct. Change-Id: I8bad7266379d959f5370b7ebeefbbba939c5de06 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245143 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* sign_official_build.sh should work without dev-firmware keysBill Richardson2015-01-311-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The signing scripts pass a bunch of args around, including paths to the keys used to sign dev-mode-specific firmware. That was only used on Alex and ZGB, so all the newer systems don't have those keys and the script falls over. This uses the normal firmware keys if the dev-firmware keys don't exist. This was an oversight with the original CL that touched resign_firmwarefd.sh BUG=chromium:453901 BRANCH=ToT TEST=manual Download a newer signed recovery image, say for nyan, and save it as scripts/image_signing/nyan-recovery-mp.bin Temporarily delete the developer firmware keys from the devkeys: rm -f tests/devkeys/dev_firmware* Now try resigning the recovery image: cd scripts/image_signing ./sign_official_build.sh recovery nyan-recovery-mp.bin \ ../../tests/devkeys/ signed.bin \ ../../tests/devkeys/key.versions It should work. Change-Id: I474811158cb33e16ad09c16b0db825c40217dd70 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245151 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Don't include lib20 files in xrefsBill Richardson2015-01-311-0/+2
| | | | | | | | | | | | | | | | The vboot 2.0 stuff is deprecated, so let's not index that when building cross-references (cscope.files and TAGS). BUG=none BRANCH=ToT TEST=manual make xrefs Change-Id: If3a9c42f869308acd929e32d5290e3354f5c3555 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/244751 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* lib21: Close the open file when finished using itBill Richardson2015-01-311-1/+3
| | | | | | | | | | | BUG=none BRANCH=ToT TEST=make runtests Change-Id: Ie4ac1ae71e70b62f9bc89fa1441ff5ca65199f79 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/244673 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Rename Makefile's fwlib2 target to fwlib20.Bill Richardson2015-01-292-37/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This accurately reflects what's really happening. Vboot 2.0 is backwards-compatible with the binary structs used in vboot 1.0, while vboot 2.1 will not be. When building firmware, vboot_reference should be invoked in one of three ways: TARGET OUTPUT VERSION fwlib vboot_fw.a 1.0 fwlib20 vboot_fw20.a 2.0 fwlib21 vboot_fw21.a 2.1 BUG=chromium:228932 BRANCH=ToT CQ-DEPEND=CL:243981 TEST=manual emerge-veyron_pinky coreboot emerge-samus coreboot emerge-daisy_spring chromeos-u-boot make runtests Change-Id: I98d8ea6b48e5922a470e744d56699cad43eabb3d Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243980 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* sign_official_build: Support old images without kernel in partition 4.Hung-Te Lin2015-01-291-6/+25
| | | | | | | | | | | | | | | | | Old images don't put kernel on partition 4 and rely on vblock for installation. The signer script has to support both old and new images, by testing if kernel partition has valid data. BRANCH=signer BUG=chromium:449450 TEST=(get old image without kernel blob on partition 4) sign_official_build.sh usb image.bin ../../tests/devkeys signed.bin \ ../../tests/devkeys/key.versions Change-Id: I92542ffb162660d86c30d9598fe1ca59ff69afe4 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243874 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* sign_official_buid: Fix "incorrect rootfs hash" when image has no firmware ↵stabilize-6736.BHung-Te Lin2015-01-281-3/+6
| | | | | | | | | | | | | | | | | | | updater . For each mount_image_partition, we have to unmount explicitly before doing other changes (especially when using dd) to image. Otherwise system may flush data when releaseing loop device and cause output image to be corrupted. BUG=chromium:449450 TEST=sign_official_build.sh factory factory_install_shim.bin \ ../../../tests/devkeys signed.bin ../../../tests/devkeys/key.versions sign_official_build.sh verify signed.bin BRANCH=signer Change-Id: I20756d9769c3737e25cfea348a9a4d64cc43b202 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243496 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* futility: extract vb2_verify_fw to an external testBill Richardson2015-01-283-14/+6
| | | | | | | | | | | | | | | | | The vb2_verify_fw command is used only in a host-side test. It doesn't need to be built into futility. This makes it a separate executable used just for that test. BUG=chromium:231547 BRANCH=none TEST=make VBOOT2=1 runtests Note that tests/vb2_firmware_tests.sh still passes, now using an external vb2_verify_fw executable instead of a futility command. Change-Id: Iee58df065e7a762369c5e691f6c2093de9122ed2 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243630
* vboot2: Add stub implementation for vb2ex_printf()Bill Richardson2015-01-281-0/+13
| | | | | | | | | | | | | BUG=none BRANCH=ToT TEST=manual make VBOOT2=1 DEBUG=1 runtests Change-Id: I5e99082d713e2f8ad2c56a10b86d0e0a44037549 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243360 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: vbutil_kernel should check the kernel a bit moreBill Richardson2015-01-281-0/+6
| | | | | | | | | | | | | | | | | | Trying to repack an invalid kernel blob should notice and complain that the blob is invalid instead of just segfaulting. BUG=chromium:452353 BRANCH=ToT TEST=manual See the bug report for an example test case. Many more tests are being added as futility development continues. Change-Id: I2bbfb8ab41a0f596b25a76f76f74d7b47b7e4a17 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243583 Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: fix alignment issues on 32-bit architecturesBill Richardson2015-01-2820-35/+68
| | | | | | | | | | | | | | | | | | We were assuming 8-byte alignment for buffers. That's not true on 32-bit architectures. We should make the alignment requirements explicit (and correct) for all architectures. BUG=chromium:452179 BRANCH=ToT CQ-DEPEND=CL:243380 TEST=manual USE=vboot2 FEATURES=test emerge-x86-alex vboot_reference Change-Id: I120f23e9c5312d7c21ff9ebb6eea2bac1e430e37 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243362 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cgpt_wrapper: Fix non-zero return code when okayNam T. Nguyen2015-01-271-3/+4
| | | | | | | | | | | | | | | | I forgot to reset "ret" to zero in the case the two hashes come out the same. This CL fixes that silly logic bug. BUG=None BRANCH=None TEST=`cgpt show /dev/mtd0` should exit with status 0 Change-Id: I1c64ea215c861c8afb44e235d090c72a5d006d55 Reviewed-on: https://chromium-review.googlesource.com/243325 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Trybot-Ready: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* cgptlib: Add functions to cgptlib APIFurquan Shaikh2015-01-244-17/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following changes are done to the cgptlib API in order to allow backend component of fastboot to perform erase and write operations on partitions and manipulate GPT entries: GptFindNthEntry - Returns the nth entry in GPT that matches provided GUID. GptGetEntrySizeLba - Returns size of a partition in lba. GptGetEntrySizeBytes - Returns size of a partition in bytes. GptUpdateKernelWithEntry - Given kernel entry is updated using the provided update_type. GptUpdateKernelEntry calls this function with entry for current_kernel. Add flags GPT_UPDATE_ENTRY_RESET and GPT_UPDATE_ENTRY_INVALID for calls to GptUpdateKernelEntry. These operations are used by write image and erase partition respectively. BUG=chrome-os-partner:35861 BRANCH=None TEST=Compiles successfully and all the newly added functions work as expected. Change-Id: I82c87e4c97de2d207e80209dbd4922b4bcd5880a Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/240268 Trybot-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
* vboot: Add flag to vbutil_kernel for reconstruction of vmlinuz imageShelley Chen2015-01-2311-18/+318
| | | | | | | | | | | | | | | | | | | | | | | | | | Adding functionality to allow for rebuilding of vmlinuz after it has been processed into vblock and header stripped. Basically appends the 16-bit header of a vmlinuz image onto the end of the vblock. BUG=chromium:438302 BRANCH=none TEST=Successfully ran "make runalltests". Also, ran: 1. Repack kernel block (so that 16-bit header is included): "vbutil_kernel --pack kern_0 ..." 2. Verify kernel: "vbutil_kernel --verify kern_0 ... ". This should be done before booting into kernel, but not necessary for it to work. 3. Rebuild vmlinuz image: "vbutil_kernel --get-vmlinuz kern_0 --vmlinuz-out vm.out" 4. Set up kexec with vmlinuz (this should complete with no errors): "kexec -l vm.out (other kernel cmd line args)" 5. Boot into kernel: "kexec -e" Change-Id: Iaa1582a1aedf70b43cdb3a56cde1fb248f1793d4 Signed-off-by: Shelley Chen <shchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/232750 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: remove obsolete dev_sign_file commandBill Richardson2015-01-224-405/+1
| | | | | | | | | | | | | This wasn't being used anywhere, so out it goes. BUG=chromium:231457 BRANCH=none TEST=make runtests Change-Id: If3865f54ac29655ee7d520f00e618f490f25c619 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/235481 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: extract verify_kernel command to an external testBill Richardson2015-01-223-9/+5
| | | | | | | | | | | | | | | | | | The verify_kernel command is used only in a host-side test. It doesn't need to be built into futility. This makes it a separate executable used just for that test. BUG=chromium:231547 BRANCH=none TEST=make runtests Note that the load_kernel_tests.sh still passes, using the external verify_kernel executable. Change-Id: I309d2561d65af7eb4f3708e9bc024852238deeec Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/235480 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: update the vbutil_kernel implementationBill Richardson2015-01-223-977/+2
| | | | | | | | | | | | | | | | | | | Now that the underlying bug is fixed (commit 64ef69c), this replaces the old vbutil_kernel command implementation with the new one that we rolled back in commit f1dba02. BUG=chromium:418647 BRANCH=none TEST=make runtests I've also built an image with this change, installed it on a Chromebook, ran make_dev_ssd.sh, make_dev_firmware.sh, recovered, etc. Everything still works. Change-Id: I8996e674a24b5d994658a6be2973ef3623cd659b Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/235429 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cgpt: Close stdout on exec'ing flashromNam T. Nguyen2015-01-221-2/+10
| | | | | | | | | | | | | | | | flashrom spills out "Reading flash... SUCCESS" and so on to stdout. This affects scripts calling to "cgpt". So this CL sets stdout to CLOEXEC before exec'ing flashrom. It still leaves stderr and stdin unclosed. BUG=None BRANCH=None TEST=cgpt show /dev/mtd0 2>/dev/null will not show any unnecessary text Change-Id: Ide1414c56f63ffe8bc2385a797f166476dacd732 Reviewed-on: https://chromium-review.googlesource.com/242295 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@google.com>
* cgpt_wrapper: Resolve the path to "cgpt" commandNam T. Nguyen2015-01-221-0/+17
| | | | | | | | | | | | | | | | Because we do not use "execvp", "cgpt.bin" is not resolved to the same directory as "cgpt". So we need to resolve the original command to its absolute path first, then append ".bin" to it. BUG=None BRANCH=None TEST="cgpt" no longer fails. Change-Id: Id22c2d97616867125e9744c00bbf527f8a176df4 Reviewed-on: https://chromium-review.googlesource.com/242294 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@google.com>
* cgpt_wrapper: Only write rw_gpt back if changedNam T. Nguyen2015-01-221-2/+12
| | | | | | | | | | | | | | | | We always wrote back the rw_gpt file to NOR flash. This operation is too slow. This CL compares if the original file has been changed by cgpt.bin before writing the file back to NOR. BUG=None BRANCH=None TEST=/usr/bin/cgpt show /dev/mtd0 now does not write back to NOR Change-Id: I4c63f0d4da72f3674e06a896fa329f5fc964a885 Reviewed-on: https://chromium-review.googlesource.com/242293 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@google.com>
* cgpt: Enable fast-verify when writing back to NORNam T. Nguyen2015-01-221-2/+2
| | | | | | | | | | | | | | | flashrom has been fixed, we could enable this flag for better performance. BUG=None BRANCH=None TEST=cgpt show /dev/mtd0 works much faster now. Change-Id: I7a6f5b8649b4293d9b4b4878ae8e599ea1c35289 Reviewed-on: https://chromium-review.googlesource.com/242292 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@google.com>
* cgpt: Properly show ChromeOS-scheme MTD partitionsNam T. Nguyen2015-01-222-4/+32
| | | | | | | | | | | | | | | | | | | When working on NAND, we do not actually work with one device name. We work on a temporary file instead. Moreover, depending on the type of the partition, we need to show different devices. BUG=None BRANCH=None TEST=All commands must be run on storm_nand TEST=/usr/bin/cgpt.bin find -t kernel should print out /dev/mtd2 TEST=/usr/bin/cgpt.bin find -t rootfs should print out /dev/ubiblock5_0 TEST=/usr/bin/cgpt.bin find -t data should print out /dev/ubi1_0 Change-Id: Ia36777ffa6a9cfc7c8ec4b128e49ece140428238 Reviewed-on: https://chromium-review.googlesource.com/242291 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@google.com>
* futility: prevent segfault for "futility help version"Bill Richardson2015-01-211-1/+2
| | | | | | | | | | | | | | | | | BUG=none BRANCH=none TEST=make runtests Before, this segfaulted: futility help version Now it doesn't. Change-Id: I7f8fb38d2eb96641b7664709cd78f976e8fed4b2 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/235428 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add cgpt_wrapper binary to transparently support NANDNam T. Nguyen2015-01-175-5/+508
| | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a "cgpt_wrapper" binary that will forward to "cgpt" binary as needed to transparently support NAND. The idea is that if we are working with an MTD device, this binary will exec out to "flashrom" to read in the GPT section, then exec out to the actual "cgpt" binary to work on that file, and finally write it back with "flashrom". This CL introduces a make target "install_mtd" to install this wrapper. The corresponding ebuild should use this make target when "mtd" USE flag is on. BUG=chromium:442518 BRANCH=none CQ-DEPEND=CL:239573 TEST=unittest and some trial runs with mtdram TEST=test on a real device with NOR flash and NAND Change-Id: I54534afa9a970ec858f313f698c0eb210c827477 Reviewed-on: https://chromium-review.googlesource.com/239580 Tested-by: Nam Nguyen <namnguyen@chromium.org> Reviewed-by: Daniel Ehrenberg <dehrenberg@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
* image_signing: work around shar invocation changingMike Frysinger2015-01-161-0/+4
| | | | | | | | | | | | | | | The shar utility changed the flag name and newer versions no longer accept -w. Mung the shellball on the fly to use the newer flag. BUG=chrome-os-partner:33719 TEST=signing old firmware shellball inside chroot passes BRANCH=none Change-Id: If5c2da3062bd72062baa779bb26ea56304c31558 Reviewed-on: https://chromium-review.googlesource.com/241064 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
* use ${} with make vars instead of $()Mike Frysinger2015-01-161-38/+38
| | | | | | | | | | | | BUG=None TEST=make still builds BRANCH=none Change-Id: Ie7292e4cc88338dc6544fd859028ce55557578b4 Reviewed-on: https://chromium-review.googlesource.com/241043 Commit-Queue: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Bill Richardson <wfrichar@google.com>
* integrate support for static buildsMike Frysinger2015-01-161-1/+10
| | | | | | | | | | | | | | | | | | | | Add a STATIC knob to easily get static builds of all binaries. We want this for the signer system. We also need to fix the bmpblk utility to look up its libraries via pkg-config. BUG=chromium:447051 TEST=`make STATIC=1` works now BRANCH=none Change-Id: Icaef1f19f4618b0ce2b934735796749539081a02 Reviewed-on: https://chromium-review.googlesource.com/241041 Trybot-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Bill Richardson <wfrichar@google.com> Commit-Queue: Mike Frysinger <vapier@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: Change find_fmap() to search larger alignments firstJulius Werner2015-01-141-12/+28
| | | | | | | | | | | | | | | | | | | | | | | | This patch changes the FMAP detection mechanism in host utilities to use the same algorithm as flashrom: try to check the offset with the largest possible alignment first, then subsequently check other offsets in the order of larger to smaller alignments. This provides consistency between the tools and makes the chance of finding the "wrong" FMAP (e.g. a bit pattern that just looks like an FMAP header, maybe from a piece of source code that tries to look for the same) less likely, since we usually try to prefer large alignments for the FMAP offset (for flashrom efficiency). BRANCH=None (should be updated on the signers... is that a branch?) BUG=chromium:447051 TEST='make runtests'. Manually ran the new dump_fmap on all images in tests/futility/data, and on a "known broken" Veyron_Pinky image that had a "fake" FMAP header at a 4-byte aligned offset. Change-Id: I15873573a93f3926c70136679dccd626e5038614 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/240750 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: Split NV storage field defintions into their own headerRandall Spangler2015-01-143-56/+69
| | | | | | | | | | | | | | | | | | And include it in vb2_api.h if VB20 internals are needed. This allows coreboot to get at the fields more cleanly for now, rather than duplicating the field definitions. In the long run, we should have APIs for this rather than having coreboot peek at the bits directly. BUG=none BRANCH=none TEST=emerge-veyron_pinky coreboot && make -j runtests Change-Id: Ic308c3470773b91191bf682ff1b3cfce8864d26a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/240285 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Introduce vb2ex_hwcrypto APIstabilize-storm-6683.Bstabilize-6670.Bstabilize-6662.BJulius Werner2015-01-0614-53/+328
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch extends the vboot2 API by three callback functions that the platform firmware may implement to offer hardware crypto engine support. For now we only support this for hash algorithms, and we will only allow it for firmware body hashes (not the keyblock or preamble which are too small to matter execution-time-wise anyway). The API is similar to the vb2api_*_hash() functions used to start body hashing in the first place, but we still take this round trip through vboot to allow it to do key/signature management and retain full control of the verification process. We also add a new preamble flag to explicitly disable this feature, so that we can later return to a solely software-based verification path through a firmware update in case a hardware crypto engine turns out to be insecure. CQ-DEPEND=CL:236435 BRANCH=None BUG=chrome-os-partner:32987 TEST='make runtests VBOOT2=1'. Manually booted on Pinky with and without HW crypto support and with the preamble flag set to confirm expected behavior. lib21/ parts untested except for compiling and new unit tests. Change-Id: I17c7d02f392089875a5942a5aafcf6a657354863 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/236453 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* nand: Allow smaller disks for booting a kernelfactory-samus-6658.BDan Ehrenberg2015-01-061-1/+1
| | | | | | | | | | | | | | | | | | When vboot eliminates trivially small disks, it checks the GPT size for external GPT disks. For upcoming NAND devices, the GPT size is 8kB. This patch changes the definition of trivially small disks to be those under 8kB so that NAND can be booted from. BUG=chromium:433433 TEST=make runalltests TEST=Booted and saw a kernel from NAND selected on from an 8kB GPT. BRANCH=none Change-Id: I5047b9b642d564d5e4d77dd0b6dafb9eea09176a Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238463 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* nand: vboot support for small GPTsDan Ehrenberg2015-01-057-19/+29
| | | | | | | | | | | | | | | | | | | | | | | This patch makes some small modifications to cgpt and vboot to root out the last vestigates of a fixed 128-entry GPT: - Get rid of the TOTAL_ENTRIES_SIZE constant and all users. - Reduce MAX_NUMBER_OF_ENTRIES to 128 (which is what the GPT spec specifies) so that this can be used for things like memory allocations without additional overhead. - Base the amount of GPT read/written on the number of entries specified in the GPT header on disk/flash. BUG=chromium:433433 TEST=make runalltests TEST=Modified fmap to make an 8k RW_GPT, wrote a GPT with cgpt, then rebooted and found that the GPT was correctly read after restarting and the appropriate mtd partitions were present. BRANCH=none Change-Id: I45317377da20259caf04a7a4fa077a892b03c45f Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238245 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: Handle GBB_FLAG_DISABLE_LID_SHUTDOWNstabilize-6592.BShawn Nematbakhsh2014-12-172-7/+35
| | | | | | | | | | | | | | | | Handle GBB_FLAG_DISABLE_LID_SHUTDOWN to disable lid-triggered system shutdown. BUG=chromium:434462 BRANCH=Auron TEST=Manual on Auron, with corresponding depthcharge change. Set GBB flag 0x1000 and disable powerd launch on boot. Close lid and issue 'reboot' command over ssh. Verify system reboots successfully into OS. Change-Id: Id2731508296a5ba9229f969f8224565d64f3d4a3 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/234995 Reviewed-by: Randall Spangler <rspangler@chromium.org>