[coreboot-gerrit] Change in coreboot[master]: vboot: Add function to check if UDC can be enabled

Furquan Shaikh (Code Review) gerrit at coreboot.org
Thu Apr 26 04:12:17 CEST 2018


Hello Duncan Laurie,

I'd like you to do a code review. Please visit

    https://review.coreboot.org/25847

to review the following change.


Change subject: vboot: Add function to check if UDC can be enabled
......................................................................

vboot: Add function to check if UDC can be enabled

Add a function that will check the various requirements to
enable UDC:

- developer mode enabled
- GBB flag set or VBNV flag set

BUG=b:78577893
BRANCH=poppy

Change-Id: Id146ac1065f209865372aeb423f66ae734702954
Signed-off-by: Duncan Laurie <dlaurie at google.com>
Signed-off-by: Furquan Shaikh <furquan at google.com>
---
M src/security/vboot/vboot_common.c
M src/security/vboot/vboot_common.h
2 files changed, 21 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/47/25847/1

diff --git a/src/security/vboot/vboot_common.c b/src/security/vboot/vboot_common.c
index 11320d2..e7ad376 100644
--- a/src/security/vboot/vboot_common.c
+++ b/src/security/vboot/vboot_common.c
@@ -20,11 +20,14 @@
 #include <console/cbmem_console.h>
 #include <console/console.h>
 #include <fmap.h>
+#include <gbb_header.h>
 #include <reset.h>
 #include <rules.h>
 #include <stddef.h>
 #include <string.h>
+#include <security/vboot/gbb.h>
 #include <security/vboot/vboot_common.h>
+#include <security/vboot/vbnv.h>
 
 int vboot_named_region_device(const char *name, struct region_device *rdev)
 {
@@ -36,6 +39,22 @@
 	return fmap_locate_area_as_rdev_rw(name, rdev);
 }
 
+/* Read the UDC enable flag from VBNV. */
+int vboot_can_enable_udc(void)
+{
+	/* Always disable if not in developer mode */
+	if (!vboot_developer_mode_enabled())
+		return 0;
+	/* Enable if GBB flag is set */
+	if (gbb_is_flag_set(GBB_FLAG_ENABLE_UDC))
+		return 1;
+	/* Enable if VBNV flag is set */
+	if (vbnv_udc_enable_flag())
+		return 1;
+	/* Otherwise disable */
+	return 0;
+}
+
 /* ========================== VBOOT HANDOFF APIs =========================== */
 int vboot_get_handoff_info(void **addr, uint32_t *size)
 {
diff --git a/src/security/vboot/vboot_common.h b/src/security/vboot/vboot_common.h
index 8c92f7f..53fed15 100644
--- a/src/security/vboot/vboot_common.h
+++ b/src/security/vboot/vboot_common.h
@@ -109,10 +109,12 @@
 int vboot_developer_mode_enabled(void);
 int vboot_recovery_mode_enabled(void);
 int vboot_recovery_mode_memory_retrain(void);
+int vboot_can_enable_udc(void);
 #else /* !CONFIG_VBOOT */
 static inline int vboot_developer_mode_enabled(void) { return 0; }
 static inline int vboot_recovery_mode_enabled(void) { return 0; }
 static inline int vboot_recovery_mode_memory_retrain(void) { return 0; }
+static inline int vboot_can_enable_udc(void) { return 0; }
 #endif
 
 #endif /* __VBOOT_VBOOT_COMMON_H__ */

-- 
To view, visit https://review.coreboot.org/25847
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id146ac1065f209865372aeb423f66ae734702954
Gerrit-Change-Number: 25847
Gerrit-PatchSet: 1
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Duncan Laurie <dlaurie at chromium.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180426/252ec2dc/attachment-0001.html>


More information about the coreboot-gerrit mailing list