[coreboot-gerrit] Patch set updated for coreboot: google/chromeos: Add support for saving recovery reason across reboot

Furquan Shaikh (furquan@google.com) gerrit at coreboot.org
Fri Jul 22 18:41:18 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/15802

-gerrit

commit adbbdc3be80ebc4c757a291cd95f53df34d78437
Author: Furquan Shaikh <furquan at google.com>
Date:   Fri Jul 22 08:56:43 2016 -0700

    google/chromeos: Add support for saving recovery reason across reboot
    
    On some x86 platforms (skylake, apollolake), we observe reboots at
    different steps during the FSP initialization. These additional reboots
    result in loss of recovery request because vboot_reference library
    clears recovery request on vbnv once verification is complete and it has
    made a decision about which boot path to take(normal/dev, slot-a/slot-b,
    recovery).
    
    Provide a way to allow mainboards/chipsets to inform recovery module in
    vboot2 to save recovery reason to survive unexpected reboots. The
    recovery reason is set in vbnv after vboot_reference library completes
    its verification and clears the reason in vbnv while jumping to
    payload.
    
    BUG=chrome-os-partner:55431
    
    Change-Id: Ie96be9aeb42c8209d8215943409e6327d6a8bf98
    Signed-off-by: Furquan Shaikh <furquan at google.com>
---
 src/vendorcode/google/chromeos/vboot2/Kconfig      |  9 ++++++
 src/vendorcode/google/chromeos/vboot2/misc.h       |  2 ++
 src/vendorcode/google/chromeos/vboot2/recovery.c   | 33 ++++++++++++++++++++++
 .../google/chromeos/vboot2/vboot_loader.c          |  1 +
 4 files changed, 45 insertions(+)

diff --git a/src/vendorcode/google/chromeos/vboot2/Kconfig b/src/vendorcode/google/chromeos/vboot2/Kconfig
index 7580d8d..63dfd29 100644
--- a/src/vendorcode/google/chromeos/vboot2/Kconfig
+++ b/src/vendorcode/google/chromeos/vboot2/Kconfig
@@ -78,3 +78,12 @@ config VBOOT_DYNAMIC_WORK_BUFFER
 	  ram to allocate the vboot work buffer. That means vboot verification
 	  is after memory init and requires main memory to back the work
 	  buffer.
+
+config VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT
+	bool "Save recovery reason in VBNV on reboot."
+	default n
+	depends on VBOOT_VERIFY_FIRMWARE
+	help
+	  This option ensures that the recovery request is not lost because of
+	  reboots caused after vboot verification is run. e.g. reboots caused by
+	  FSP components on Intel platforms.
diff --git a/src/vendorcode/google/chromeos/vboot2/misc.h b/src/vendorcode/google/chromeos/vboot2/misc.h
index ca64b37..9b771a2 100644
--- a/src/vendorcode/google/chromeos/vboot2/misc.h
+++ b/src/vendorcode/google/chromeos/vboot2/misc.h
@@ -35,4 +35,6 @@ int vb2_logic_executed(void);
 /* Store the selected region in cbmem for later use. */
 void vb2_store_selected_region(void);
 
+void vb2_save_recovery_reason_vbnv(void);
+
 #endif /* __CHROMEOS_VBOOT2_MISC_H__ */
diff --git a/src/vendorcode/google/chromeos/vboot2/recovery.c b/src/vendorcode/google/chromeos/vboot2/recovery.c
index 5e547bb..0df5dfa 100644
--- a/src/vendorcode/google/chromeos/vboot2/recovery.c
+++ b/src/vendorcode/google/chromeos/vboot2/recovery.c
@@ -13,8 +13,41 @@
  * GNU General Public License for more details.
  */
 
+#include <assert.h>
+#include <bootstate.h>
 #include "misc.h"
 #include "../vboot_common.h"
+#include <vb2_api.h>
+
+static int vb2_get_recovery_reason(void)
+{
+	struct vb2_shared_data *sd = vb2_get_shared_data();
+	assert(sd);
+	return sd->recovery_reason;
+}
+
+void vb2_save_recovery_reason_vbnv(void)
+{
+	if (!IS_ENABLED(CONFIG_VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT))
+		return;
+
+	int reason =  vb2_get_recovery_reason();
+	if (!reason)
+		return;
+
+	set_recovery_mode_into_vbnv(reason);
+}
+
+static void vb2_clear_recovery_reason_vbnv(void *unused)
+{
+	if (!IS_ENABLED(CONFIG_VBOOT_SAVE_RECOVERY_REASON_ON_REBOOT))
+		return;
+
+	set_recovery_mode_into_vbnv(0);
+}
+
+BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY,
+		      vb2_clear_recovery_reason_vbnv, NULL);
 
 /*
  * 1. Check if recovery mode is initiated by EC.
diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
index 7541518..b76d20b 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
@@ -91,6 +91,7 @@ static void vboot_prepare(void)
 	if (verification_should_run()) {
 		verstage_main();
 		car_set_var(vboot_executed, 1);
+		vb2_save_recovery_reason_vbnv();
 	} else if (verstage_should_load()) {
 		struct cbfsf file;
 		struct prog verstage =



More information about the coreboot-gerrit mailing list