summaryrefslogtreecommitdiff
path: root/host
Commit message (Collapse)AuthorAgeFilesLines
* vboot: update vboot2 functions to use new vb2_error_tJoel Kitching2019-08-1321-177/+162
| | | | | | | | | | | | | | | | | | To make explicit when vboot2 error codes should be returned, use the new vb2_error_t type on all functions which return VB2_ERROR_* constants. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Idd3ee8afe8c78347783ce5fa829cb78f1e5719e2 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1728113, chromium:1728499 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1728292 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* vboot: deprecate VbExError functionJoel Kitching2019-07-241-3/+3
| | | | | | | | | | | | | | | | Convert uses of this function to call VB2_DEBUG and manually exit if necessary. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I9006b1a9c66645757d33310d96207233b88eaed5 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1710340 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: remove vboot1 version of ARRAY_SIZE macroJoel Kitching2019-06-261-1/+1
| | | | | | | | | | | | | | | | Macro already exists in vboot2-style 2common.h. Relocate tests accordingly. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I6b96627a05e8c05ff49b8780fe4472890c2a2043 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675869 Reviewed-by: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: move vb2_packed_key and several functions from lib20 to 2libJoel Kitching2019-06-071-0/+2
| | | | | | | | | | | | | | | | | | | * Move vb2_packed_key from vb2_struct.h to 2struct.h * Move vb2_verify_member_inside from lib20/common.c to 2common.c * Move vb2_packed_key_data and vb2_verify_packed_key_inside from lib20/packed_key.c to 2packed_key.c * Relocate tests accordingly BUG=b:124141368, chromium:968464 TEST=make clean && make runtests BRANCH=none Change-Id: I6a9338ffdb640aad071941c3768427e15cd2aa93 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1642773 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot: update display init to use vboot2 codeJoel Kitching2019-05-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per go/vboot2-oprom-cleanup, use vboot2 SD flag DISPLAY_AVAILABLE, instead of the old vboot1 flags OPROM_MATTERS and OPROM_LOADED. Remove instances of "OPROM" and update with correct nomenclature. Update code and tests for EC software sync and diagnostic menu to use vboot2 display init model. OPROM_MATTERS and OPROM_LOADED are now deprecated, and will be removed when no references remain in depthcharge and coreboot. Deprecate VBERROR_DISPLAY_INIT_MISMATCH (previously OPROM_MISMATCH) and return VBERROR_REBOOT_REQUIRED directly when needed. BUG=b:124141368, b:124192753, chromium:948529 TEST=Build image for eve, force EC update, check that the "critical update" screen shows TEST=make clean && make runtests BRANCH=none Change-Id: I889872f886230f8559d5cce09d0de194da3fcc38 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1605641 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: deprecate Alt OS codeJoel Kitching2019-05-141-13/+0
| | | | | | | | | | | | | | BUG=b:124141368, b:131663912 TEST=make clean && make runtests BRANCH=none Change-Id: I6aae5683b8306eede4388ff5ed6665e7769756dc Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1588026 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* Makefile: Enable more warnings for host utilities / testsJulius Werner2019-05-144-22/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a bunch of more warnings that are already enabled in coreboot and thus already enabled for firmware builds anyway (because coreboot just passes its CFLAGS through). Enabling it in the vboot Makefile means they also apply to host utilities and tests, which sounds desirable for consistency. Fix enough of the cruft and bad coding practices that accumulated over the years of not having warnings enabled to get it to build again (this includes making functions static, removing dead code, cleaning up prototypes, etc.). Also remove -fno-strict-aliasing from the x86 firmware build options, because it's not clear why it's there (coreboot isn't doing this, so presumably it's not needed). BRANCH=None BUG=None TEST=make runtests Change-Id: Ie4a42083c4770a4eca133b22725be9ba85b24184 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1598721 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
* vboot: deprecate GPIO_SIGNAL_TYPE_DEVJoel Kitching2019-03-281-1/+1
| | | | | | | | | | | | | | | | | As part of chromium:942901, physical dev switch functionality is being deprecated. BUG=chromiumos:942901 TEST=make clean && make runtests BRANCH=none Change-Id: I84d35a3eade6272896e7f9c3c43e87bba090f132 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1539435 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: do not check for VBSD_HONOR_VIRT_DEV_SWITCHJoel Kitching2019-03-262-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of chromium:942901, physical dev switch functionality is being deprecated. As such, we no longer need to specify the flag VBSD_HONOR_VIRT_DEV_SWITCH -- the virtual dev switch should always be honoured. Additionally, there is no longer a need to check this flag when looking up the value for crossystem devsw_cur. This constant will be marked as deprecated in a subsequent CL. BUG=b:124141368, b:124192753, chromium:942901 TEST=Build locally TEST=/work/vboot/src/repohooks/pre-upload.py TEST=make clean && make runtests TEST=make clean && COV=1 make coverage && make coverage_html BRANCH=none Change-Id: Ib1ab86d79b039650136f1038c23175f5990895db Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1526070 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot/crossystem: deprecate devsw_virtualJoel Kitching2019-03-261-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | As part of chromium:942901, physical dev switch functionality is being deprecated. There is no longer any need to provide devsw_virtual flag in crossystem. BUG=b:124141368, b:124192753, chromium:942901 TEST=Build locally TEST=/work/vboot/src/repohooks/pre-upload.py TEST=make clean && make runtests TEST=make clean && COV=1 make coverage && make coverage_html TEST=Check for references to devsw_virtual in code search BRANCH=none Change-Id: Id80ec1de8c43909ce2ff661744622d2ea36030a6 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1526069 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: allocate nvram bit for diagnostic modeMatt Delco2019-03-201-0/+4
| | | | | | | | | | | | | | | | This change allocates a bit in the nvram that will be used in a later change to tell the firmware whether to detour to diagnostic mode during boot. BUG=b:124358784 BRANCH=None TEST=Local build and ran "make runtests". Verified with a later change that the nvram bit takes effect as expected. Change-Id: If2fd3f46da30fc7375d37b240e3e745819ae0632 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1504758 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: move general constants to a separate headerJoel Kitching2019-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | coreboot uses the C preprocessor on its linker scripts to allow evaluation of macros when defining memory layout. Move constants from 2api.h to an independent file in order to allow for coreboot to use these constants in its memlayout file, without needing to include the entire vboot API. Note this commit creates two new header files: - firmware/2lib/include/2constants.h: contains the constants - firmware/include/vb2_constants.h: externally importable header Also, rename VB2_WORKBUF_RECOMMENDED_SIZE to VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE for clarity. BUG=b:124141368, b:124192753 TEST=Build locally TEST=/work/vboot/src/repohooks/pre-upload.py TEST=make clean && make runtests TEST=make clean && COV=1 make coverage && make coverage_html BRANCH=none Change-Id: Id17c6955b67e51cb048b10b4be0901c0e9110a1f Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1504490 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* futility: updater: Preserve all sections with FMAP_AREA_PRESERVE setHung-Te Lin2019-03-051-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many projects started their initial builds without knowing that some sections must be preserved when being updated. This may be solved by adding section name to 'preserved' list in firmware updater (for instance, CL:1239797), or include that section as sub area of {RO,RW}_PRESERVE. However, there are problems in both solutions. For example, installing an older image will run old updater, which will not preserve the new names. Also, if there are multiple sections must be preserved (and not contiguous - see CL:1493629) there will be problems. Additionally, changing FMAP layout usually causes more problems. As a result, adding the description in FMAP area would be the better idea. A new FMAP_AREA_PRESERVE suggests firmware updater to preserve a section if possible. In Coreboot, this can be easily set in *.fmd using flag (PRESERVE). See https://review.coreboot.org/31709 for example. BUG=chromium:936768 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ie56f65dd418faa97ffb78b1acff613e7d7e268b8 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1495054 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot_reference: add const to char* params in cgptFletcher Woodruff2019-02-121-14/+15
| | | | | | | | | | | | | | | | | | | | cgpt's C/C++ bindings use non-const char* parameters leading to compiler errors if a user attempts to pass a const char* parameter rather than creating an unnecessary mutable copy. Since the code doesn't need to modify the parameters, change them to const char* to make the library easier to use. BUG=none TEST=builds and test cgpt cli tool on-device. CQ-DEPEND=CL:1460081 BRANCH=none Change-Id: I6552db159e3dc4d9d07bb889a3f1e4e890b33cb0 Reviewed-on: https://chromium-review.googlesource.com/1459848 Commit-Ready: Fletcher Woodruff <fletcherw@chromium.org> Tested-by: Fletcher Woodruff <fletcherw@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: support recoverysw_cur with new gpiod APIBrian Norris2019-02-041-1/+7
| | | | | | | | | | | | | | | | | | We've dropped the chromeos_arm driver on recent kernels. Now, if you name the GPIO as RECOVERY_SW_L (e.g., in the Device Tree), crossystem can pick it up directly. BRANCH=none BUG=chromium:897992, b:116761006 TEST=crossystem recoverysw_cur on ARM with 4.14+ (without chromeos_arm driver) Change-Id: I20fb1aa310268a60070bd6c8914c4d58e5760cf8 Reviewed-on: https://chromium-review.googlesource.com/1448395 Commit-Ready: Brian Norris <briannorris@chromium.org> Tested-by: SANTHOSH JANARDHANA HASSAN <sahassan@google.com> Tested-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
* cgpt: add -D support to CgptEditstabilize-11686.BMatt Delco2019-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The lack of -D support in CgptEdit introduced a test failure. This change adds support for -D. BRANCH=none BUG=chromium:605348 TEST=Verified that prior to this change the tests failed: cros_workon --host start vboot_reference sudo FEATURES=test emerge vboot_reference The tests fail in a different area prior to CgptEdit, so I applied the following temporary change to Makefile to see the relevant failure: ifeq (${MINIMAL},) # Bitmap utility isn't compiled for minimal variant - test_targets:: runbmptests runfutiltests + test_targets:: runbmptests # runfutiltests # Scripts don't work under qemu testing With this change the tests pass. Change-Id: Ia2127a3537c72e4ea6daf59c5c33b8701a89b0f6 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1436496 Tested-by: Matt Delco <delco@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* cgpt: enable calling CgptEditMatt Delco2018-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | This change allows CgptEdit to be called via the API. Prior to this change link fails in an app that uses CgptEdit due to undefined reference. The underlying implementation wasn't checking set_unique so I've fixed that as well. BRANCH=none BUG=None TEST=Added CgptEdit(0) call to extern.c and verified that build failed. Added cgpt_edit.c to Makefile and confirmed that build is now successful. Successfully ran unit tests on both vboot_reference and the app I'm working on that calls CgptEdit (which also has a unit test for setting the drive ID). Change-Id: Ie0a46ff96406eb83d0564d3f1eac978e0565ed76 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1361948 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: add alt_os_enabled to show Alt OS stateJoel Kitching2018-11-191-0/+5
| | | | | | | | | | | | | | | | | | | | | Some user-space applications need to know whether Alt OS is currently enabled or disabled. Add alt_os_enabled to crossystem as a read-only flag for this purpose. It is currently based off of reading VBSD_ALT_OS_SHOW_PICKER from VbSharedDataHeader. We may want to change that to a field dedicated to showing Alt OS state in the future (see b/117195332). BUG=b:117195332,b:117142023 TEST=emerge-eve vboot_reference && \ cros deploy --force --board=eve dut vboot_reference Change-Id: Ic9a120e7d24021eb984d501f09ce4d7b6f85d730 Reviewed-on: https://chromium-review.googlesource.com/1328390 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* CHERRY-PICK: vboot: create NVRAM flag to pause after EC software syncJoel Kitching2018-11-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, it is impossible to programmatically enable/disable Alt OS mode in eve. This is because only EC-RW supports the kbatboot keyboard matrix functionality. But, as part of the campfire boot flow, the keyboard matrix is retrieved *immediately* after jumping into EC-RW. We need to insert a small pause in order to allow for some entity (autotest/servo) to send a kbatboot command, simulating the Alt OS keyboard press hotkey. BUG=b:117140648,b:118786884 TEST=Manually use crossystem to set post_ec_sync_delay=1 Reboot, and wait for the delay to begin Run `kbatboot 1 4 1` in EC console Check that AP console contains: "vb2_post_ec_sync_hooks: post_ec_sync_delay 5000 ms..." TEST=make clean && make runtests Note that we are only cherry-picking the changes which affect crossystem in this CL. Firmware changes will still live in campfire-eve branch only. Change-Id: I1305357199d87b80b4edc4e311015106ab07de65 Reviewed-on: https://chromium-review.googlesource.com/c/1256644 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Trybot-Ready: Joel Kitching <kitching@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 64d7369976b88b21d8d8a860252023776a2f119e) Reviewed-on: https://chromium-review.googlesource.com/1328389 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: add support for ICL gpiochipSubrata Banik2018-10-311-0/+1
| | | | | | | | | | | | | | On Icelake platform, the pinctrl (gpiochip) driver label is "INT3455:00", hence declare it properly. TEST=run 'crossystem wpsw_cur' and see '0' rather than an error on dragonegg platform. Change-Id: I34e24478934a8fbaf9777a8340672697f7642ba3 Signed-off-by: Subrata Banik <subrata.banik@intel.com> Reviewed-on: https://chromium-review.googlesource.com/1307200 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* crossystem: replace 'chromeos_arm' device with new GPIO chardev APIBrian Norris2018-10-261-3/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream Linux supports a new ioctl API for GPIO chips, via new /dev/gpiochip* device nodes. This new API supports name lookups, which is a much nicer way than the index-based stuff in /sys/class/gpio/. We can finally use this instead of our custom, downstream "chromeos_arm" driver. GPIO line names are defined in a 'gpio-line-names' property in the Device Tree. For now, we have exactly one board using this, and we're calling it 'AP_FLASH_WP_L'. We will need to ensure future devices use this same naming. Per others' suggestions, I'm avoiding using libgpiod, because it's a relatively new library (with breaking changes in v1.0 as recently as this year), and vboot_reference is used by plenty of other projects. And it wasn't that hard to hand-roll the ioctls. Side note: the chromeos_arm device is not guaranteed to be found at /sys/devices/platform/chromeos_arm any more (especially on kernel >=4.14), so this is a handy excuse to just kill use of the driver entirely. BRANCH=none BUG=chromium:897992 TEST=`crossystem wpsw_cur` on 4.14 kernels (with this API) and older kernels (without this API) Change-Id: I7553801fb0e97c8a0aa6f4341d297ad0071c3dac Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1298274 Reviewed-by: Douglas Anderson <dianders@chromium.org>
* add extern C markers to installed headersMike Frysinger2018-09-043-0/+24
| | | | | | | | | | | | | | | Some of the headers have extern C markings already, so add to the rest of the installed files so users don't have to. BUG=chromium:878440 TEST=build passes BRANCH=none Change-Id: I3edf56ca2235269803049207806a9f7eb4c664f2 Reviewed-on: https://chromium-review.googlesource.com/1201042 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cgpt: add edit commandstabilize-nocturne-10986.Bstabilize-11021.84.Bstabilize-11020.Bstabilize-11005.Bstabilize-10985.Brelease-R70-11021.Bfirmware-servo-11011.Bfirmware-nocturne-10984.Bfactory-nocturne-10984.BMatt Delco2018-08-152-0/+7
| | | | | | | | | | | | | | | | This change adds a command to cgpt to change the GUID of the drive. BRANCH=none BUG=None TEST=Compiled and ran utility to verify that GUID changes. Also verified that the new and existing tests completed successfully. Change-Id: Ia8a815447509626312e2b06c6f293901290c73c3 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1171834 Reviewed-by: Julius Werner <jwerner@chromium.org>
* Add AltOS NVRAM flagsTing Shen2018-08-071-0/+8
| | | | | | | | | | | | | | | | Port CL:1009444 to ToT. Adds (enable|disable)_alt_os_request flag for AltOS boot flow. BRANCH=none BUG=b:70804764 TEST=1. make runtests 2. Manually, set and get new flags via crossystem Change-Id: Ie7fe2620f736335f11c39cbfe37b3fdf400ff926 Reviewed-on: https://chromium-review.googlesource.com/1014840 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: bulk fix tabs and spacing inconsistencyJoel Kitching2018-08-039-38/+37
| | | | | | | | | | | | | | | | | | | Problem files were found with: find . -name '*.c' -o -name '*.h' | xargs grep '^ [^*]' and edited manually. Ignores utility/ and cgpt/, since they seem to globally adhere to a two-space tab convention. BUG=None TEST=make clean runtests TEST=emerge vboot_reference depthcharge Change-Id: I5a678484a119c8f1911f717e1968bdb4f1a0810f Reviewed-on: https://chromium-review.googlesource.com/1160131 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot_reference: Add recoverysw_is_virtual flag to crossystemTudor Brindus2018-08-021-0/+7
| | | | | | | | | | | | | | | | | | This commit adds a flag recoverysw_is_virtual for determining whether a device's recovery switch status (as given by recoverysw_cur) is from a physical button or a line connected to Servo, without a physical button (e.g. veyron_minnie). BRANCH=none BUG=chromium:845589 TEST=manually tested on cave and veyron_minnie; make runtests Change-Id: If8e54e1df78b25a52dbf359ce641bea75533d705 Reviewed-on: https://chromium-review.googlesource.com/1157537 Commit-Ready: Tudor Brindus <tbrindus@chromium.org> Tested-by: Tudor Brindus <tbrindus@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: Add BINF3_LEGACY for systems boot in legacy mode.Hung-Te Lin2018-05-232-0/+3
| | | | | | | | | | | | | | | | | | | | | The BINF3 (VBT7) reflects the firmware type, and we need that to describe which type of firmware was booted. The 'legacy' did not have its own value definition, but without that we can't make sure if the system is running a non-chrome firmware or simply entered legacy boot path. CL:1054307 introduced a new value (0x4) for legacy type and we should handle it in crossystem mainfw_type command. BUG=b:79130310 TEST=emerge-eve coreboot depthcharge chromeos-bootimage; Boot in legacy mode and see crossystem reporting 'legacy' for mainfw_type. Change-Id: I4a1165e547e70c634d45054f56d1357ae5af2a83 Reviewed-on: https://chromium-review.googlesource.com/1068556 Commit-Ready: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add new NV and GBB flag to control UDCDuncan Laurie2018-04-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | This change adds a new NV and GBB flag for controlling USB device mode behavior, adding an additional step to enable UDC on systems that support it. Users of this feature will need to first enable developer mode and then enable UDC separately by running "crossystem dev_enable_udc=1". Alternatively those without write protect enabled can set a GBB flag to have UDC enabled by default while in developer mode. This is based on the security reviewed proposal at https://docs.google.com/document/d/1b6avd9xvhvljN_NKtctWrClj4mSYZ_uPmp7MmAnPwqs BUG=b:74339386 BRANCH=poppy TEST=manual testing on Eve device Change-Id: I6f440320f28b033639b53246d3034bc8acc37a33 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/1010769 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* crossytem:Add GLK GPIO IDShaunak Saha2018-04-161-0/+5
| | | | | | | | | | | | BUG=b:78009842 Change-Id: I50de5d69309a25411c907425675eace330de7615 Signed-off-by: Shaunak Saha <shaunak.saha@intel.com> Signed-off-by: Hannah Williams <hannah.williams@intel.com> Reviewed-on: https://chromium-review.googlesource.com/742490 Commit-Ready: Aaron Durbin <adurbin@chromium.org> Tested-by: Hannah Williams <hannah.williams@intel.corp-partner.google.com> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* crossystem: Fix mosys data length checkRandall Spangler2018-03-111-2/+2
| | | | | | | | | | | | | | | CL:942031 introduced a check for the length of output returned by mosys. If the output has a trailing newline, then the check failed. Just make sure we get at least as much data as we expect. BUG=b:74439800 BRANCH=none TEST=run crossystem on bob; no 'mosys returned hex data' errors Change-Id: If678b201185dbda869e4e17abae314470f5cef4a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/958286 Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
* crossystem: Fix null pointer dereference on VMsRandall Spangler2018-03-081-2/+2
| | | | | | | | | | | | | | | Check the result of VbSharedDataRead() before dereferencing it. BUG=chromium:789276,chromium:819695 BRANCH=none TEST=make runtests Change-Id: I1b1cc90bdc2fca61a9aad6b02e8b7e1f6a919797 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/954712 Commit-Ready: Keith Haddow <haddowk@chromium.org> Reviewed-by: Keith Haddow <haddowk@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* crossystem: add support for CNL gpiochipVincent Palatin2018-03-071-0/+1
| | | | | | | | | | | | | | | | | On CNL systems, the pinctrl (gpiochip) driver label is "INT34BB:00". Declare it properly. BRANCH=none BUG=b:71722386 TEST=on Meowth, run 'crossystem wpsw_cur' and see '0' rather than an error. Change-Id: I74f3cce19afac9a76e8d3071426e79eb9bb11db9 Reviewed-on: https://chromium-review.googlesource.com/951789 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org>
* 2lib: Add support for 64-byte nvstorage recordRandall Spangler2018-03-073-10/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The calling firmware can set ctx->flags VB2_CONTEXT_NVDATA_V2 to tell vboot that nvdata is a 64-byte record instead of a 16-byte record, or equivalently, set the VBSD_NVDATA_V2 flag if calling the old vboot1 API. If calling firmware does not (which is the current coreboot and depthcharge default), then the 16-byte record is used, and V2 fields return explicit default values. Added the fw_max_rollforward V2 field, which defaults to 0xfffffffe on V1. This will be used by a subsequent CL. Added unit tests to verify all that. Added crossystem support, though it will only work with the current 16-byte records until firmware sets the VBSD flag and mosys supports larger records. (Note that because coreboot/depthcharge do not yet set the new context flag, this CL should not change ToT firmware behavior.) See go/vboot-nvstorage for design doc. BUG=chromium:789276 BRANCH=none TEST=make runtests Change-Id: I43072ef153dfa016c051f560892af1fbb3508e3a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/942031
* cgpt: add support for managing GPT platform required partition bitBen Chan2018-02-061-0/+2
| | | | | | | | | | | | | | | | Bit 0 in the GPT partition attributes is defined to indicate whether a partition is required by the platform. This CL adds the support for managing this bit to cgpt. BUG=b:70807006 BRANCH=None TEST=Run unit tests. Change-Id: Iaf87c828438b3df6730de502ae420fcf4c61277b Reviewed-on: https://chromium-review.googlesource.com/902196 Commit-Ready: Ben Chan <benchan@chromium.org> Tested-by: Ben Chan <benchan@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* vboot: Use 2nvstorage instead of vboot_nvstorageRandall Spangler2017-12-116-172/+163
| | | | | | | | | | | | | | | | | | Remove the old vboot1 vboot_nvstorage library (VbNv*() functions) and use the vboot2 library (vb2_nv_*()) instead. This is needed in preparation for moving to 64-byte records; no sense in implementing that change twice... Should be (better be) no change in system behavior. BUG=chromium:789276 BRANCH=none TEST=make runtests compare output of crossystem before/after change (should be identical) Change-Id: I10f9975b0824263064b9a74a3c6daadcecc085d3 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/794732
* nvstorage: Add kernel max rollforward NV storage fieldRandall Spangler2017-11-171-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This just adds the kernel_max_rollforward field to the nvstorage libraries and crossystem. The firmware does not use it yet; that's coming in a subsequent CL. 16 of the fields's 32 bits are taken from unused bytes of the kernel field. This has no effect on existing usage. BUG=chromium:783997 BRANCH=none TEST=make runtests Also manual testing. In a root shell: crossystem kernel_max_rollforward --> Should default to 0 crossystem kernel_max_rollforward=0xfffffffe crossystem kernel_max_rollforward --> Should be 0xfffffffe (Note that setting it to 0xffffffff is indistinguishable from the -1 value that the crossystem library uses to indicate error, so 0xffffffff isn't actually usable as a max rollforward limit. But 0xfffffffe is, and if we ever get so close to the limit that we need to use 0xffffffff, something has already gone horribly wrong with our versioning strategy...) Change-Id: I008f412e6ed3c0b59beb9881268585af69d1ff2e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/765572 Reviewed-by: Julius Werner <jwerner@chromium.org>
* crossystem: add support for AMD0030 gpiochipDaniel Kurtz2017-09-271-0/+1
| | | | | | | | | | | | | | | | | | | | | On AMD Stoney Ridge systems, the pinctrl (gpiochip) driver label is "AMD0030". Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> BUG=b:65597554 TEST=w/ coreboot patches: https://review.coreboot.org/#/c/21684/ https://review.coreboot.org/#/c/21614/ TEST=crossystem wpsw_cur => 0 BRANCH=None Change-Id: Iab0a1a28dd3e42d55cf3b18503e2df0de7b8ad11 Reviewed-on: https://chromium-review.googlesource.com/685945 Commit-Ready: Daniel Kurtz <djkurtz@chromium.org> Tested-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* tests: Add support for exponent 3 keysCaveh Jalali2017-08-242-0/+44
| | | | | | | | | | | | BRANCH=none BUG=b:64854892 TEST=make runlongtests Change-Id: I827ce47b68339dc4df7f84b26a0b6643af27037b Signed-off-by: Caveh Jalali <caveh@google.com> Reviewed-on: https://chromium-review.googlesource.com/628176 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org>
* crossystem: Remove defunct sw_wpsw_boot fieldstabilize-9765.7.Bstabilize-9765.39.BJulius Werner2017-07-181-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | The sw_wpsw_boot field only ever worked correctly on some platforms. It also isn't used anywhere in the codebase (only other reference is a comment about how it doesn't always work in factory_installer.sh), and it's no longer clear what it was meant for in the first place (b/35510092 hints at needing it for some planned feature that was never implemented). Let's get rid of it to avoid confusing people. If userspace tools need to know the software write-protect state, they can instead run flashrom directly. For feedback reports, this output is already included in the "verified boot" section. BRANCH=none BUG=chromium:508269,chromium:742685 TEST=none Change-Id: I8975b1e2c8e604b4cb48d092c13b923b4db2d207 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/575389 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Update for openssl 1.1Daniel Kurtz2017-07-073-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | OpenSSL 1.1 has made significant non-backwards compatible changes to its API as outlined in: https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes BRANCH=none BUG=chromium:738114 TEST=cros_workon --host start vboot_reference TEST=w/ openssl-1.0.2k: sudo emerge vboot_reference TEST=w/ openssl-1.1.0e: sudo emerge vboot_reference => both build ok $ futility version => command runs without error TEST=cros_workon --board=soraka start vboot_reference coreboot TEST=w/ openssl-1.0.2k: emerge-soraka vboot_reference coreboot TEST=w/ openssl-1.1.0e: emerge-soraka vboot_reference coreboot => All build ok Change-Id: I37cfc8cbb04a092eab7b0b3224f475b82609447c Reviewed-on: https://chromium-review.googlesource.com/557739 Commit-Ready: Daniel Kurtz <djkurtz@chromium.org> Tested-by: Daniel Kurtz <djkurtz@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* host lib: include <sys/types.h> for ssize_tstabilize-9693.BAlex Suykov2017-06-281-0/+1
| | | | | | | | | | | In uClibc neither <stdio.h> nor <strings.h> defines ssize_t. Change-Id: I7fb6a0f51eae76062784952beb42298c486461b5 Signed-off-by: Alex Suykov <alex.suykov@gmail.com> Reviewed-on: https://chromium-review.googlesource.com/320472 Commit-Ready: Stefan Reinauer <reinauer@google.com> Tested-by: Stefan Reinauer <reinauer@google.com> Reviewed-by: Stefan Reinauer <reinauer@google.com>
* vboot_reference: Add support for 3072-bit exponent 3 keysNicolas Boichat2017-03-161-0/+3
| | | | | | | | | | | | | | | | This also adds the required tests (keys, testcases), and some additional tests in vb2_rsa_utility_tests.c that were not added when 2048-bit exponent 3 support was added. BRANCH=none BUG=chromium:684354 TEST=make runtests Change-Id: I56d22302c2254ef500b9d2d290a79d8c8bc39942 Reviewed-on: https://chromium-review.googlesource.com/449060 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* host_keyblock: Fix vb2_create_keyblock_externalNicolas Boichat2017-03-161-1/+2
| | | | | | | | | | | | | | | | 939cc3a "futility: Use only vboot 2.0 APIs for keyblocks" introduced 2 subtle bugs, and we could still pass unit tests. Until we start adding more signing algorithms and sig_data_size != 0. BUG=chromium:611535 BRANCH=none TEST=make runtests Change-Id: Ief95e5ab773185b59276cf06d1efaa29f1212466 Reviewed-on: https://chromium-review.googlesource.com/448399 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot_reference: Add support for 2048-bit exponent 3 keysstabilize-9313.Bfirmware-cr50-release-9308.25.Bfirmware-cr50-mp-release-9308.87.Bfirmware-cr50-mp-r86-9311.70.Bfirmware-cr50-mp-9311.Bfirmware-cr50-guc-factory-9308.26.Bfirmware-cr50-9308.Bfirmware-cr50-9308.24.BNicolas Boichat2017-02-181-10/+24
| | | | | | | | | | | | | | This also adds the required tests (keys, testcases). BRANCH=none BUG=chromium:684354 TEST=make runtests Change-Id: I5e148f8792ea325f813d76089271f3c4bcc2935d Reviewed-on: https://chromium-review.googlesource.com/438951 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* host_key2: Add VB2_SIG_ALG_COUNT to count the number of valid signaturesNicolas Boichat2017-02-151-2/+4
| | | | | | | | | | | | | | | | More reliable than simply assuming that VB2_SIG_RSA8192 is the last signature. BRANCH=none BUG=chromium:684354 TEST=rm tests/testkeys/key_*; make genkeys -j TEST=make runtests -j Change-Id: I755b3afb50313fcdf292fb3cd5b0dfe09f8593e3 Reviewed-on: https://chromium-review.googlesource.com/438948 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* signature_digest/SignatureDigest: convert vb2_crypto to hash algorithmNicolas Boichat2017-02-111-6/+11
| | | | | | | | | | | | | | | | We were passing the wrong value to PrependDigestInfo. Let's also refactor the function a little bit. BRANCH=none BUG=chromium:689371 TEST=make gentestcases; git status => no change Change-Id: I0244c3f3de05b33b7ddd21e93a266faf34f2c239 Reviewed-on: https://chromium-review.googlesource.com/439086 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* 2lib: add VB2_DEBUG_RAW() to print without function nameRandall Spangler2017-01-202-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Currently, VB2_DEBUG() will print the function name as a prefix to the debug output. Add VB2_DEBUG_RAW() to print without that, so that it's possible to print little bits of debug output. Use this in ec_sync to hex dump the hashes. And then clean up all of the debug calls which explicitly did things like: VB2_DEBUG("%s: foo", __func__); to just: VB2_DEBUG("foo"); so they don't double-print the function name BUG=chromium:683391 BRANCH=none TEST=build_packages --board=reef chromeos-firmware && DEBUG=1 make -j runtests CQ-DEPEND=CL:430978,CL:431111 Change-Id: I0c35519d2e670d55d65d01eaa60d61f3e3edf419 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/431171 Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: replace VBDEBUG(()) macro with VB2_DEBUG()Randall Spangler2017-01-124-20/+21
| | | | | | | | | | | | | | | | The original VBDEBUG macro used doubly-nested parens to work with MSVC, which didn't support varargs in macros. We now only use more modern compilers, so replace it with the VB2_DEBUG macro and get rid of the ugly and fragile double parens. BUG=chromium:611535 BRANCH=none TEST=make runtests; build_packages --board=reef chromeos-firmware Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425133 Reviewed-by: Shelley Chen <shchen@chromium.org>
* crossystem: add phase_enforcement fieldAaron Durbin2016-12-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Provide 'phase_enforcement' field that indicates if a system should have its full security features enabled while in the factory. The backend implementation currently is only for x86 using chromeos_acpi. On reef: $ grep ^ /sys/devices/platform/chromeos_acpi/GPIO.*/* /sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.0:4 /sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.1:1 /sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.2:10 /sys/devices/platform/chromeos_acpi/GPIO.2/GPIO.3:INT3452:00 BUG=chrome-os-partner:59951 BRANCH=None TEST=Tested on reef with accompanying coreboot patches and flipping internal pulls to see the correct setting. Change-Id: Id5401d795cff8874a038f2456121549713a11237 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/418899 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* vboot: Add vb2_unpack_key_bufferRandall Spangler2016-11-061-1/+3
| | | | | | | | | | | | | | | | | Previously, vb2_unpack_key() actually unpacked a key buffer. Callers that had a vb2_packed_key had to typecast it back to a uint8_t buffer to unpack it. Rename vb2_unpack_key() to vb2_unpack_key_buffer(), and make vb2_unpack_key() unpack a vb2_packed_key. BUG=chromium:611535 BRANCH=none TEST=make runtests; emerge-kevin coreboot depthcharge; emerge-samus and boot it Change-Id: I9ee38a819c59cc58a72ead78cf5ddf3d0f301ae7 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/400906 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>