summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Revert "vboot: Plumb the two disk sizes and 'gpt on device' param through"stabilize-6480.Bfactory-ryu-6486.Bfactory-ryu-6486.1.BJulius Werner2014-11-158-53/+15
| | | | | | | | | | | | | | | | | | | | This reverts commit 5040a945dfd0dd305d3ca8e923b8bf0bd5c6528e. This patch breaks booting any image (both fixed and removable) on Veyron_Pinky (and presumably every other non-NAND board?). By the power vested in me through the office of ChromeOS tree sheriff (well, five hours early but whatever) it is hereby reverted! BUG=chromium:425677 BRANCH=none TEST=Can successfully boot on Veyron_Pinky again. Change-Id: I9323a3d5e34491337fc7eb09dd00d845ac42997d Reviewed-on: https://chromium-review.googlesource.com/229963 Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Tested-by: Julius Werner <jwerner@chromium.org>
* vboot: Plumb the two disk sizes and 'gpt on device' param throughDan Ehrenberg2014-11-158-15/+53
| | | | | | | | | | | | | | | | | | | | | | | | To support an external GPT, disks have two new attributes: - A binary flag indicating whether the GPT is in the same address space as the payloads or a separate one. - The number of sectors of the streaming portion of storage, as opposed to the portion containing the GPT. These have been added elsewhere to GptData (in cgptlib) and BlockDev (in depthcharge). This patch adds the plumbing between those, including in the DiskInfo interface between the firmware and vboot. BUG=chromium:425677 BRANCH=none TEST=Interactively wrote the GPT with cgpt and observed the following boot with depthcharge to read the GPT from SPI and then read from the proper locations in NAND flash. make runalltests passes. Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Change-Id: I5a77e417aea8ee9442d18c200d1b073aa5375ecf Reviewed-on: https://chromium-review.googlesource.com/228943 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot: Fix load_kernel_tests to call the right cgptNam T. Nguyen2014-11-141-3/+5
| | | | | | | | | | | | | | | | load_kernel_tests called out to "cgpt" as is and this is interpreted as "/usr/bin/cgpt" on the host. This CL fixes that by using the right version in "build/install_for_test/bin/cgpt". BUG=none BRANCH=none TEST=rename /usr/bin/cgpt; make runtests Change-Id: I65ee0f271b081da6f719764e22c14fef05cdb65b Reviewed-on: https://chromium-review.googlesource.com/229590 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* vboot2: Add api-level functions to use new data structuresRandall Spangler2014-11-147-6/+433
| | | | | | | | | | | | | | | | | | And associated unit tests. And fix a memory overwrite in the old vb_api_tests.c, which apparently didn't touch a critical piece of the shared work buffer, but was still wrong. (This was a problem in the test, not in the code being tested.) BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I322fb7e6bb5214b0adcf5d6d48a0cd238abba88e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229738 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Split vb2_guid into its own header fileRandall Spangler2014-11-143-32/+44
| | | | | | | | | | | | | | | | This allows the api header to include it without pulling in the rest of the vboot2 internal structs. No functional changes; just moving a struct definition. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ife9408f9b597939a3cc85a10d534108e12f2d739 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229793 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot: cgpt: Treat drive_path as the GPT storageNam T. Nguyen2014-11-1424-552/+309
| | | | | | | | | | | | | | | | | | | | | | Previously, "cgpt" called out to "flashrom" directly to read and write NOR area. This CL removes that dependency and always treats "drive_path" as the storage of GPT structs. This makes it consistent that whatever device that cgpt reads from or writes to is always the device that stores GPT structs. We only need to pass in the size of the drive that contains the partitions, but we do not need to access to that drive. More information is in the bug. BUG=chromium:432611 BRANCH=none TEST=unittest CQ-DEPEND=CL:228942 Change-Id: Id0139adf70463cec4f2924de8b9a4725dbec822b Reviewed-on: https://chromium-review.googlesource.com/229736 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* vboot: cgpt: fix my_lba of the secondary GPTDan Ehrenberg2014-11-146-63/+77
| | | | | | | | | | | | | | | | | | | | Previously, my_lba of the secondary GPT was recorded as if that GPT was written at the end of the device. This patch tweaks my_lba to report where it is in the random-access GPT address space, namely at the end of that space. TEST=Compiled it into the firmware and observed the firmware to update the my_lba field of the secondary GPT. BRANCH=none BUG=chromium:425677 Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Change-Id: I88791fb2cff1086351ca8a3adeef675c4a88cc9a Reviewed-on: https://chromium-review.googlesource.com/228942 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Daniel Ehrenberg <dehrenberg@chromium.org> Tested-by: Daniel Ehrenberg <dehrenberg@chromium.org>
* vboot2: load keyblock and preamble from new-style structsRandall Spangler2014-11-145-0/+638
| | | | | | | | | | | | | And associated unit tests. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I6565d8f5da947b4874a656a61051df1a4ce415c7 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229163 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot: cgpt: Support writing GPT structs to NOR flashNam T. Nguyen2014-11-1315-100/+642
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL allows the GPT headers and partition entry arrays to be stored in a NOR flash device. Instead of treating both the NOR and NAND devices as one (in a sandwich way), this CL writes and reads the GPT structs independently of the actual device that houses the partitions. Therefore, the first usable LBA of the partitions will be at 0, and the last usable LBA is at the end of the NAND. +------------------------+ | NOR houses GPT structs | +------------------------+ | 0 | Index into v v +------------------------+ | NAND houses partitions | +------------------------+ Note that the "my_lba", "alternate_lba", "entries_lba" in the GPT headers are no longer meaningful. Consumers of cgptlib will have to set "stored_on_device" to either GPT_STORED_ON_DEVICE or GPT_STORED_OFF_DEVICE, and "gpt_drive_sectors" to the number of 512-byte sectors available to store GPT structs. The NOR read and write operations are done by "flashrom". BUG=chromium:425677 BRANCH=none TEST=unittest TEST=build with DEBUG, cgpt create/add/show on a stumpy-moblab Change-Id: I083b3c94da3b0bb3da1a7b10c6969774080a2afd Reviewed-on: https://chromium-review.googlesource.com/226800 Reviewed-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* vboot2: Add code and tests for verifying vb2_fw_preamble2Randall Spangler2014-11-125-11/+277
| | | | | | | | | | | | | | | This is the last low-level data structure verification code for the new data structures. Subsequent changes are the next level up the food chain. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I2e45106c27447eb624c1ed562e40b98088249742 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/228360 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* crossystem: add platform for ipa8064Vadim Bendebury2014-11-101-0/+1
| | | | | | | | | | | | | | | | | Storm and Whirlwind use Ipq8064 chipset, need a new platform category in crossystem. BRANCH=storm BUG=chrome-os-partner:33592 TEST=manual localhost ~ # echo $(crossystem platform_family) IPQ8064 localhost ~ # Change-Id: I921771e12604d3051e5d4213db494a79007147ff Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/228677 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* crossystem: cache vbnv contents to avoid lengthy readsVadim Bendebury2014-11-101-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Storing nvram in SPI Flash becomes more and more popular. Retrieving it takes quite a while due to various flashrom issues. While flashrom still needs to be improved to minimize its running time, a good speed up can be achieved by caching the nvram contents in crossystem. The cache is invalidated each time nvram is written (this could be optimized by updating the local copy, but probably is not worth the extra effort). BRANCH=storm BUG=chrome-os-partner:33592 TEST=crossystem runs much faster now: localhost var # time /var/tmp/crossystem . . . real 0m1.669s user 0m0.790s sys 0m0.170s localhost var # Change-Id: Ie4a483efc189257ff58c92bdc39871b917c89727 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/228655 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
* vboot2: Change preamble to contain a list of signaturesrelease-R40-6457.Bfactory-auron-6459.BRandall Spangler2014-11-066-50/+30
| | | | | | | | | | | | | | | Use struct vb2_signature2 objects to hold the hashes of firmware components, rather than a separate vb2_fw_preamble2_hash struct. Better for code reuse. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ia9e23c1488a884f2d6fab4c4be51b25d3ff25c2f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/228241 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: pass const work buffers, and clarify min_offset outputRandall Spangler2014-11-067-21/+28
| | | | | | | | | | | | | | | | | | | | | When a work buffer is passed to a function, and duplicated inside that function, allocations made against the duplicate are automatically freed when the duplicate goes out of scope. Make that explicit in the comments. And pass in const struct workbuf * instead of struct workbuf *, to make it clear that the passed-in work buffer pointer is not being altered by the function. Also, comment that the value of min_offset becomes undefined if vb2_verify_common_member() or vb2_verify_common_subobject() fails. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Icc6010e6ef786f78cd2176a59d4d0e6e14905a11 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227524 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: add code to verify vb2_keyblock2Randall Spangler2014-11-063-1/+258
| | | | | | | | | | | | | | | Now supports multiple signatures per keyblock. And associated unit tests. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I7f2ef216e3689a22ed86c34763f68345d4080e04 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227181 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: add support for verify data / digest using new signature structRandall Spangler2014-11-056-2/+325
| | | | | | | | | | | | | | | This adds the vb2_signature2 equivalents of vb2_verify_digest() and vb2_verify_data(), including support for bare hash signatures. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I372c9e5f0be926a833e4ca8f84665cfb05907481 Reviewed-on: https://chromium-review.googlesource.com/226950 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
* vboot2: add support for new vb2_signature2 structRandall Spangler2014-11-057-1/+255
| | | | | | | | | | | | | And assocated unit tests. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I37fccafd8ccee5c0d55e3746c1611a8dff73145a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226939 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: convert structs outside of individual test funcsRandall Spangler2014-11-051-81/+73
| | | | | | | | | | | | | | | | This reduces duplicated code in the test functions. (Well, not so much duplicated code yet, but it will when more tests are added in the next CL. And it's easier to review this piece separately from the added tests.) BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I863cdfd44d35b55df9799fd45a6cf8e40dd1ad21 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226925 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: be consistent in use of sig_algorithm vs sig_alg in vboot2 structsRandall Spangler2014-11-054-11/+11
| | | | | | | | | | | | | | | | Previously, we had a mix of sig_algorithm and sig_alg member names, and it was hard to remember which struct used which variant. Prefer sig_alg because of the 80-column limit. Same with hash_alg vs. hash_algorithm BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ifbb60f3172549e29efc0fb1f7f693efa51eb7cc3 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226943 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: use common header size fieldsRandall Spangler2014-11-058-97/+365
| | | | | | | | | | | | | | | | Add functions for verifying object integrity using common header size fields. Convert vb2_packed_key2 to use the the new functions. This isn't much prettier for packed keys; the benefit is more obvious for keyblocks (coming next). BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I0c09533368abb7ced3b5ac622a15e62832413b7f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226874 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* mocked_tpm: Add back missing parenstabilize-6436.BDuncan Laurie2014-11-041-0/+1
| | | | | | | | | | | | | | This was deleted in the previous commit and breaks building with MOCK_TPM=1 BUG=chrome-os-partner:32698 BRANCH=all TEST=build with MOCK_TPM=1 Change-Id: Ie437f9fb4c60161a95ca1cf992035858f02e3f19 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227220 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vb2: parse dev mode in phase1Aaron Durbin2014-11-033-32/+35
| | | | | | | | | | | | | | | | | | | | | | The rest of the system software expects dev mode to be orthogonal to recovery mode. However, vb2_fw_phase1() was only checking recovery mode. The caller would then not call vb2_fw_phase2() which checked the developer mode settings. Fix this by doing the necessary steps in vb2_fw_phase1(). BUG=chrome-os-partner:33264 BRANCH=None TEST=None yet. Change-Id: I06da388c3ca33754ddb5937a2877fbc287946490 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/225906 Tested-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Tested-by: Benson Leung <bleung@chromium.org>
* make_dev_ssd: support devices using /dev/dm-1 as root device.Hung-Te Lin2014-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | Some devices may use rootdev=/dev/dm-1 as root device (the default one was dm-0, according to build scripts). Running make_dev_ssd.sh --remove_rootfs_verification on these devices will fail changing rootdev kernel command line, and cause people not able to re-mount root device as writable. To support running make_dev_ssd on these devices, we want to change the rootdev pattern to dm[0-9]. BUG=chromium:428041. TEST=make_dev_ssd.sh --remove_rootfs_verification BRANCH=none Change-Id: Idfd251c58e7d39b0b80ec1fc68989c2f49bdd1b2 Reviewed-on: https://chromium-review.googlesource.com/226782 Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org>
* vboot2: un-nest data structuresRandall Spangler2014-11-017-111/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally, we designed the vboot data structures so that some of them had sub-structures. Then the variable-length data for each of the structures was at the end. So: struct vb2_keyblock { struct vb2_packed_key struct vb2_signature } // Followed by variable-length data for keyblock // Followed by variable-length data for packed key // Followed by variable-length data for signature This had the weird side effect that the header and data for the sub-structs were not contiguous. That wasn't too bad before, but it gets more complicated with the new data structures. Each structure now can also have a description. And keyblocks can have a list of signatures. Structures also couldn't really know their own size, since a sub-struct might have a 20-byte header, but then 2K of other data in between that and the data for the sub-struct itself. So, un-nest all the data structures. That is, the keyblock now contains the offset of the signature struct, rather than the signature struct itself. And then all the variable-length data for each struct immediately follows the struct itself. So: struct vb2_keyblock2 { // Offset of packed key // Offset of first signature } // Followed by variable-length data for keyblock struct vb2_packed_key // Followed by variable-length data for packed key struct vb2_signature2 // Followed by variable-length data for signature (desc, sig data) Verifying and traversing these objects is much more straightforward. And each struct can now know its own size. This first change rearranges the structures. Descriptions now immediately follow the fixed size structure headers. The next change adds better verification of the structures, using the fixed_size and total_size fields in the common header. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ieb9148d6f26c3e59ea542f3a95e59d8019ccee21 Reviewed-on: https://chromium-review.googlesource.com/226824 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
* vboot2: Add GUIDs for VB2_SIG_NONE signature typesRandall Spangler2014-10-311-3/+16
| | | | | | | | | | | | | | | Signatures with VB2_SIG_NONE are unsigned hashes. To make it easier to locate these signatures in the keyblock's list of signatures, define GUIDs for them. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I5bf9424107d7703b1a191b1bdf02954192ffc583 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226813 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot: cgpt: Check for NULL entry array.Nam T. Nguyen2014-10-312-0/+26
| | | | | | | | | | | | | | | | | When GptLoad() fails to validate a header, it will not load the corresponding entry array, and hence will not allocate memory. The "*_entries" pointer then stay NULL. This CL checks for NULL pointer in CheckEntries() in the same way that CheckHeader() does. BUG=none BRANCH=none TEST=unittest Change-Id: I9f72e843590fbcbcf90d55640f86c782446e8755 Reviewed-on: https://chromium-review.googlesource.com/226778 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* Extend HWID digest into PCR1 (GBB v1.2 only)Bill Richardson2014-10-3110-129/+414
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GBB header v1.2 adds a digest of the HWID string to the blob (and maintains it when updated with the current futility/gbb_utility). This CL causes VbSelectFirmware() to extend PCR1 with that HWID digest (only for GBB header v1.2 and later, of course). Tests are updated. This also adds a "pcr" command to futility to help determine that the change is working on the hardware (adds 4K bytes or fewer to the size of the executable). BUG=chromium:415714 BRANCH=ToT (and maybe others?) TEST=make runtests, manual install on HW To test on hardware, build and update a system with this change (both the disk image and the RO firmware). NOTE: The BIOS image must be built in a chroot that is using the current version of futility. You may need to update your chroot if your BIOS image still produces v1.1 GBB headers. Check with: futility show <firmware_image.bin> | grep -B1 'digest:' Boot the new system with a new test image, then follow these steps: Read the BIOS: # flashrom -r /tmp/bios.bin Make sure the GBB has a valid digest for the HWID. # futility show /tmp/bios.bin | grep -B1 'digest:' HWID: SAMUS TEST 8028 digest: 4172d24f40bf72cc0ab8... <valid> # Extract only the sha1sum-sized part of the HWID digest: # futility show /tmp/bios.bin | awk '/digest:/ {print $2}' | colrm 41 4172d24f40bf72cc0ab878b4c589b8fe9cf4405e # Simulate extending that value in a PCR using the futility "pcr" command: # futility pcr 4172d24f40bf72cc0ab878b4c589b8fe9cf4405e PCR: 0000000000000000000000000000000000000000 + 4172d24f40bf72cc0ab878b4c589b8fe9cf4405e PCR: b6e5ffd2d898a7b15236ad22ca25f53ac1f40776 # Finally, look at the value of PCR1. It should match the last line of the futility pcr output: # head /sys/class/misc/tpm0/device/pcrs | grep PCR-01 PCR-01: B6 E5 FF D2 D8 98 A7 B1 52 36 AD 22 CA 25 F5 3A C1 F4 07 76 # Change-Id: I09cf855f1a24616cc1a9ddb676670edbc76827d2 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226408 Reviewed-by: Darren Krahn <dkrahn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: add version commandBill Richardson2014-10-314-0/+49
| | | | | | | | | | | | | BUG=none BRANCH=none TEST=manual make && ./build/futility/futility version Change-Id: I362b13d3befba62a33bc9fd2e87ad68f4bc62a84 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226779 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: Add vb2_unpack_key2() and unit testsfactory-rambi-6420.BRandall Spangler2014-10-2910-3/+341
| | | | | | | | | | | | | | | | | | | | | | | This unpacks new-style packed keys. For now, it can also handle old-style packed keys by passing them to the old unpacking function. Once we've switched over to new-style keys in the signing scripts, we'll remove the old format to save code size. Also added is a test library which converts from old to new struct formats. That should eventually get absorbed into futility, and the test keys directory should have both old and new format packed keys in it. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I0fe31f124781d1ea1efedab65dcd6130bfca18dd Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225490 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Add verification for common vb2 struct headerRandall Spangler2014-10-295-11/+115
| | | | | | | | | | | | | | All new-style structs have a common header. This adds a verification function for that common header, and tests for it. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I668486e77f7200c10b43aa2d17b4dd6639e5538e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225459 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* cgpt: Separate out certain GPT manipluation functionsstabilize-6415.Bfoo-testDan Ehrenberg2014-10-297-284/+315
| | | | | | | | | | | | | | | | | For kernel NAND support, some vboot/cgptlib functionality is needed from depthcharge. This patch moves certain function declarations to a new header in firmware/include and puts their definitions in a common place. TEST=make runalltests passes and packages build BRANCH=none BUG=chromium:403432 Change-Id: Idd42b1f9f531651d78bb4afb80ca90c24aae93d9 Reviewed-on: https://chromium-review.googlesource.com/224996 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Daniel Ehrenberg <dehrenberg@chromium.org> Tested-by: Daniel Ehrenberg <dehrenberg@chromium.org>
* vboot2: Move and rename functionsRandall Spangler2014-10-289-121/+130
| | | | | | | | | | | | | | | | | | | | | | | | Move packed key functions to their own file, in preparation for introducing support for vb2_packed_key2. Rename the awfully-named vb2_verify_fw_preamble2() function to vb2_load_fw_premable(), since the new structs actually have a vb2_fw_preamble2 struct and that would be very confusing. Rename vb2_verify_fw_keyblock() to vb2_load_fw_keyblock(), so it matches. No functional changes, just renaming. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ia914e48e6c5814ab3205b999ceda1aa2452206ff Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225458 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: use enum signature algorithmRandall Spangler2014-10-289-107/+166
| | | | | | | | | | | | | | | | | | | This changes the internals of vboot2 to use the enumerated type for signature algorithm. The conversion from crypto algorithm is done only when unpacking the key. This is preparation for the vboot2 data types, which separate signature and hash algorithms into their own fields. There is no external change in the calling API to vboot, and no change to the external data structures. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I2e176d186d88cc7541644e001e720b4aee456be0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225209
* vboot2: use enum hash algorithmstabilize-6412.BRandall Spangler2014-10-2812-62/+91
| | | | | | | | | | | | | | | | | | | | | | This changes the internals of vboot2 to use the enumerated type for hash algorithm. The conversion from crypto algorithm is done only when unpacking the key (and ok, in checking the rsa padding, but that goes away in the next change). This is preparation for the vboot2 data types, which separate signature and hash algorithms into their own fields. There is no external change in the calling API to vboot, and no change to the external data structures. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I9c6de08d742dab941beb806fbd2bfc1e11c01e2c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225208 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Log recovery reason and subcode to consoleJulius Werner2014-10-251-2/+6
| | | | | | | | | | | | | | | | | | | | | Looks like vboot2 currently never outputs the current recovery reason anywhere, which is annoying for debugging devices without working display (where you could press TAB). This patch adds log messages both when deciding to go into recovery mode and when picking up an existing recovery request from NVRAM, for maximum visibility. Also removes the "Both slots are bad." part of the vb2_fail() message, since this is not necessarily true and can be confusing (there are many other possible reasons why it might want to go into recovery). BRANCH=ToT BUG=None TEST=Manual Change-Id: Ic98c61223dce00e830ea0f199878d47b214bb224 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225160 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: new data structuresRandall Spangler2014-10-246-31/+474
| | | | | | | | | | | | | | | | | These structures allow for simplication and feature expansion in vboot. They are NOT backwards-compatible with old vboot1 structs. This CL simply adds the new structs and unit tests for struct packing; future CLs will add support for them in the firmware library and futility. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I22532acf985dd74316bd30f17e750f993b6c53d7 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/224820 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Fix broken compatiblity check for gbb header 1.1Randall Spangler2014-10-232-7/+10
| | | | | | | | | | | | | | | | vboot2 supports only GBB header versions 1.1+. When the GBB header was rev'd to 1.2, this broke the compatibility check for 1.1. However, the test was written in such a way that wasn't detected. Fix the check and the test. BUG=chromium:415227 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ifeb1f21bf5cf3cc05d31ac7912693e090eb8fd5e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225110 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: move verify digest to 2commonRandall Spangler2014-10-228-57/+82
| | | | | | | | | | | | | | This removes code duplicated between 2common.c and 2rsa.c. This is in preparation for adding new unsigned hash algorithms. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make -j runtests Change-Id: Ic9c542ae14d3b7f786129c1d52f8963847a94fb8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/224780 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Add hwid digest field to GBB headerBill Richardson2014-10-2112-14/+132
| | | | | | | | | | | | | | | | | | | This adds a field in the GBB header to store the sha256 digest of the HWID string, and updates gbb_utility so that it stores the digest when it modifies the HWID. Because this is a new field, the GBB_MINOR_VER is incremented. BUG=chromium:415227 BRANCH=ToT TEST=make runtests, VBOOT2=1 make runtests Since the GBB is in the RO firmware, there should be no side effects for existing devices (but even without that, they should handle a minor version change without complaint). Change-Id: Icdb2a0b564677b0b65e58df897d2ec5af3964998 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221360
* crossystem: Add support for multiple gpiochip entriesDuncan Laurie2014-10-201-4/+46
| | | | | | | | | | | | | | | | | | | | | | The current logic for finding a GPIO expects only one gpiochip entry to exist in /sys/class/gpio. With Samus there is a second entry because the codec also exports a set of GPIOs. To solve this we can use the gpiochip#/label file and compare against the GPIO controller name described in ACPI. This adds support for that detection method, as well as a new GPIO controller entry for INT3437:00 which is used in Broadwell systems. BUG=chrome-os-partner:33098 BRANCH=samus TEST=crossytem wpsw_cur works on samus (TOT with enabled codec) Change-Id: Ib06f25c7c7e1451a3ab3bb00fd063e23b4d75878 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/224156 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* crossystem: Change ReadFileInt to take an unsigned int pointerDuncan Laurie2014-10-184-92/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently ReadFileInt assumes that an integer value read from a file is never going to be "-1" and uses that value to indicate failure. In particular for GPIO values that may be returned by the kernel it is possible for them to be not simply 0 or 1 but instead a bit within the GPIO status register that indicates the value. The function semantics are changed to have the caller pass in the variable to store the integer in, and use the return code explicitly as a pass or fail condition. This requires all the callers of ReadFileInt to be changed to use the new scheme, and the x86 ReadGpio function is changed to normalize the GPIO value that is read from the kernel instead of assuming it is always 1 for active high values. BUG=chrome-os-partner:32645 BRANCH=samus,auron TEST=build for samus, check crossystem output and ensure that all values are properly reported and that wpsw_cur is correct now. Also tested to ensure no changes in output on: x86-alex, daisy, peach_pit, lumpy, stumpy, nyan_big, nyan_blaze, rush_ryu, panther, wolf, zako, auron, rambi, squawks, parrot_ivb, veyron_pinky Change-Id: I824152eed5f96cf1faaa18ba31a01f4d346ad172 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223009 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: move vb2_safe_memcmp() from rsa to commonRandall Spangler2014-10-184-32/+45
| | | | | | | | | | | | | | This will be needed by other algorithms, so should not live inside the rsa module. Also added explicit unit tests for it. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I92c8c6484964a93d755ac2ee93b57511794540e9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/224111 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* cgpt: Validate GPT headers before loading themNam T. Nguyen2014-10-172-21/+60
| | | | | | | | | | | | | | | | | This CL validates the GPT headers before continue loading its fields. BRANCH=none BUG=chromium:422469 TEST=unittest TEST=cpgt show on a random file. There should be some warnings. TEST=boot from SD/USB on a device. cgpt show that boot device. It should not fail. Change-Id: I1e5e986cc46620643ec8ec6914fa696a3d04d23a Reviewed-on: https://chromium-review.googlesource.com/223800 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* vboot: Support SLOW_EC_UPDATE with OPROM_MATTERSDuncan Laurie2014-10-173-7/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to display the slow EC update screen on x86 devices in normal mode it is necessary to request a reboot where the VGA Option ROM is loaded. This needs a bit of plumbing to pass the OPROM_MATTERS and OPROM_LOADED flags into shared data so they can be consumed in the VbEcSoftwareSync() function. It also needs the VbInit() function to not immediately request a reboot if the VGA Option ROM was loaded in normal mode and the SLOW_EC flag is set as it will still need to be used during software sync. A FIXME in VbEcSoftwareSync() is implemented and the comment is removed, and two extra checks are done. First, if rebooting to RO then also check if the VGA Option ROM is needed to save an extra reboot, and second when exiting the software sync function request a reboot without the VGA Option ROM if it was done in normal mode and the option rom was needed+loaded. The request for a reboot from VbEcSoftwareSync() is saved when doing EC update in case there is an (optional) PD software sync that may also need to display the screen. BUG=chrome-os-partner:12257,chrome-os-partner:32379 BRANCH=samus TEST=all tests pass, manual testing: 1) in normal mode, with EC/PD in RW, ensure that they are rebooted to RO and the VGA Option ROM is loaded and the wait screen is displayed, and then the system is rebooted at the end and the VGA Option ROM is not loaded. 2) same as #1 with EC/PD in RO already, same result 3) same as #1 with system in developer mode, same result except there is no reboot at the end of software sync 4) same as #1 with system in developer mode and EC/PD in RO, ensure that there is no extra reboot at the beginning or end of software sync. Change-Id: Id592181efd640f4cd37a986cd1dcc29f3ca45104 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223718 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* sign_official_build: Support new image layout (always installable kernel in B).Hung-Te Lin2014-10-161-178/+145
| | | | | | | | | | | | | | | | | | | | | ChromiumOS images have recently changed the installable vblock from stateful partition to kernel + vblock in slot B. sign_official_build script should follow that layout so other scripts (ex, cros_generate_update_payload) won't find wrong blob. BRANCH=none BUG=chrome-os-partner:32156 TEST=for image_t in ssd usb install recovery; do ./sign_official_build.sh $image_t IMAGE KEYDIR output$image_t.bin ./sign_official_build.sh verify output$image_t.bin done # Also boots images without problem. Change-Id: I04e2b50f3f3355263ba6de9567b4a82c040c5826 Reviewed-on: https://chromium-review.googlesource.com/221890 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org>
* vboot2: move firmware hash tags to their own header fileRandall Spangler2014-10-162-17/+42
| | | | | | | | | | | | | | | And add a few hash tag types we'll be supporting soon. No functional changes; just moving an enum from one header to another. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I6f0fa54ee85fd857c4037856b81e2159e92f1ea9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223532 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Split crypto algorithms into their own header fileRandall Spangler2014-10-164-28/+46
| | | | | | | | | | | | | | | | This allows the algorithm list to be shared by code which simply needs to look at the vboot structures. No functional changes; just moving enums around and adding comments. BUG=chromium:423882 BRANCH=none TEST=make runtests; VBOOT2=1 make runtests Change-Id: Ia8cefeffb28d5eceb290540195193ea13e68e2c1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223541 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* futility: Be more accepting of how it's invokedBill Richardson2014-10-152-86/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that futility is pretty much working as intended, we don't have to be quite so picky in the way it's being invoked. Up until now, it's only worked when invoked as "futility" or as one of the built-in commands, such as "dump_fmap". This change removes those restrictions. You can invoke futility under any name you wish. If it recognizes the name as a built-in command, great. Otherwise it will require a valid command as the first arg, just like it always has. BUG=none BRANCH=ToT, Samus TEST=make runtests In addtion to the new test included with this CL, I manually ran lddtree --copy-to-tree=blah --generate-wrappers /usr/bin/futility ./blah/usr/bin/futility dump_fmap -h tests/futility/data/bios_peppy_mp.bin Before this CL, the wrapper didn't work because the binary was being invoked as futility.elf, which was rejected. After this CL, the wrapper works fine. Change-Id: Iafdaff6e07ed294a7d29e4cff599ace0a3089229 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223386 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* Use VbExStream APIs to read the kernel partitionRandall Spangler2014-10-152-36/+83
| | | | | | | | | | | | | | | | | | | | | | | | | This is necessary to support reading the kernel from raw NAND flash, where the driver may need to skip over bad sectors, and absolute sector addressing is thus not practical. The impact is relatively minor. Vboot only did two reads per kernel anyway, one for the first 64KB of the partition and a second for the rest of the kernel data. Firmware which uses vboot will need to implement the streaming APIs. Or, as a really easy workaround, just copy the implementation from firmware/stub/vboot_api_stub_stream.c, which translates from the new streaming API to the old sector-based disk API. BUG=chromium:403432 BRANCH=none TEST=make runtests; passes. CQ-DEPEND=CL:221992, CL:222885, CL:222945 Change-Id: I7437b489650c95c09ac68b67d4d86f9e15c2fa73 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/222410 Reviewed-by: Daniel Ehrenberg <dehrenberg@chromium.org>
* vboot: new streaming APIsDan Ehrenberg2014-10-153-1/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds three functions called from vboot into depthcharge to support NAND. NAND needs to stream rather than be accessed randomly in order to skip bad blocks. The intended flow from vboot1 is: - Read the GPT from a NAND disk handle, and depthcharge will silently fill it in with reads from from SPI - When a partition is selected, open a stream on the volume to access NAND - Sequentially read the NAND partition - Close the NAND stream This can be done multiple times when trying different partitions. The stream is associated with the GPT by reading/opening a stream from the same disk handle. This patch includes stub implementations by rspangler to translate the stream calls to block device calls. To reduce vboot code duplication, this flow will be done for all media types eventually, but a STREAMING flag is included to ease the transition. The draft depthcharge code can be found at https://chromium-review.googlesource.com/#/c/222312/ BUG=chromium:403432 TEST=stub implementations pass unit tests; together with upcoming depthcharge and vboot code, actually boots a kernel. This compiles by itself. BRANCH=none Change-Id: I660a89594390c72c2ef6ea2564367ce62bd90cf2 Reviewed-on: https://chromium-review.googlesource.com/221992 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Daniel Ehrenberg <dehrenberg@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>