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 <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776279
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/Makefile b/Makefile
index e6c6284..fa63773 100644
--- a/Makefile
+++ b/Makefile
@@ -395,11 +395,11 @@
 # 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 @@
 
 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 @@
 	${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 95%
rename from firmware/lib/include/rollback_index.h
rename to firmware/lib/include/secdata_tpm.h
index cfa7a26..6e31e71 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 @@
  */
 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 324660f..4271f76 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 b273d23..5ddb16c 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 02d1a91..37034c9 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 dbaf93f..eb05109 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 e2ca910..e2075e2 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 2203595..35dafe9 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 4255deb..376e1a6 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 24b7de8..58349ca 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 75dda29..bc120c3 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 @@
 	/* 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 9249b11..9f4dad8 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 6fd30ba..0000000
--- 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 b8ebc80..cac5133 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 <stdint.h>
@@ -11,7 +11,7 @@
 #include <string.h>
 
 #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 011a361..dc9da89 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 43cc399..988d3e4 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 1304aaf..03194b5 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 86195e3..cd641e7 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 5b1e71b..c5636a9 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 39bf29d..bca2cf6 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 6978910..25be6fe 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 b8f5431..34bee18 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"