diff mbox series

[v6,10/20] secvar_devtree: add physical presence mode helper

Message ID 20200916162131.22478-11-erichte@linux.ibm.com
State Accepted
Headers show
Series Add initial secure variable storage and backend drivers | expand

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d362ae4f4c521a7faffb1befe2fbba467f2c4d18)

Commit Message

Eric Richter Sept. 16, 2020, 4:21 p.m. UTC
This patch adds a simple function to detect whether or not physical
presence has been asserted. In the current implementation, all physical
presence assertion modes are treated the same.

Signed-off-by: Eric Richter <erichte@linux.ibm.com>
---
 libstb/secvar/secvar_devtree.c | 15 +++++++++++++++
 libstb/secvar/secvar_devtree.h |  2 ++
 2 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/libstb/secvar/secvar_devtree.c b/libstb/secvar/secvar_devtree.c
index 998093f7..5903ee34 100644
--- a/libstb/secvar/secvar_devtree.c
+++ b/libstb/secvar/secvar_devtree.c
@@ -64,3 +64,18 @@  void secvar_set_update_status(uint64_t val)
 	dt_add_property_u64(secvar_node, "update-status", val);
 }
 
+bool secvar_check_physical_presence(void)
+{
+	struct dt_node *secureboot;
+
+	secureboot = dt_find_by_path(dt_root, "ibm,secureboot");
+	if (!secureboot)
+		return false;
+
+	if (dt_find_property(secureboot, "clear-os-keys")
+			|| dt_find_property(secureboot, "clear-all-keys")
+			|| dt_find_property(secureboot, "clear-mfg-keys"))
+		return true;
+
+	return false;
+}
diff --git a/libstb/secvar/secvar_devtree.h b/libstb/secvar/secvar_devtree.h
index c1c923d9..04eb00de 100644
--- a/libstb/secvar/secvar_devtree.h
+++ b/libstb/secvar/secvar_devtree.h
@@ -10,4 +10,6 @@  void secvar_init_devnode(const char *compatible);
 void secvar_set_status(const char *status);
 void secvar_set_update_status(uint64_t val);
 
+bool secvar_check_physical_presence(void);
+
 #endif