summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* futility: Create signatures using vboot 2.0 APIsstabilize-8688.BRandall Spangler2016-08-0327-319/+505
| | | | | | | | | | | | | Refactor futility to use only vboot 2.0 APIs to create signatures. BUG=chromium:611535 BRANCH=none TEST=make runtests Change-Id: I176e7f424fa556d34d8fe691df5681f1e43210ce Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356128 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot: Always compile vb2.1 stuff into utillibRandall Spangler2016-08-031-30/+10
| | | | | | | | | | | | | | | Some of the vboot 2.0 and 2.1 functions call common code that currently lives inside the vb2.1 host library. To be able to use vboot 2.0 code in futility, we always need to include the 2.1 sources. BUG=chromium:611535 BRANCH=none TEST=make runtests Change-Id: Ib01622fa462d0bceda1e6041b5e3395ee7c2f94f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356127 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* futility: cmd_show uses only vboot 2.0 APIsRandall Spangler2016-08-0311-87/+151
| | | | | | | | | | | | | This removes the remaining vboot 1.0 API calls from cmd_show. BUG=chromium:611535 BRANCH=none TEST=make runtests Change-Id: I03c4260aa034100efbbea1005367cd85dfff273d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/350173 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cgptlib: cast 32bit to 64bit before multiplicationPatrick Georgi2016-08-031-3/+6
| | | | | | | | | | | | | | | | | Coverity noted that multiplying two 32bit values happens in 32bit, while the result is to be stored in an uint64_t. BUG=none BRANCH=none TEST=none Found-by: Coverity Scan #1353032, #1353033, 1353034 Change-Id: I8d0c5fe4feee066a81e8904c525dc836dd7a4fc6 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/365391 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tlcl: implement clear, startup, shutdown, self teststabilize-8647.BAndrey Pronin2016-07-263-6/+133
| | | | | | | | | | | | | | | | | Implement TlclStartup, TlclSaveState, TlclResume, TlclSelfTestFull, TlclContinueSelfTest, TlclForceClear. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55250 TEST=boot on kevin in recovery mode, verify that 'tpmc ctest', 'tpmc startup', 'tpmc clear' work. Change-Id: I00839eae1984e24c0138ec5bdab8299379e1bcb6 Reviewed-on: https://chromium-review.googlesource.com/362996 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tlcl: support sending raw commandsAndrey Pronin2016-07-263-4/+43
| | | | | | | | | | | | | | | Implement TlclSendReceive and TlclPacketSize required for sending raw commands. BRANCH=none BUG=chrome-os-partner:55210 TEST=boot on kevin, verify that 'tpmc raw' works Change-Id: Iba41b95dd7790a6b7a3a7af6cf5f897f45dce1e5 Reviewed-on: https://chromium-review.googlesource.com/363033 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tpmc: define actions for all commands for tpm2Andrey Pronin2016-07-261-29/+67
| | | | | | | | | | | | | | | | | | | | | Implement macros to handle differences between TPM1.2 and TPM2.0. For all original tpmc commands define if they are to (1) be implemented, (2) do nothing, or (3) return a "not implemented" error. Print TPM mode (1.2 or 2.0) for tpmc in 'tpmc help' output. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55250 TEST=boot on kevin; verify that the following tpmc commands do nothing and return success: ppon, enable, activate; verify that 'help' prnts the right mode and command descriptions. Change-Id: Ifec4e8e5bd4afb45f76f9c2b3249c844ea1b670a Reviewed-on: https://chromium-review.googlesource.com/363000 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Modify 'tpmc block' to lock only the FW indexAndrey Pronin2016-07-265-7/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in https://chromium-review.googlesource.com/#/c/361381/, instead of being a synonym to 'tpmc pplock', the 'tpmc block' command should protect just the FW index using WriteLock. Additionally, both TlclSetGlobalLock and TlclLockPhysicalPresence in tlcl (which are used by 'tpmc block' and 'tpmc pplock') are updated to first check if the platform hierarchy is already disabled and return success, if so. That's needed to prevent command failures when rollback protection is already on. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55250 TEST=boot on kevin, verify that 'tpmc block' and 'tpmc pplock' work as expected: - pplock is possible after block - pplock and block succeed both for enabled and disabled PH - block locks FW index - pplock disables PH Change-Id: I32bff2b590a51315b11da361b97c684dcce8ab36 Reviewed-on: https://chromium-review.googlesource.com/362772 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tlcl: automatically detect if platform hierarchy is disabledAndrey Pronin2016-07-264-20/+38
| | | | | | | | | | | | | | | | | Instead of passing a special flag when 'tpmc' starts, auto-detect if platform hierarchy is disabled in TlclLibInit(). See discussion in https://chromium-review.googlesource.com/#/c/362520/. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55250 TEST=boot on kevin, verify that 'tpmc read 0x1008 0xd' works Change-Id: Id94e7faadf835f7ea58a944e914163d6849e85c1 Reviewed-on: https://chromium-review.googlesource.com/362771 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: Upgrade VerifyFirmwarePreamble() to vboot2.0Randall Spangler2016-07-2623-563/+424
| | | | | | | | | | | | | | | This replaces all calls to vboot1 VerifyFirmwarePreamble() with equivalent vb2.0 functions. No effect on ToT firmware, which already uses the vboot2.0 functions. BUG=chromium:611535 BRANCH=none TEST=make runtests Change-Id: I5c84e9ed0e0c75e2ea8dbd9bfcde0597bc457f24 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/349322 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* apollolake: Find GPIO bank offset for write protect pinsselvar22016-07-261-3/+13
| | | | | | | | | | | | | | | | Specify function to find GPIO bank offset for write protect pin in Broxton. BUG=chrome-os-partner:55604 BRANCH=none TEST=verify crossystem output with and without WP screw. Change-Id: Ied41f31e59e0dfc699fbcd1b6bb8688f1fea549c Signed-off-by: sselvar2 <susendra.selvaraj@intel.com> Reviewed-on: https://chromium-review.googlesource.com/358124 Commit-Ready: Aaron Durbin <adurbin@chromium.org> Tested-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* tlcl: tpm2: fix unmarshal_u32 return valueAndrey Pronin2016-07-261-1/+1
| | | | | | | | | | | | | | | Before the fix, unmarshal_u32 returned only 16 bits of the value. BRANCH=none BUG=chrome-os-partner:55210 TEST=boot on keving, verify that 'tpmc getvf' correctly returns the 'orderly' flag (bit 31 of a 32-bit flags value) Change-Id: I182abdd78a6bdcbc21fe631492559099caeb934f Reviewed-on: https://chromium-review.googlesource.com/362994 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Implement GetCapabilities and reading flags for tpm2Andrey Pronin2016-07-264-29/+225
| | | | | | | | | | | | | | | | | | For TPM2.0: 1) Implement TPM2_GetCapabilities command that allows reading TPM properties, including PERMANENT and STARTUP_CLEAR flags. 2) Implement 'getpf' and 'getvf' commands in tpmc. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55250 TEST=boot on kevin, verify 'tpmc getpf' and 'tpmc getvf' Change-Id: I8490b2c92ebf7c266e27b7cb5898126a1b99b1a8 Reviewed-on: https://chromium-review.googlesource.com/362770 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: Disambiguate vb2.1 structs and functionsRandall Spangler2016-07-2635-778/+779
| | | | | | | | | | | | | | | | | | | | | | | Futility needs to link against both vboot1/vboot2.0 and vboot2.1 functions. This was easy in the past because it did (vboot1 + vboot2.1) and there's no overlap. In replacing vboot1 function calls and structs with vboot2.0, now there are symbol collisions between vboot2.0 and vboot2.1. For example, both of them use a struct called vb2_signature, but the structs are defined differently. Functions which operate on those structs also overload. Rename the vb2.1 structs to start with vb21_ instead of vb2_. Do the same for vb2.1 functions which operate on vb2.1 data. BUG=chromium:611535 BRANCH=none TEST=make runtests Change-Id: I24defd87cbd9ef64239faf1a8e98ab2372d27539 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/347458 Reviewed-by: Daisuke Nojiri <dnojiri@google.com>
* vboot: Remove vboot1 init and select-firmware APIsRandall Spangler2016-07-2629-4166/+3
| | | | | | | | | | | | | | | | | | And nuke all the underlying code that is unused once those APIs are gone. These APIs are not used by any project in ToT, having been superseded last year by the vboot2 APIs. No functional changes to live code, just lots of deletes. CQ-DEPEND=CL:347414 BUG=chromium:611535 BRANCH=none TEST=make runtests; build samus Change-Id: I05ac752d74d1343dd03600b1c5e6ed22822e2802 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/347257
* bmpblk_utility: fix build warnings (errors) with USE="-minimal"Brian Norris2016-07-251-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Warning like this: utility/bmpblk_utility.cc: In member function 'void vboot_reference::BmpBlockUtil::load_yaml_config(const char*)': utility/bmpblk_utility.cc:104:61: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'std::vector<std::basic_string<char> >::size_type {aka unsigned int}' [-Werror=format=] printf("%ld image_names\n", config_.image_names.size()); ^ utility/bmpblk_utility.cc:108:59: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'std::map<std::basic_string<char>, vboot_reference::ImageConfig>::size_type {aka unsigned int}' [-Werror=format=] printf("%ld images_map\n", config_.images_map.size()); ^ utility/bmpblk_utility.cc:119:61: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'std::map<std::basic_string<char>, vboot_reference::ScreenConfig>::size_type {aka unsigned int}' [-Werror=format=] printf("%ld screens_map\n", config_.screens_map.size()); ^ utility/bmpblk_utility.cc: In member function 'void vboot_reference::BmpBlockUtil::pack_bmpblock()': utility/bmpblk_utility.cc:597:70: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'std::basic_string<char>::size_type {aka unsigned int}' [-Werror=format=] current_offset, it->second.compressed_content.length()); ^ utility/bmpblk_utility.cc:609:59: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'std::basic_string<char>::size_type {aka unsigned int}' [-Werror=format=] current_offset, config_.locale_names.size()); ^ Technically, C++ container::size_type is slightly different than size_t, but I think %zd should work fine. BRANCH=none BUG=none TEST=`USE="-minimal" emerge-kevin vboot_reference` Change-Id: I9d0b22818714cad2ad7e95557df7837c91c2b0f7 Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/362621 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fix yaml pkg-config warningsBrian Norris2016-07-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | I see warnings like this when building with USE=minimal (the default): Package yaml-0.1 was not found in the pkg-config search path. Perhaps you should add the directory containing `yaml-0.1.pc' to the PKG_CONFIG_PATH environment variable No package 'yaml-0.1' found That's because we don't have a yaml dependency for the USE=minimal build, yet we still unconditionally call `pkg-config --libs yaml-0.1`. Let's move the pkg-config calls into 'ifeq' block where they're actually used. BRANCH=none BUG=none TEST=`emerge-${BOARD} vboot_reference` both with and without USE=minimal Change-Id: I96a59848ee970abacbe4cc3c56bb35c7cf552f63 Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/362620 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: Convert vboot1 SHA calls to use vboot2Randall Spangler2016-07-2239-1608/+378
| | | | | | | | | | | | | | | | | | This change replaces all calls to the old vboot1 SHA library with their vboot2 equivalents. This is the first in a long series of changes to move the core vboot kernel verification into vb2, and the control/display loop out to depthcharge. BUG=chromium:611535 BRANCH=none TEST=make runtests; build samus firmware and boot it Change-Id: I31986eb766176c0e39a192c5ce15730471c3cf94 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/344342 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* vboot: Fix potential alignment issue reading FWMPRandall Spangler2016-07-221-10/+17
| | | | | | | | | | | | | | | | | | | | | RollbackFwmpRead() assumed that a uint8[] array on the stack would be aligned sufficiently for typecasting to struct RollbackSpaceFwmp and accessing its members. This was true on x86 (where unaligned accesses work fine) and probably harmless on other platforms (since RollbackSpaceFwmp is __attribute__(packed). But it's cleaner to switch to using a union of the buffer and struct, since that will provide the proper alignment. BUG=chromium:601492 BRANCH=baytrail and newer platforms TEST=make -j runtests Change-Id: I97077923ab5809c68510cbd382541bf2827aba6b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/362087 Commit-Ready: Dan Shi <dshi@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tlcl: use different NV_Read authorizations for fw and userlandAndrey Pronin2016-07-226-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | Let's use an earlier version of CL 360944 that relies on the global flag to decide if the platform authorization is to be used. As it turned out, we can't read NVRAM with empty password authorization if platform hierarchy is still enabled (as it is in firmware), so we keep platform authorization for firmware, and use empty password only for userland utilities, like tpmc. BRANCH=none BUG=chrome-os-partner:55531 TEST=Run 'initctl stop trunksd; tpmc read 0x1008 0xd" on kevin, verify that it returns the right output. Change-Id: Ic878ebde9086e803d2487d90c55c0f19001cf94b Signed-off-by: Andrey Pronin <apronin@google.com> Reviewed-on: https://chromium-review.googlesource.com/362520 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* Support 'tpmc setbgloballock' for tpm2 caseAndrey Pronin2016-07-211-1/+4
| | | | | | | | | | | | | | | | | Some scripts call 'tpmc setbgloballock' or 'tpmc block'. For tpm2 it should be equivalent to pplock, i.e. perform rollback protection actions: writelock for NVRAM firmware index and disable platform hierarchy. BRANCH=none BUG=chrome-os-partner:55210 TEST=run 'tpmc block' on kevin, check that it attempts pplock Change-Id: I51fae6bd111cf3ff3c1dfbed7441868abad8fc15 Reviewed-on: https://chromium-review.googlesource.com/361381 Commit-Ready: Dan Shi <dshi@google.com> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Darren Krahn <dkrahn@chromium.org>
* Read NVRAM with proper authorization for tpm2Andrey Pronin2016-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | In TPM2 case, NVRAM must be read with empty password authorization in tpmc, since platform hierarchy is disabled by firmware or trunksd for rollback prevention. Since all NVRAM indices are now defined with AUTHREAD, switch to empty password authorization from platform authorization for all NVRAM reads in Tlcl. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55251 TEST=Run 'initctl stop trunksd; tpmc read 0x1008 0xd" on kevin, verify that it returns the right output. Change-Id: Ifb72ff5080a4ac5f8d63b5c0713e5bb184f176ca Reviewed-on: https://chromium-review.googlesource.com/360944 Commit-Ready: Dan Shi <dshi@google.com> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Proper armv7l host arch detectionPaul Kocialkowski2016-07-181-0/+4
| | | | | | | | | | | | | | | This allows properly detecting an armv7l host architecture and setting the right ARCH value so that e.g. crossystem can build fine. BRANCH=none BUG=none TEST=Build host_stuff on an armv7l machine Change-Id: I6a6ac74477eff41e73eca671d9dac229888c4e77 Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-on: https://chromium-review.googlesource.com/360160 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* Stub tlcl implementation for tpm2 caseAndrey Pronin2016-07-156-19/+218
| | | | | | | | | | | | | | | | | | | Build a special version of TPM Lightweight Command Library in libvboot_host for TPM2. Create the framework for implementation, stub functions for now. libvboot_host is used by tpmc and other user-space utilities that talk directly to tpm bypassing trunks/trousers. BRANCH=none BUG=chrome-os-partner:54981 BUG=chrome-os-partner:55210 TEST=Boot on kevin, verify that 'tpmc read' works. Change-Id: I4cc41028041193041defc319687697eb9edb1f3e Reviewed-on: https://chromium-review.googlesource.com/358623 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* bdb: Add nvmrw_get and nvmrw_setDaisuke Nojiri2016-07-114-0/+180
| | | | | | | | | | | | | These internal APIs are used to get and set values in NVM-RW variables. BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: Ibae1836cb569fe89dd2c8249f76c66b78b1c2cf4 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356691 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tpm2: add nvram lock and hierarchy control commandsVadim Bendebury2016-07-093-4/+102
| | | | | | | | | | | | | | | | | | | | The firmware needs to lock the kernel rollback index before starting up the kernel. The TPM2_NV_WriteLock command is used for that. We also want to limit the amount of control the user space apps have over TPM. With TPM1.2 it was achieved by deasserting physical presence. TPM2 specification allows to achieve the same goal by disabling Platform Hierarchy, which is active out of reset. BRANCH=none BUG=chrome-os-partner:50465 TEST=verified that all commands succeed and chrome OS boots up fine. Change-Id: Ia5893460e0b29f1945cb2aae45a5f10b08fe1ed1 Reviewed-on: https://chromium-review.googlesource.com/358351 Commit-Ready: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Darren Krahn <dkrahn@chromium.org>
* fix a compile flag typoVadim Bendebury2016-07-071-1/+1
| | | | | | | | | | | | | | The code guarded by this compilation flag is not supposed to kick in on gru/kevin, this is how the typo went unnoticed. BRANCH=none BUG=none TEST=kevin still boots into chrome os Change-Id: Ic12aacb7ad9b2361666e719a50597d3836d5212a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/358493 Reviewed-by: Julius Werner <jwerner@chromium.org>
* vb2api: pad digest buffers if they are larger than digest sizesVadim Bendebury2016-07-061-0/+3
| | | | | | | | | | | | | | | | | Extending tpm PCRs in case of TPM2 requires 32 bit values, some digests pre-calculated in vboot source code are 20 bytes in size. To make sure that PCR extension is consistent, pad remaining buffer space when a 20 byte digest is returned in a 32 byte buffer. BRANCH=none BUG=chrome-os-partner:50645 TEST=did not verify much, made sure that PCR extension commands triggered by coreboot succeed. Change-Id: Ib16bdf782f18a6106eadb4b880cd1e67b56ad6db Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/358175 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tpm2: refactor tpm2 return value processingVadim Bendebury2016-07-061-8/+10
| | | | | | | | | | | | | | | | There is no point in checking and reporting error code in each function calling tpm_process_command(), let's do it in one place for all commands. BRANCH=none BUG=chrome-os-partner:50645 TEST=Kevin still boots to chrome os Change-Id: I10f45bd15df293f63401c295c5dce833543c50da Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/358174 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Darren Krahn <dkrahn@chromium.org>
* tpm2: add marshaling/unmarshaling and tlcl supportVadim Bendebury2016-07-013-0/+569
| | | | | | | | | | | | | | | | | | | | | | | | The marshaling code is a port of the coreboot patch https://chromium-review.googlesource.com/353915. The only supported commands at this time are NV_read and NV_write. The tlcl layer includes functions necessary to satisfy compilation requirements of rollback_index.c, functions to lock spaces and clear TPM are not yet implemented, they just report being invoked. The missing functions implementation is coming, but even without it it is possible to boot Chrome OS with firmware and kernel rollback counters maintained in the TPM NVRAM. BRANCH=none BUG=chrome-os-partner:50645 TEST=with depthcharge patches applied kevin/gru boards boot into chrome OS with rollback counters read from/written to TPM2 Change-Id: I29fe9069d7c37c33d354f36c93bda15d439bf74f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356753 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tpm2: simplify rollback checks.Vadim Bendebury2016-07-011-8/+21
| | | | | | | | | | | | | | | | | | | | On the systems using TPM2 this rollback index check will run only for the kernel space. This means that TPM initialization is guaranteed to be completed by the time this code runs. The exact ways of verifying the space settings and locking it are still being designed, this functionality is temporarily excluded in this patch. BRANCH=none BUG=chrome-os-partner:50645 TEST=with the rest of the patches applied kevin/gru boards boot into chrome OS with rollback counters read from/written to TPM2 Change-Id: Ie4e22886493404f538b2b3ae6f8c2bdca5f7ab22 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356752 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tpm: add TSS constants and structures for TPM2Vadim Bendebury2016-07-013-178/+307
| | | | | | | | | | | | | | | | | | | The latest TPM specification uses different command codes, command structures and return codes. Let's put definitions for different TPM versions into different include files. CQ-DEPEND=CL:357831 BRANCH=none BUG=chrome-os-partner:50645 TEST=with the rest of the patches applied kevin/gru boards boot into chrome OS with rollback counters read from/written to TPM2 Change-Id: Ie13696d4e5098a4ea5e338e84334d257e5c704a7 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356751 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add ability to build vboot firmware for TPM2 supportVadim Bendebury2016-07-011-1/+12
| | | | | | | | | | | | | | | TPM2 will have to use a different tlcl layer, the configuration option will be provided by depthcharge at build time. BRANCH=none BUG=chrome-os-partner:50645 TEST=with the rest of the patches applied kevin/gru boards boot into chrome OS with rollback counters read from/written to TPM2 Change-Id: I0694741f5317da2c3268ee9edfdf29caff2fc26c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356750 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* bdb: Add secrets librarystabilize-8530.Bstabilize-8530.96.Bstabilize-8530.93.Bstabilize-8530.89.Bstabilize-8530.80.Bstabilize-8530.77.Bstabilize-8530.71.Bstabilize-8530.35.Bstabilize-8516.Brelease-R53-8530.BDaisuke Nojiri2016-06-237-1/+276
| | | | | | | | | | | | | | The secrets library clears, extends, and derives secrets which are used by vboot SoC. BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: I38c93fd450364792cebc942694f848e10d0e9502 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/349252 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* bdb: Add vba_update_bucDaisuke Nojiri2016-06-225-0/+137
| | | | | | | | | | | | | vba_update_buc writes a BUC (boot unlock code) to NVM-RW. It will be called by AP-RW to update a BUC. BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: Ic91f34b60b11ebce948bce01993ddb44519a59b8 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/346233
* test: Add tests for futility show and vbutil_*stabilize-8481.Bstabilize-8447.Bstabilize-8429.BRandall Spangler2016-06-0720-0/+362
| | | | | | | | | | | | | | Currently, the unit tests verify a 0 exit code, but don't check the output. Add tests to check the output. BUG=chromium:617247 BRANCH=none TEST=make runtests Change-Id: I842046bb6f788eee05a1f2f511c6fb08df4a5379 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/349670 Reviewed-by: Daisuke Nojiri <dnojiri@google.com>
* vboot_api_kernel: Remove assumptions about EC-RW hash type and sizeJulius Werner2016-05-312-188/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | With newer PD chips and different update mechanisms, we can no longer guarantee that the "hash" (really just a sort of version identifier) of an EC-RW image will always be a SHA256. This patch removes any hardcoded assumptions about that from vboot, and instead accepts any hash size returned by VbExEcHashImage() and VbExEcGetExpectedImageHash(). It also removes the assumption that the hash can be regenerated by running SHA256 over the full image returned by VbExEcGetExpectedImage(). We can thus no longer support VBERROR_EC_GET_EXPECTED_HASH_FROM_IMAGE, which is fine since that functionality hasn't been needed for years and there would be no reason why we might need it in the future. This also allows simplifying the code flow of EcUpdateImage() a bit (since you can really just return very early if you already figured out that you don't need to update). BRANCH=None BUG=chrome-os-partner:53780 TEST=Tested software sync on Oak both after cold and warm boot. Change-Id: I498f3d39085a38740734fff9f2d1a186a0801489 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/348001 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vb2_sha: Add sha256 extendDaisuke Nojiri2016-05-203-4/+40
| | | | | | | | | | | | | | | This patch adds vb2_sha256_extend, which extends a hash using a given block. BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: I512674f18dffc55692907c85b19ff19df88a5eeb Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/346234 Commit-Ready: Daisuke Nojiri <dnojiri@google.com> Tested-by: Daisuke Nojiri <dnojiri@google.com> Reviewed-by: Randall Spangler <rspangler@google.com>
* bdb: Add NVM libraryDaisuke Nojiri2016-05-208-16/+762
| | | | | | | | | | | | | | This patch adds NVM library, which verifies, updates, and syncs NVM-RW of vboot SoC. BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: I5adc399f9e582bd9ea7d9ee73482ed9a924837e0 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/343121 Reviewed-by: Daisuke Nojiri <dnojiri@google.com>
* test: Print out actual result when test_succ failsstabilize-8350.68.Bstabilize-8350.21.Brelease-R52-8350.BDaisuke Nojiri2016-05-181-1/+1
| | | | | | | | | | | BUG=none BRANCH=tot TEST=make runtests Change-Id: I419b01d2dd0798bd0a3fe155e41d6aa3d328716a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/345586 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* test: Make TEST_* report test locationstabilize-8337.BDaisuke Nojiri2016-05-104-66/+158
| | | | | | | | | | | | | | | | | | | This patch converts TEST_* functions to macros, which print file name and line # of the check. This will allow us to locate a failed test quickly. New TEST_* macros also automatically generate a test name if testname == NULL. This will save us time to think of a name for every single check we write in a test. BUG=none BRANCH=tot TEST=make runtests Change-Id: Ibdeb99681985c3f348836d256fa3484f2f0c315f Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/343233 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* hmac: Add HMAC to 2lib libraryDaisuke Nojiri2016-05-108-2/+290
| | | | | | | | | | | | | | | This patch adds HMAC. HMAC will be used to sign/verify NVM structures. Hash algorithms can be selected from those supported by enum vb2_hash_algorithm (i.e. SHA1, SHA256, or SHA512). BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: I6d349bc807874fe2a5512aabcd7fbf67a4eaa40a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/342880 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* vboot: Fix FWMP link error if TPM is mockedRandall Spangler2016-05-112-2/+13
| | | | | | | | | | | | | | | | The MOCK_TPM build flag caused link to fail because RollbackFwmpRead() was missing its mock. BUG=chromium:601492 BRANCH=baytrail and newer platforms TEST=make -j runtests Hack makefile to add MOCK_TPM := 1 and make -j; no link errors. Change-Id: I3885d6b6c627bf475f4da33ef67f31aec2159799 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/343920 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* vboot: Add firmware management parametersRandall Spangler2016-05-0812-5/+442
| | | | | | | | | | | | | | | | This adds RW firmware support for the optional firmware management parameters TPM space. System-level tests require CL:339262 to add cryptohome support. BUG=chromium:601492 BRANCH=baytrail and newer platforms TEST=make -j runtests Or better, COV=1 make, and then make sure all new code is covered. Change-Id: Ifaf644c80809552d5961615be6017c2a332a034b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/339234
* test: Add TEST_STR_NEQDaisuke Nojiri2016-05-082-0/+25
| | | | | | | | | | | | | | TEST_STR_NES can be used to check the returned string is not what it shouldn't be. BUG=none BRANCH=tot TEST=make runtests Change-Id: I09d5a63334e9b8365a44bb96ed31db8155d95e21 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/343120 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* bdb: Add vba_bdb_initDaisuke Nojiri2016-05-076-2/+500
| | | | | | | | | | | | | | | | | | | vba_bdb_init initializes the vboot context and decides what to do next based on the vboot register content. Possible actions are: 1. proceed to verify the current slot 2. reset to try the other slot 3. reset to recovery mode bdb_sprw_test demonstrates these actions. BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: If72cdd575d09b9162a871f088064ca853b7fd74d Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/342604 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* bdb: Add vboot_register.hDaisuke Nojiri2016-05-071-0/+22
| | | | | | | | | | | | | | vboot_register.h lists definitions for vboot registers. Vboot registers are used to transfer information between modules (coreboot & depthcharge) or boots. BUG=chrome-os-partner:51907 BRANCH=tot TEST=make runtests Change-Id: Ie0876fefb43d3e79a8f96e8f25f99f798892a056 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/342603
* bdb: Rename subkey to datakeystabilize-8282.Bfirmware-gale-8281.BDaisuke Nojiri2016-05-049-44/+44
| | | | | | | | | | | | | | This patch replaces subkey with datakey to make name use consistent with the design document. BUG=chrome-os-partner:51908 BRANCH=tot TEST=make runtests Change-Id: I3690abd51e6c18c5a1094a8449f375d803c7e0b2 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/342199 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* bdb: Replace sha functions with vb2 libraryDaisuke Nojiri2016-05-045-221/+20
| | | | | | | | | | | | | | BDB has its own implementation of SHA256. This patch replaces it with the one implemented in vb2 library. BUG=chrome-os-partner:51908 BRANCH=tot TEST=build runtests Change-Id: Ida19dd49153a038fc2b2ce481cedf828818aaeaa Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/342121 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* bdb: Integrate bdb_testDaisuke Nojiri2016-05-042-108/+150
| | | | | | | | | | | | | This patch integrate bdb_test with the root Makefile. BUG=chrome-os-partner:51908 BRANCH=tot TEST=make runtests Change-Id: I6266199d8f3068d2e9349110e8351f20d027ab35 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/342091 Reviewed-by: Randall Spangler <rspangler@chromium.org>