From 110df5cafaa55eb0e78f379be7731f8d7b3914b7 Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Thu, 29 Aug 2019 13:27:23 +0800 Subject: [PATCH] vboot/secdata: rename rollback_index to secdata_tpm These secure spaces are now used for more than just rollback versions and should be renamed thus. Note: Originally this rename operation was batched into the CL which rewrites the functions in rollback_index/secdata_tpm, but it made reviewing in Gerrit a pain, since it couldn't pick up on the file renames, and instead showed them as deletes/adds. Doing the rename separately helps ensure all references to rollback_index are updated, and gives us a better review experience in Gerrit. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I51e5c731e0d7a071d384c28da56e7adce64ba943 Signed-off-by: Joel Kitching Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776279 Commit-Queue: Joel Kitching Tested-by: Joel Kitching Reviewed-by: Julius Werner --- Makefile | 14 ++++---- .../{rollback_index.h => secdata_tpm.h} | 8 ++--- ..._rollback_index.c => mocked_secdata_tpm.c} | 4 +-- .../lib/{rollback_index.c => secdata_tpm.c} | 6 ++-- firmware/lib/tpm2_lite/tlcl.c | 2 +- firmware/lib/vboot_api_kernel.c | 2 +- firmware/lib/vboot_kernel.c | 2 +- firmware/lib/vboot_ui.c | 2 +- firmware/lib/vboot_ui_common.c | 2 +- firmware/lib/vboot_ui_menu.c | 2 +- firmware/linktest/main.c | 4 +-- tests/ec_sync_tests.c | 2 +- tests/rbtest.conf | 34 ------------------- ...ack_index2_tests.c => secdata_tpm_tests.c} | 4 +-- tests/vboot_api_devmode_tests.c | 2 +- tests/vboot_api_kernel2_tests.c | 2 +- tests/vboot_api_kernel4_tests.c | 2 +- tests/vboot_api_kernel5_tests.c | 2 +- tests/vboot_api_kernel_tests.c | 2 +- tests/vboot_detach_menu_tests.c | 2 +- tests/vboot_kernel_tests.c | 2 +- utility/load_kernel_test.c | 2 +- 22 files changed, 35 insertions(+), 69 deletions(-) rename firmware/lib/include/{rollback_index.h => secdata_tpm.h} (96%) rename firmware/lib/{mocked_rollback_index.c => mocked_secdata_tpm.c} (87%) rename firmware/lib/{rollback_index.c => secdata_tpm.c} (97%) delete mode 100644 tests/rbtest.conf rename tests/{rollback_index2_tests.c => secdata_tpm_tests.c} (99%) diff --git a/Makefile b/Makefile index e6c62846..fa63773b 100644 --- a/Makefile +++ b/Makefile @@ -395,11 +395,11 @@ endif # Support real TPM unless BIOS sets MOCK_TPM ifeq (${MOCK_TPM},) FWLIB_SRCS += \ - firmware/lib/rollback_index.c \ + firmware/lib/secdata_tpm.c \ ${TLCL_SRCS} else FWLIB_SRCS += \ - firmware/lib/mocked_rollback_index.c \ + firmware/lib/mocked_secdata_tpm.c \ firmware/lib/tpm_lite/mocked_tlcl.c endif @@ -691,10 +691,10 @@ TEST_NAMES = \ ifeq (${TPM2_MODE}${MOCK_TPM},) # TODO(apronin): tests for TPM2 case? -# tlcl_tests and rollback_index2_tests only work when MOCK_TPM is disabled +# secdata_tpm_tests and tlcl_tests only work when MOCK_TPM is disabled TEST_NAMES += \ - tests/tlcl_tests \ - tests/rollback_index2_tests + tests/secdata_tpm_tests \ + tests/tlcl_tests endif TEST_FUTIL_NAMES = \ @@ -1255,9 +1255,9 @@ runmisctests: test_setup ${RUNTEST} ${BUILD_RUN}/tests/ec_sync_tests ifeq (${TPM2_MODE}${MOCK_TPM},) # TODO(apronin): tests for TPM2 case? -# tlcl_tests and rollback_index2_tests only work when MOCK_TPM is disabled +# secdata_tpm_tests and tlcl_tests only work when MOCK_TPM is disabled + ${RUNTEST} ${BUILD_RUN}/tests/secdata_tpm_tests ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests - ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests endif ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests diff --git a/firmware/lib/include/rollback_index.h b/firmware/lib/include/secdata_tpm.h similarity index 96% rename from firmware/lib/include/rollback_index.h rename to firmware/lib/include/secdata_tpm.h index cfa7a265..6e31e71c 100644 --- a/firmware/lib/include/rollback_index.h +++ b/firmware/lib/include/secdata_tpm.h @@ -2,12 +2,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * - * Functions for querying, manipulating and locking rollback indices + * Functions for querying, manipulating and locking secure data spaces * stored in the TPM NVRAM. */ -#ifndef VBOOT_REFERENCE_ROLLBACK_INDEX_H_ -#define VBOOT_REFERENCE_ROLLBACK_INDEX_H_ +#ifndef VBOOT_REFERENCE_SECDATA_TPM_H_ +#define VBOOT_REFERENCE_SECDATA_TPM_H_ #include "2return_codes.h" #include "2sysincludes.h" @@ -170,4 +170,4 @@ uint32_t SafeWrite(uint32_t index, const void *data, uint32_t length); */ vb2_error_t SetVirtualDevMode(int val); -#endif /* VBOOT_REFERENCE_ROLLBACK_INDEX_H_ */ +#endif /* VBOOT_REFERENCE_SECDATA_TPM_H_ */ diff --git a/firmware/lib/mocked_rollback_index.c b/firmware/lib/mocked_secdata_tpm.c similarity index 87% rename from firmware/lib/mocked_rollback_index.c rename to firmware/lib/mocked_secdata_tpm.c index 324660ff..4271f768 100644 --- a/firmware/lib/mocked_rollback_index.c +++ b/firmware/lib/mocked_secdata_tpm.c @@ -2,12 +2,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * - * Functions for querying, manipulating and locking rollback indices + * Functions for querying, manipulating and locking secure data spaces * stored in the TPM NVRAM. */ #include "utility.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "tss_constants.h" vb2_error_t SetVirtualDevMode(int val) diff --git a/firmware/lib/rollback_index.c b/firmware/lib/secdata_tpm.c similarity index 97% rename from firmware/lib/rollback_index.c rename to firmware/lib/secdata_tpm.c index b273d23d..5ddb16cd 100644 --- a/firmware/lib/rollback_index.c +++ b/firmware/lib/secdata_tpm.c @@ -2,14 +2,14 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * - * Functions for querying, manipulating and locking rollback indices + * Functions for querying, manipulating and locking secure data spaces * stored in the TPM NVRAM. */ #include "2sysincludes.h" #include "2common.h" #include "2crc8.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "tlcl.h" #include "tss_constants.h" #include "vboot_api.h" @@ -17,7 +17,7 @@ #define RETURN_ON_FAILURE(tpm_command) do { \ uint32_t result_; \ if ((result_ = (tpm_command)) != TPM_SUCCESS) { \ - VB2_DEBUG("Rollback: %08x returned by " #tpm_command \ + VB2_DEBUG("TPM: 0x%x returned by " #tpm_command \ "\n", (int)result_); \ return result_; \ } \ diff --git a/firmware/lib/tpm2_lite/tlcl.c b/firmware/lib/tpm2_lite/tlcl.c index 02d1a91b..37034c99 100644 --- a/firmware/lib/tpm2_lite/tlcl.c +++ b/firmware/lib/tpm2_lite/tlcl.c @@ -7,7 +7,7 @@ */ #include "2common.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "2sysincludes.h" #include "tlcl.h" #include "tpm2_marshaling.h" diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index dbaf93f3..eb05109b 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -14,7 +14,7 @@ #include "2sysincludes.h" #include "ec_sync.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "utility.h" #include "vb2_common.h" #include "vboot_api.h" diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index e2ca910f..e2075e22 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -17,7 +17,7 @@ #include "cgptlib_internal.h" #include "gpt_misc.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "utility.h" #include "vb2_common.h" #include "vboot_api.h" diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c index 22035952..35dafe97 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -13,7 +13,7 @@ #include "2secdata.h" #include "ec_sync.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "tlcl.h" #include "utility.h" #include "vb2_common.h" diff --git a/firmware/lib/vboot_ui_common.c b/firmware/lib/vboot_ui_common.c index 4255deb0..376e1a67 100644 --- a/firmware/lib/vboot_ui_common.c +++ b/firmware/lib/vboot_ui_common.c @@ -6,7 +6,7 @@ */ #include "2common.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "2sysincludes.h" #include "vboot_api.h" #include "vboot_kernel.h" diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c index 24b7de8f..58349ca3 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -13,7 +13,7 @@ #include "2sysincludes.h" #include "ec_sync.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "utility.h" #include "vb2_common.h" #include "vboot_api.h" diff --git a/firmware/linktest/main.c b/firmware/linktest/main.c index 75dda291..bc120c3d 100644 --- a/firmware/linktest/main.c +++ b/firmware/linktest/main.c @@ -6,7 +6,7 @@ #include "2sysincludes.h" #include "cgptlib.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "tlcl.h" #include "vboot_common.h" #include "vboot_kernel.h" @@ -22,7 +22,7 @@ int main(void) /* load_kernel_fw.h */ LoadKernel(0, 0); - /* rollback_index.h */ + /* secdata_tpm.h */ RollbackKernelRead(0); RollbackKernelWrite(0); RollbackKernelLock(0); diff --git a/tests/ec_sync_tests.c b/tests/ec_sync_tests.c index 9249b11a..9f4dad89 100644 --- a/tests/ec_sync_tests.c +++ b/tests/ec_sync_tests.c @@ -16,7 +16,7 @@ #include "ec_sync.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "vboot_audio.h" #include "vboot_common.h" diff --git a/tests/rbtest.conf b/tests/rbtest.conf deleted file mode 100644 index 6fd30bab..00000000 --- a/tests/rbtest.conf +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Rollback code exhaustive test. -# -# INSTRUCTIONS. Put this file in /etc/init. Move /etc/init/tcsd.conf to -# /etc/init/tcsd.confxxx to disable it. Then boot with the device connected by -# wired ethernet. The test will start and reboot the host after every cycle. -# Unplug the ethernet cable to stop testing. If left alone, the test will stop -# at the first failure or when all the states have been tested. -# -# Reminder: rollback_index_test only works with TPM-agnostic firmware. - -# Connecting to tcsd requires that "localhost" be reachable, so we wait for -# shill to start, but that's not enough, and in the while loop below we also -# wait for pinging to localhost to succeed. - -start on started shill - -script - cable="" - while [ "$cable" != "yes" ]; do - cable=$(/usr/sbin/ethtool eth0 | grep Link | cut -f 3 -d ' ') - logger "rbtest: cable is $cable" - ping -c 1 localhost || cable="" - sleep 2 - done - # ideally we would like to issue a "stop tcsd", but this doesn't work - # (upstart race?) so we must manually disable tcsd.conf - ### stop tcsd - logger "starting rbtest" - /usr/bin/rollback_index_test > /tmp/rbtest.out 2>&1 -end script diff --git a/tests/rollback_index2_tests.c b/tests/secdata_tpm_tests.c similarity index 99% rename from tests/rollback_index2_tests.c rename to tests/secdata_tpm_tests.c index b8ebc80e..cac51338 100644 --- a/tests/rollback_index2_tests.c +++ b/tests/secdata_tpm_tests.c @@ -2,7 +2,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * - * Tests for rollback_index functions + * Tests for secdata_tpm functions */ #include @@ -11,7 +11,7 @@ #include #include "2crc8.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "tlcl.h" diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c index 011a3616..dc9da890 100644 --- a/tests/vboot_api_devmode_tests.c +++ b/tests/vboot_api_devmode_tests.c @@ -18,7 +18,7 @@ #include "crc32.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "vboot_common.h" #include "vboot_display.h" diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c index 43cc399f..988d3e4b 100644 --- a/tests/vboot_api_kernel2_tests.c +++ b/tests/vboot_api_kernel2_tests.c @@ -15,7 +15,7 @@ #include "2secdata.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "vboot_audio.h" #include "vboot_common.h" diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c index 1304aaf0..03194b56 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -17,7 +17,7 @@ #include "ec_sync.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "vboot_audio.h" #include "vboot_common.h" diff --git a/tests/vboot_api_kernel5_tests.c b/tests/vboot_api_kernel5_tests.c index 86195e3c..cd641e7a 100644 --- a/tests/vboot_api_kernel5_tests.c +++ b/tests/vboot_api_kernel5_tests.c @@ -19,7 +19,7 @@ #include "2struct.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "vb2_common.h" #include "vboot_api.h" diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c index 5b1e71b9..c5636a94 100644 --- a/tests/vboot_api_kernel_tests.c +++ b/tests/vboot_api_kernel_tests.c @@ -14,7 +14,7 @@ #include "2common.h" #include "2nvstorage.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "utility.h" #include "vboot_api.h" diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c index 39bf29dc..bca2cf6f 100644 --- a/tests/vboot_detach_menu_tests.c +++ b/tests/vboot_detach_menu_tests.c @@ -15,7 +15,7 @@ #include "2secdata.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "vboot_api.h" #include "vboot_audio.h" diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c index 69789105..25be6fe0 100644 --- a/tests/vboot_kernel_tests.c +++ b/tests/vboot_kernel_tests.c @@ -22,7 +22,7 @@ #include "gpt.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "test_common.h" #include "vb2_common.h" #include "vb2_struct.h" diff --git a/utility/load_kernel_test.c b/utility/load_kernel_test.c index b8f54315..34bee188 100644 --- a/utility/load_kernel_test.c +++ b/utility/load_kernel_test.c @@ -15,7 +15,7 @@ #include "2misc.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "rollback_index.h" +#include "secdata_tpm.h" #include "vboot_common.h" #include "vboot_kernel.h"