diff mbox series

[v4,05/18] secvar: change backend hook interface to take in bank references

Message ID 20200511213152.24952-6-erichte@linux.ibm.com
State Changes Requested
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 (0f1937ef40fca0c3212a9dff1010b832a24fb063)

Commit Message

Eric Richter May 11, 2020, 9:31 p.m. UTC
From: Nayna Jain <nayna@linux.ibm.com>

Previously, backends were implicitly expected to operate on global
references to the variable and update banks. This patch changes the
interface for this driver to instead take the banks in as an argument.

This removes the implict dependency on these references, makes the
design consistent with the storage driver, and also will simplify unit
testing of these functions.

Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
Signed-off-by: Eric Richter <erichte@linux.ibm.com>
---
V4:
 - squashed in a whitespace fix for the storage driver struct

 include/secvar.h            | 20 ++++++++++++--------
 libstb/secvar/secvar_main.c |  6 +++---
 2 files changed, 15 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/include/secvar.h b/include/secvar.h
index ec812b85..75730b2e 100644
--- a/include/secvar.h
+++ b/include/secvar.h
@@ -9,18 +9,22 @@ 
 struct secvar;
 
 struct secvar_storage_driver {
-        int (*load_bank)(struct list_head *bank, int section);
-        int (*write_bank)(struct list_head *bank, int section);
-        int (*store_init)(void);
+	int (*load_bank)(struct list_head *bank, int section);
+	int (*write_bank)(struct list_head *bank, int section);
+	int (*store_init)(void);
+	void (*lock)(void);
 	uint64_t max_var_size;
 };
 
 struct secvar_backend_driver {
-        int (*pre_process)(void);               // Perform any pre-processing stuff (e.g. determine secure boot state)
-        int (*process)(void);                   // Process all updates
-        int (*post_process)(void);              // Perform any post-processing stuff (e.g. derive/update variables)
-        int (*validate)(struct secvar *var);    // Validate a single variable, return boolean
-        const char *compatible;			// String to use for compatible in secvar node
+	int (*pre_process)(struct list_head *variable_bank,
+			   struct list_head *update_bank);   // Perform any pre-processing stuff (e.g. determine secure boot state)
+	int (*process)(struct list_head *variable_bank,
+		       struct list_head *update_bank);       // Process all updates
+	int (*post_process)(struct list_head *variable_bank,
+			    struct list_head *update_bank);  // Perform any post-processing stuff (e.g. derive/update variables)
+	int (*validate)(struct secvar *var);		     // Validate a single variable, return boolean
+	const char *compatible;				     // String to use for compatible in secvar node
 };
 
 
diff --git a/libstb/secvar/secvar_main.c b/libstb/secvar/secvar_main.c
index f4b98925..4eb9ae66 100644
--- a/libstb/secvar/secvar_main.c
+++ b/libstb/secvar/secvar_main.c
@@ -63,7 +63,7 @@  int secvar_main(struct secvar_storage_driver storage_driver,
 	secvar_set_status("okay");
 
 	if (secvar_backend.pre_process) {
-		rc = secvar_backend.pre_process();
+		rc = secvar_backend.pre_process(&variable_bank, &update_bank);
 		if (rc) {
 			prlog(PR_ERR, "Error in backend pre_process = %d\n", rc);
 			/* Early failure state, lock the storage */
@@ -77,7 +77,7 @@  int secvar_main(struct secvar_storage_driver storage_driver,
 		goto out;
 
 	/* Process variable updates from the update bank. */
-	rc = secvar_backend.process();
+	rc = secvar_backend.process(&variable_bank, &update_bank);
 
 	/* Create and set the update-status device tree property */
 	secvar_set_update_status(rc);
@@ -106,7 +106,7 @@  int secvar_main(struct secvar_storage_driver storage_driver,
 	secvar_storage.lock();
 
 	if (secvar_backend.post_process) {
-		rc = secvar_backend.post_process();
+		rc = secvar_backend.post_process(&variable_bank, &update_bank);
 		if (rc) {
 			prlog(PR_ERR, "Error in backend post_process = %d\n", rc);
 			goto out;