vboot1: Add vboot2 recovery reason strings and subcode to TAB display

vboot2 added a few new recovery reasons (and abolished many old ones).
In the current vboot2/vboot1 hybrid architecture used on Veyron, the
vboot1 kernel verification part controls the status display when
pressing the TAB key, which may try to show recovery reasons set by the
vboot2 firmware verification part. These currently result in the not
very helpful "We have no idea what this means", so lets hack a few more
strings into vboot1 which will be otherwise harmless. Also add the
recovery_subcode field to the display, which is used much more
extensively by vboot2 and often very useful in firguring out what really
went wrong.

BRANCH=veyron
BUG=None
TEST=Manually set a few recovery reasons and subcodes through crossystem
and made sure they get displayed correctly on my Jerry.

Change-Id: I3f3e6c6ae6e7981337841c0c5e3cd767628472c3
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248391
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h
index f71a55a..4401777 100644
--- a/firmware/include/vboot_nvstorage.h
+++ b/firmware/include/vboot_nvstorage.h
@@ -183,6 +183,16 @@
 #define VBNV_RECOVERY_EC_EXPECTED_HASH 0x29
 /* EC software sync - expected EC image doesn't match hash */
 #define VBNV_RECOVERY_EC_HASH_MISMATCH 0x2A
+/* VB2: Secure data inititalization error */
+#define VBNV_RECOVERY_VB2_SECDATA_INIT 0x2B
+/* VB2: GBB header is bad */
+#define VBNV_RECOVERY_VB2_GBB_HEADER  0x2C
+/* VB2: Unable to clear TPM owner */
+#define VBNV_RECOVERY_VB2_TPM_CLEAR_OWNER 0x2D
+/* VB2: Error determining/updating virtual dev switch */
+#define VBNV_RECOVERY_VB2_DEV_SWITCH  0x2E
+/* VB2: Error determining firmware slot */
+#define VBNV_RECOVERY_VB2_FW_SLOT     0x2F
 /* Unspecified/unknown error in read-only firmware */
 #define VBNV_RECOVERY_RO_UNSPECIFIED  0x3F
 /*
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index c66af8d..26fa8bd 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -430,6 +430,16 @@
 		return "EC software sync unable to jump to EC-RW";
 	case VBNV_RECOVERY_EC_PROTECT:
 		return "EC software sync protection error";
+	case VBNV_RECOVERY_VB2_SECDATA_INIT:
+		return "Secure NVRAM (TPM) initialization error";
+	case VBNV_RECOVERY_VB2_GBB_HEADER:
+		return "Error parsing GBB header";
+	case VBNV_RECOVERY_VB2_TPM_CLEAR_OWNER:
+		return "Error trying to clear TPM owner";
+	case VBNV_RECOVERY_VB2_DEV_SWITCH:
+		return "Error reading or updating developer switch";
+	case VBNV_RECOVERY_VB2_FW_SLOT:
+		return "Error selecting RW firmware slot";
 	case VBNV_RECOVERY_RO_UNSPECIFIED:
 		return "Unspecified/unknown error in RO firmware";
 	case VBNV_RECOVERY_RW_DEV_SCREEN:
@@ -511,11 +521,14 @@
 	used += StrnAppend(buf + used, "HWID: ", DEBUG_INFO_SIZE - used);
 	used += StrnAppend(buf + used, hwid, DEBUG_INFO_SIZE - used);
 
-	/* Add recovery reason */
+	/* Add recovery reason and subcode */
+	VbNvGet(vncptr, VBNV_RECOVERY_SUBCODE, &i);
 	used += StrnAppend(buf + used,
 			"\nrecovery_reason: 0x", DEBUG_INFO_SIZE - used);
 	used += Uint64ToString(buf + used, DEBUG_INFO_SIZE - used,
 			       shared->recovery_reason, 16, 2);
+	used += StrnAppend(buf + used, " / 0x", DEBUG_INFO_SIZE - used);
+	used += Uint64ToString(buf + used, DEBUG_INFO_SIZE - used, i, 16, 2);
 	used += StrnAppend(buf + used, "  ", DEBUG_INFO_SIZE - used);
 	used += StrnAppend(buf + used,
 			RecoveryReasonString(shared->recovery_reason),