summaryrefslogtreecommitdiff
path: root/firmware/2lib
Commit message (Collapse)AuthorAgeFilesLines
...
* 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-244-25/+424
| | | | | | | | | | | | | | | | | 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-231-1/+1
| | | | | | | | | | | | | | | | 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-226-37/+61
| | | | | | | | | | | | | | 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-211-2/+9
| | | | | | | | | | | | | | | | | | | 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
* vboot2: move vb2_safe_memcmp() from rsa to commonRandall Spangler2014-10-183-32/+34
| | | | | | | | | | | | | | 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>
* 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>
* vboot2: Add previously tried slot and result to NV storageRandall Spangler2014-10-043-3/+35
| | | | | | | | | | | | | | | | | | | | 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>
* vboot2: Fix saving the slot we tried back to nv storageRandall Spangler2014-10-041-0/+3
| | | | | | | | | | | | | | | | | 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>
* 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>
* Add GBB flag to disable PD software syncstabilize-6146.Brelease-R38-6158.BDuncan Laurie2014-08-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | In order to disable PD software sync but still do EC software sync it is useful to have a separate GBB flag for it. This will allow me to release a Samus P2B firmware image that will update the EC but not the PD, since the PD FW that comes on P2B devices cannot be updated with software sync. BUG=chrome-os-partner:30079 BRANCH=None TEST=flash BIOS with updated EC+PD: 1) no GBB flags to override behavior updates both EC and PD 2) GBB flag to disable EC software sync disables both EC and PD update 3) GBB flag to disable PD software sync disables only PD update Change-Id: I49ffb59238bee4a2dd66b24f2516e3ce46ea06cd Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211910 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add nvstorage / crossystem support for new vboot2 fieldsRandall Spangler2014-06-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows testing vboot2. These fields are ignored by original vboot firmware. BUG=chromium:370082 BRANCH=none TEST=manual crossystem -> fw_tried=A, fw_result=unknown, fw_try_next=A crossystem fw_tried=B echo $? -> 1 crossystem -> fw_tried=A, fw_result=unknown, fw_try_next=A crossystem fw_try_next=B crossystem -> fw_tried=A, fw_result=unknown, fw_try_next=B crossystem fw_try_next=beats_me echo $? -> 1 crossystem -> fw_tried=A, fw_result=unknown, fw_try_next=B crossystem fw_try_next=A crossystem -> fw_tried=A, fw_result=unknown, fw_try_next=A crossystem fw_result=trying crossystem -> fw_tried=A, fw_result=trying, fw_try_next=A crossystem fw_result=bupkis echo $? -> 1 crossystem -> fw_tried=A, fw_result=trying, fw_try_next=A crossystem fw_result=success crossystem -> fw_tried=A, fw_result=success, fw_try_next=A crossystem fw_result=failure crossystem -> fw_tried=A, fw_result=failure, fw_try_next=A crossystem fw_result=unknown crossystem -> fw_tried=A, fw_result=unknown, fw_try_next=A crossystem -> fw_try_count = 0, fwb_tries = 0 crossystem fw_try_count=6 crossystem -> fw_try_count = 6, fwb_tries = 6 crossystem fwb_tries=0 crossystem -> fw_try_count = 0, fwb_tries = 0 Change-Id: I1532f3384f8c05de2a7ff3f35abcc35d18049491 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205475
* vboot2: fix overloaded NV bitRandall Spangler2014-06-252-4/+14
| | | | | | | | | | | | | | Bill and I both added meanings for byte 1 bit 0x10. His changed (NV_BOOT_BACKUP_NVRAM) landed first, so move the vboot2 bit to byte 2. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 make runtests Change-Id: Ib7ff8da47d03f91cbeb729ca517c6315dfb4e6ac Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205408 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Scramble the GBB magic numberDaisuke Nojiri2014-06-253-5/+28
| | | | | | | | | | | | | | | | Compiling in the GBB magic number as is causes any tools that search for the number to fail. This patch allows firmware to embed XOR'ed signature. TEST=Booted Nyan in normal mode. FAFT:firmware_DevMode passes. BUG=none BRANCH=none Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Id18905a9969af3db24151e7c51332d0e94405108 Reviewed-on: https://chromium-review.googlesource.com/205416 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: More specific errors for unimplemented external APIsRandall Spangler2014-06-242-2/+8
| | | | | | | | | | | | | | | When porting vboot2 to a platform, it's common to copy 2stub.c and then start implementing APIs. Adding explicit errors makes it clearer when an unimplemented API is called. BUG=chromium:370082 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I1f412b7ed4b431dbdbdee5e33b27bf7206186918 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/204960 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: Allow platform dependent debug loggingDaisuke Nojiri2014-06-232-5/+10
| | | | | | | | | | | | | TEST=Built with VBOOT_DEBUG on/off. Booted Nyan Blaze. Verified debut output. BUG=None BRANCH=none Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Id189231f16ca8719dfff0ef3c9a8d4982b741d5f Reviewed-on: https://chromium-review.googlesource.com/205157 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: Check necessity of recovery when firmware body hash fails to matchDaisuke Nojiri2014-06-232-0/+4
| | | | | | | | | | | | | TEST=Booted Nyan Blaze and verified recovery is requested. BUG=None BRANCH=none Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I076e9714de4b853973cadad9a02a35d28431790c Reviewed-on: https://chromium-review.googlesource.com/205156 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot2: api-level routinesRandall Spangler2014-06-193-7/+491
| | | | | | | | | | | | | | I'm breaking the last chunk of vboot2 into smaller pieces as I add tests. This has the api-level routines actually called by depthcharge. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: Ic7c082fc5faa0b874b2fa5a15ebda7135dcafe0b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200151 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: misc higher-level routines, part 2Randall Spangler2014-06-192-0/+233
| | | | | | | | | | | | | | | I'm breaking the last chunk of vboot2 into smaller pieces as I add tests. This has the higher-level routines for verifying keyblock and preamble. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: I82da9542c8857a3f89a85f206c9f5aecadf94a79 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203501 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: misc higher-level routinesRandall Spangler2014-06-195-30/+548
| | | | | | | | | | | | | | | I'm breaking the last chunk of vboot2 into smaller pieces as I add tests. This has a bunch of misc routines like the dev switch logic and GBB header parsing. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: I0f67400d9b59ec21ed5cc155a9b774fd37eb559b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203374 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Use more specific error codes, part 3Randall Spangler2014-06-113-31/+139
| | | | | | | | | | | | | | Error codes reported by 2common.c are now very specific, and tests verify the proper errors are reported. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: I9480bd22b60ae339196c92918a8a984a9f05ac1a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202938 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: Use more specific error codes, part 2Randall Spangler2014-06-113-18/+43
| | | | | | | | | | | | | | | | Error codes reported by the aligment checks in common.c are now very specific, and tests verify the proper errors are reported. Changed args to vb2_member_inside() so I can force wraparounds. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: Ib135674e82005b76bce7a83a1f4a65a9c5296cf4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202937 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot2: Use more specific error codesstabilize-5944.Bstabilize-5943.Bstabilize-5942.Bfactory-samus-5939.BRandall Spangler2014-06-075-22/+112
| | | | | | | | | | | | | | | | | | | | | Error codes reported by the crypto and storage APIs are now very specific, and tests verify the proper errors are reported. More specific error codes coming to other files next, but I don't want this CL to get too long. This also changes test_common.c so TEST_EQ() reports mismatched values in both decimal and hex, and adds TEST_SUCC() to test for a successful return value. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: I255c8e5769284fbc286b9d94631b19677a71cdd0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202778 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Add common functionsRandall Spangler2014-06-052-0/+450
| | | | | | | | | | | | | | This is the third of several CLs adding a more memory- and code-efficient firmware verification library. BUG=chromium:370082 BRANCH=none TEST=make clean && COV=1 make Change-Id: I3a5daa5438afc5598d3dfcf5a597ffb16eda8749 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200140 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Add nvstorage and secdata functionsRandall Spangler2014-06-0512-1/+1548
| | | | | | | | | | | | | | This is the second of several CLs adding a more memory- and code-efficient firmware verification library. BUG=chromium:370082 BRANCH=none TEST=make clean && COV=1 make Change-Id: I1dd571e7511bff18469707d5a2e90068e68e0d6f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/199841 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Add crypto functionsRandall Spangler2014-06-057-0/+1686
| | | | | | | | | | | | | | | This is the first of several CLs adding a more memory- and code-efficient firmware verification library. This CL adds the crypto library (modified from firmware/lib/cryptolib) and unit tests for it. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: I4240eab227bb197cacc6c8e7a6397127d74414a2 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/199578 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* vboot2: Add workbuf functionsRandall Spangler2014-06-034-0/+304
We'll try breaking this up into smaller pieces. This one's pretty small - just the work buffer utility functions. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: I4c417438053c155d6f7f9725552066e9b059951c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201141