summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* crossystem: rename Vb*NvStorage_mkbp to Vb*NvStorage_mosysDavid Hendricks2014-10-091-4/+4
| | | | | | | | | | | | | | | | This is just a cosmetic tweak to make it a bit clearer that mosys is the underlying interface for these particular vbnv read/write functions. BUG=none BRANCH=none TEST=it still compiles Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: Ide172bfecf608a30489d25026268aedfc421ce4d Reviewed-on: https://chromium-review.googlesource.com/222062 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* crossystem: handle "flash" media in Vb*NvStorage()David Hendricks2014-10-091-2/+2
| | | | | | | | | | | | | | | | This handles VBNV data stored in SPI flash which happens to be the exact same way we handle VBNV data stored in the EC. BUG=chrome-os-partner:31529 BRANCH=none TEST=with CL:221349 applied, crossystem on storm no longer spews tons of errors Change-Id: I021d9f430acfac34dff44a927361a5a0e5ae2ff8 Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/222061 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* image_signing: ignore missing chrome_dev.confMike Frysinger2014-10-071-1/+1
| | | | | | | | | | | | | | | If we try to sign an image w/out Chrome, this file won't exist. Run grep with the -s flag to silence those warnings. BUG=chromium:418817 TEST=`cbuildbot storm-release` no longer warns BRANCH=None Change-Id: Ibac0978e3e4d9f89c00206a2dd21c1d71544f710 Reviewed-on: https://chromium-review.googlesource.com/221184 Reviewed-by: Gaurav Shah <gauravsh@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org>
* vboot2: Add previously tried slot and result to NV storageRandall Spangler2014-10-049-4/+96
| | | | | | | | | | | | | | | | | | | | This gives recovery mode information on two boots back instead of one, which may be handy for debugging. It also allows determining whether a failure of the current boot should try the other slot or go to recovery, using only information stored in NV storage. Added crossystem support for printing the fields, and unit tests. BUG=chrome-os-partner:32585 BRANCH=none TEST=make runtests; VBOOT2=1 make runtests Change-Id: Ia9f4186210d30217b902db7c513ae4ab8851f8f4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221230 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Improve cross-reference targetsBill Richardson2014-10-041-20/+32
| | | | | | | | | | | | | | | | | | | | | | | | | Any of these: make xrefs make tags make TAGS should create "build/cscope.files", containing a list of the source files used in preparing to run tests (minus any test sources). If the 'ctags' or 'etags' programs are installed in the chroot, they'll be run too. BUG=none BRANCH=ToT TEST=manual make xrefs cat build/cscope.files Change-Id: If1173af7edb41742bb348b728238d800ef66ad55 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221425 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: Fix saving the slot we tried back to nv storageRandall Spangler2014-10-042-0/+7
| | | | | | | | | | | | | | | | | Previously, we only kept that slot info in RAM. We read it from NV storage, but never wrote it back. Added a test to confirm proper behavior (and made sure it failed before patching 2misc.c with the fix). BUG=chrome-os-partner:32583 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ie12124d9cbe417914fbde14ea5086380d637240f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221214 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Convert vbutil_what_keys to use /bin/shBill Richardson2014-10-031-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This just involves deleting the "set -o pipefail" line. With bash, that meant that any program failure in a pipe would be fatal. Without it, only the last program matters. This usually means that the last command simply gets no input, in which case the program just appears to do nothing instead of complaining about whatever the problem was. Since vbutil_what_keys is generally only used to help debug a failure to boot, that's not a major problem. BUG=chromium:419773 BRANCH=ToT TEST=manual Tried on a Pit, it works: localhost ~ # /tmp/vbutil_what_keys /dev/mmcblk0 -e IMAGE: /dev/mmcblk0 part 2 kernel: d6170aa480136f1f29cf339a5ab1b960585fa444 (!DEV DEV !REC) developer keys part 4 kernel: d6170aa480136f1f29cf339a5ab1b960585fa444 (!DEV DEV !REC) developer keys localhost ~ # flashrom -r /tmp/bios.bin flashrom v0.9.4 : 904e8a5 : Sep 22 2014 20:47:40 UTC on Linux 3.8.11 (armv7l), built with libpci 3.1.10, GCC 4.8.x-google 20140307 (prerelease), little endian Reading flash... SUCCESS localhost ~ # /tmp/vbutil_what_keys /tmp/bios.bin -e BIOS: /tmp/bios.bin hwid: PIT D3A-D4Q-A3L root key: a026a7a4a0bf0fa32d6b7aa90a80d5ef01a3b799 Daisy MP-v3, Peach-Pi MP, Peach-Pit MP-v2, Snow MP recovery key: 6d9a2ca8b3080a97e1e5a4efbc5386ead77c3c7f Peach-Pit MP-v2 localhost ~ # Change-Id: I171da3bf688032f469d7a5cdb42278d8028b7e0d Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221176 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Don't install vbutil_what_keys on the targetBill Richardson2014-10-031-3/+3
| | | | | | | | | | | | | | | | | BUG=chromium:419773 BRANCH=ToT TEST=manual make MINIMAL=1 DESTDIR=FOO install make MINIMAL= DESTDIR=BAR install find FOO BAR -name vbutil_what_keys It should only install the script into BAR/. Change-Id: I48d3a780533c5b72cc18720d39b18ac286b07fd9 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221177 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* futility: rolled back vbutil_kernel changeBill Richardson2014-10-025-71/+1012
| | | | | | | | | | | | | | | | | | | | | When disabling verity with make_dev_ssh.sh, a bug in vbutil_kernel caused the re-signed kernel size to be the entire kernel partition instead of just the necessary bits. Until we can improve the test coverage, I'm rolling back the changes that introduced this bug. BUG=chromium:418647 BRANCH=ToT TEST=manual Created a new test image with these changes. You can install it and disable dm-verity and it works (although there seems to be an unrelated browser startup issue on ToT). Change-Id: I48e8427b05e191c9894c42056429a79d57bfc78d Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/220935 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot_kernel: Validate GPT header before usingDuncan Laurie2014-10-022-20/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In AllocAndReadGptData() the code was changed to use the GPT header to determine the LBA of the GPT entries. This change did not account for devices that have an invalid header and it can attempt to read from invalid block addresses on a device. This commit happened here: a2d72f7 vboot: cgpt: Refer to partition entries by entries_lba. https://chromium-review.googlesource.com/213861 The subsequent steps in vboot, LoadKernel->GptInit->GptRepair will fix a missing header and entries, so it is only necessary for one of the headers to be valid. This is commonly the case with a new USB stick that has an image written to it as only the primary header will be valid in this case. However it is also true if the primary header has been corrupted and the secondary header is still valid. The code has been changed to call CheckHeader() on the primary and secondary headers before attempting to use the 'entries_lba' field to read the entries from the device. AllocAndReadGptData() now only fails if both headers are invalid. A number of new unit tests are created to check for these failure conditions. In order to support this I had to extend the vboot_kernel test infrastructure to have a buffer for the mocked disk data instead of just ignoring reads and writes. This is because many of the existing tests assumed they could have an invalid GPT header and still pass. Now that the header is checked it is necessary for a valid header to be created before the tests can pass. BUG=chrome-os-partner:32386 BRANCH=samus,auron TEST=All unit tests pass when running 'make runtests' In addition real-world testing was done by corrupting the primary and/or secondary headers of USB stick to ensure that it will successfully boot if one of the headers is valid. Change-Id: I7f840a44742fa3ba9a124df29ab5749e4c5a40c1 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/220757 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Nam Nguyen <namnguyen@chromium.org>
* futility: show vs verifyBill Richardson2014-09-276-23/+163
| | | | | | | | | | | | | | | | This adds a --strict mode to the show command, which requires that all signatures be valid in order to exit cleanly. It also creates a "verify" command, which is really just an alias for "show --strict". BUG=none BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: I1fed7db7fe7128191bcab0c615706ef4fe2709f5 Reviewed-on: https://chromium-review.googlesource.com/219732 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: Allow signing raw firmware blob and keyblocksBill Richardson2014-09-274-4/+328
| | | | | | | | | | | BUG=none BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Ib1cf55301fd4c54e3280ef01b7d67a780e7e56fe Reviewed-on: https://chromium-review.googlesource.com/219731 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: Add support for [re]signing kernel partitionsBill Richardson2014-09-279-1141/+741
| | | | | | | | | | | | | | BUG=none BRANCH=ToT TEST=make runtests This also modifies the tests to compare the futility sign command results against the vbutil_kernel results. Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Ibc659f134cc83982e3f0c0bcc108cc0eddbe228e Reviewed-on: https://chromium-review.googlesource.com/219730 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: do traversal of a buffer, not a fileBill Richardson2014-09-254-34/+93
| | | | | | | | | | | | | | | | We have been traversing things by passing a file descriptor. Now the caller should mmap the file first. This will allow the caller to determine the file type before traversing into it, so we can check args. BUG=none BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: If69799bde0133689dc9fb5111e6ecb5ac61639c7 Reviewed-on: https://chromium-review.googlesource.com/219649 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: Prepare to handle kernel partitions & firmware blobsBill Richardson2014-09-254-52/+124
| | | | | | | | | | | | | | | | This adds new file types to prepare for signing kernel partitions and raw firmware blobs (FW_MAIN_A/B). BUG=none BRANCH=ToT TEST=make runtests No new functionality yet. Change-Id: Ic6b6b94bb99f00ab54609dfe1b753b53868abaca Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219648 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: implement vbutil_kernel using buffers, not filesBill Richardson2014-09-259-596/+1958
| | | | | | | | | | | | | | | | | | The original vbutil_kernel command used file read and write to make changes. Futility prefers to use memory-mapped files. This rewrites cmd_vbutil_kernel.c to use that scheme. BUG=none BRANCH=ToT TEST=make runtests The original cmd_vbutil_kernel.c is renamed, and a test written to ensure that the refactored version produces identical results. Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Ic6c3e12429a5dcb271f8136a9edac70807d66120 Reviewed-on: https://chromium-review.googlesource.com/219647 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: allow dump_fmap to specify where to extract areaBill Richardson2014-09-253-7/+51
| | | | | | | | | | | | | | | | | | | Previously, you could extract FMAP areas like so: futility dump_fmap -x bios.bin FW_MAIN_A VBLOCK_A ... This lets you decide what to name each area as it's extracted: futility dump_fmap -x bios.bin FW_MAIN_A:/tmp/rw_a ../vblock BUG=none BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: If02b57e03294b0b0b1dbc216ef57afdd3bdf2960 Reviewed-on: https://chromium-review.googlesource.com/219646 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: clean up a few shared functionsBill Richardson2014-09-259-65/+61
| | | | | | | | | | | | | | | Move the Debug() function into a common place instead of several copies in different files, rename shared functions to start with "futil_" BUG=none BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: I6b844553dff95c24894dae611102716a8da5312d Reviewed-on: https://chromium-review.googlesource.com/219645 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: Fix potential null pointer dereferenceRandall Spangler2014-09-241-1/+2
| | | | | | | | | | | | | | | If key is null in vb2_verify_digest(), we could attempt to dereference it. In practice it never is, but for safety's sake we should avoid the reference. BUG=chrome-os-partner:32235 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I5a817e432922ea4c3b439b696cd2f8d988d0fecc Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219574 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* futility: Improve help messagesstabilize-6297.BBill Richardson2014-09-2420-424/+480
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This provides help messages for the futility commands similar to the way git does. These show the available commands: futility futility help futility --help While these show help for a specific command: futility help COMMAND futility --help COMMAND futility COMMAND --help BUG=none BRANCH=ToT TEST=manual make runtests And manually look at help messages for each command. Change-Id: I1126471e242784c6ca7a2f11694fa7c505d833e8 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219528 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Re-add dumpRSAPublicKey utilityDuncan Laurie2014-09-201-1/+1
| | | | | | | | | | | | | | This utility is used by firmware tests and having it missing is causing subtle FAFT test failures that are frustratingly difficult to track down. BUG=chrome-os-partner:38032 BRANCH=none TEST=successful run of firmware_UpdateKernelDataKeyVersion Change-Id: I4dcf277ce2678001f6e68d89781b6166042ea96e Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219079 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* cleanup: DESTDIR refers to the install root, not the bin/Bill Richardson2014-09-173-8/+8
| | | | | | | | | | | | | | | | | | | | | | | This doesn't have any visible effect. It just brings the meaning of the where-do-I-put-this variable more in line with common convention. BRANCH=ToT BUG=none CQ-DEPEND=CL:217940 TEST=lots... make runtests make DESTDIR=BAR install make MINIMAL=1 DESTDIR=FOO install emerge-$BOARD vboot_reference sudo emerge vboot_reference trybots: link-tot-paladin, daisy_spring-paladin Change-Id: I8d72664da07535f663d8b2f13c872eece37978b9 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/217930 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* cleanup: remove a couple of unused functions and filesfactory-storm-6269.BBill Richardson2014-09-126-1002/+80
| | | | | | | | | | | | | | | | | | | | | | | | | scripts/sign_data.sh is just a wrapper to do this: ./signature_digest_utility $1 $3 \ | openssl rsautl -sign -pkcs -inkey $2 AFAICT, that script is only invoked by the SignatureFile() function in host/lib/file_keys.c, which is not referenced by anything. I think I can remove both of those things. Also remove utility/gbb_utility.cc, which should have been done long ago in commit 6f39615. BUG=none BRANCH=ToT TEST=make runalltests Also ran it on daisy_spring-paladin and link-tot-paladin. Change-Id: I16de5022765806f11bf6144d7ffd8cc849578a68 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/216719 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* futility: stop using the symlink names in utility scriptsBill Richardson2014-09-1213-65/+76
| | | | | | | | | | | | | | | | | | | | | | We still create the symlinks (FOO -> futility), but this change invokes those built-in functions with "futility FOO ..." instead of using the FOO symlink. Note that the scripts/ directory is unchanged. That's a separate CL, since we don't have tests for that. BUG=chromium:231547 BRANCH=ToT TEST=make runtests In addition to running "make runtests", I temporarily modified the Makefile to avoid creating the symlinks at all. The tests still passed. Change-Id: I96863259b9df02a3611f759a7509bf4090ae03e8 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/216717 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: make resign_firmwarefd.sh simply invoke futilityBill Richardson2014-09-124-213/+34
| | | | | | | | | | | | | | | | | | | | | Since all of the functionality of the resign_firmwarefd.sh script is built in to futility, let's just make that script invoke futility to do the work. We'll come back and remove the script entirely, once all outside references to it have been changed to do the right thing. BUG=chromium:224734 BRANCH=ToT TEST=make runtests Also tested by editing tests/futility/test_resign_firmware.sh to invoke the resign_firmwarefd.sh script instead of futility. Everything passed. Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Id068e551067a956cd7ddc3f9b9e23488261d8d94 Reviewed-on: https://chromium-review.googlesource.com/216716 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: slight tweak to the logging implementationBill Richardson2014-09-122-25/+61
| | | | | | | | | | | | | | | Just reporting that the parent process is "/bin/bash" doesn't help much. Let's also report the cmdline args given to the parent and the cwd. This will help us identify which shell script is calling futility with the wrong args. BUG=chromium:231547 BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: I800995ff269ab8d8c56cad8827d8de48a53cd150 Reviewed-on: https://chromium-review.googlesource.com/216715
* futility: preserve preamble flags when resigning BIOS imagesBill Richardson2014-09-123-13/+54
| | | | | | | | | | | | | | | | | | If we're re-signing a valid BIOS image, we want to be sure that we preserve the original firmware preamble flags (RO_NORMAL and so forth) if the --flags option does not specifically override it. This change adds a test for that case, and makes it happen. BUG=chromium:224734 BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: I8cbde66abaf96ec82adf0205bedf57b1fd1b82a1 Reviewed-on: https://chromium-review.googlesource.com/216714 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: Wipe GBB data before writing new values.Hung-Te Lin2014-09-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | The previous version of gbb_utility always zeros data before writing new values and we should keep this behavior, to simplify firmware hash calculation and potential security concern. BRANCH=none BUG=chromium:413066 TEST=emerge gbb_utility; factory/bin/gooftool get_firmware_hash bios.bin Original-Change-Id: Ic97a118cefc9698d52d9370b627670ff103d5e23 Change-Id: If38e15f35ee491cc80f96b360c63ee25f71c1854 Reviewed-on: https://chromium-review.googlesource.com/217700 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> (cherry picked from commit 3c8d29c204c6feb91ad951e2e1c5190d4ca98a13) Reviewed-on: https://chromium-review.googlesource.com/217711 Commit-Queue: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Remove unused include path.Alex Deymo2014-09-051-2/+0
| | | | | | | | | | | | | | | | This path doesn't exists in the repo so this patch removes it from the Makefile: firmware/arch/${FIRMWARE_ARCH}/include BUG=None BRANCH=None TEST=./emerge_test Change-Id: I8b5461ee0ddfa0aa8d31bc6d2b981912a9ccde58 Reviewed-on: https://chromium-review.googlesource.com/214392 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Alex Deymo <deymo@chromium.org> Tested-by: Alex Deymo <deymo@chromium.org>
* futility: sign command works on unsigned imagesBill Richardson2014-09-053-4/+58
| | | | | | | | | | | | | | | | | | | This allows the sign command to work on BIOS images with invalid VBLOCK areas. When re-signing an existing image, the length of the firmware body is part of the firmware preamble in the VBLOCK areas. If those are invalid, the BIOS can still be signed, but it will have to sign the entire FW_MAIN area. That's a little slower to verify, so we'd prefer not to do that, but it works. BUG=chromium:224734 BRANCH=ToT TEST=make runtests Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: If58b5c86c5df12f004eabff72c22bfb1e84de7fd Reviewed-on: https://chromium-review.googlesource.com/216229 Reviewed-by: Randall Spangler <rspangler@chromium.org>