[coreboot-gerrit] New patch to review for coreboot: google/chromeos: Add recovery module in vboot2

Furquan Shaikh (furquan@google.com) gerrit at coreboot.org
Fri Jul 22 18:36:37 CEST 2016


Furquan Shaikh (furquan at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15800

-gerrit

commit 94b53807542d83745b2c55dbbf36f84c2e44f0b3
Author: Furquan Shaikh <furquan at google.com>
Date:   Fri Jul 22 08:28:57 2016 -0700

    google/chromeos: Add recovery module in vboot2
    
    Add recovery module in vboot2 that checks if a recovery request is
    pending:
    1. Checks if recovery mode is initiated by EC.
    2. Checks if recovery request is present in VBNV.
    3. Checks if recovery request is present in handoff for post-cbmem
    stages.
    4. Checks if vboot verification is complete and looks up selected region
    to identify if recovery is requested by vboot library.
    
    BUG=chrome-os-partner:55431
    
    Change-Id: I31e332a4d014a185df2434c3730954e08dc27281
    Signed-off-by: Furquan Shaikh <furquan at google.com>
---
 src/vendorcode/google/chromeos/vboot2/Makefile.inc |  6 +++
 src/vendorcode/google/chromeos/vboot2/recovery.c   | 55 ++++++++++++++++++++++
 src/vendorcode/google/chromeos/vboot_common.h      |  6 +++
 3 files changed, 67 insertions(+)

diff --git a/src/vendorcode/google/chromeos/vboot2/Makefile.inc b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
index b0a3c12..31889e2 100644
--- a/src/vendorcode/google/chromeos/vboot2/Makefile.inc
+++ b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
@@ -28,6 +28,12 @@ romstage-y += ../vboot_common.c
 ramstage-y += ../vboot_common.c
 postcar-y += ../vboot_common.c
 
+bootblock-y += recovery.c
+romstage-y += recovery.c
+ramstage-y += recovery.c
+verstage-y += recovery.c
+postcar-y += recovery.c
+
 bootblock-y += common.c
 libverstage-y += vboot_logic.c
 verstage-y += common.c
diff --git a/src/vendorcode/google/chromeos/vboot2/recovery.c b/src/vendorcode/google/chromeos/vboot2/recovery.c
new file mode 100644
index 0000000..5e547bb
--- /dev/null
+++ b/src/vendorcode/google/chromeos/vboot2/recovery.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "misc.h"
+#include "../vboot_common.h"
+
+/*
+ * 1. Check if recovery mode is initiated by EC.
+ * 2. Check if recovery request is present in VBNV.
+ * 3. Check recovery request in handoff for stages post-cbmem.
+ * 4. For non-CBMEM stages, check if vboot verification is done and look-up
+ * selected region to identify if vboot_refence library has requested recovery
+ * path.
+ * 5. If nothing applies, return 0 indicating no recovery request.
+ */
+int vboot_check_recovery_request(void)
+{
+	/* EC-initiated recovery. */
+	if (get_recovery_mode_switch())
+		return 1;
+
+	/* Recovery request in VBNV. */
+	if (get_recovery_mode_from_vbnv())
+		return 1;
+
+	/*
+	 * Check recovery flag in vboot_handoff for stages post CBMEM coming
+	 * online.
+	 */
+	if (!VBOOT_PRE_CBMEM && vboot_handoff_check_recovery_flag())
+		return 1;
+
+	/*
+	 * For non-post-cbmem stages, identify if vboot verification is
+	 * already complete and no slot was selected i.e. recovery path was
+	 * requested.
+	 */
+	if (!VBOOT_POST_CBMEM && vb2_logic_executed() &&
+	    !vb2_is_slot_selected())
+		return 1;
+
+	return 0;
+}
diff --git a/src/vendorcode/google/chromeos/vboot_common.h b/src/vendorcode/google/chromeos/vboot_common.h
index 0125550..abf8d1a 100644
--- a/src/vendorcode/google/chromeos/vboot_common.h
+++ b/src/vendorcode/google/chromeos/vboot_common.h
@@ -26,10 +26,16 @@
 				 (ENV_VERSTAGE &&			\
 				  IS_ENABLED(VBOOT_STARTS_IN_BOOTBLOCK)))
 
+#define VBOOT_POST_CBMEM	(ENV_RAMSTAGE || ENV_POSTCAR)
 
 /* Locate vboot area by name. Returns 0 on success and -1 on error. */
 int vboot_named_region_device(const char *name, struct region_device *rdev);
 
+/*
+ * Function to check if there is a request to enter recovery mode. Returns 1 if
+ * request to enter recovery mode is present, otherwise 0.
+ */
+int vboot_check_recovery_request(void);
 /* ========================== VBOOT HANDOFF APIs =========================== */
 /*
  * The vboot_handoff structure contains the data to be consumed by downstream



More information about the coreboot-gerrit mailing list