[Skiboot] [PATCH v2 05/14] libstb: rename rom_driver_ops struct to container_verification_code
Claudio Carvalho
cclaudio at linux.vnet.ibm.com
Thu Aug 31 17:24:36 AEST 2017
This just gives a better name to the rom_driver_ops structure.
Signed-off-by: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>
---
libstb/drivers/romcode.c | 4 ++--
libstb/drivers/sw_driver.c | 4 ++--
libstb/rom.c | 22 +++++++++++-----------
libstb/rom.h | 6 +++---
libstb/stb.c | 22 ++++++++++------------
5 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/libstb/drivers/romcode.c b/libstb/drivers/romcode.c
index 94bd42c..68f1230 100644
--- a/libstb/drivers/romcode.c
+++ b/libstb/drivers/romcode.c
@@ -81,7 +81,7 @@ static void romcode_cleanup(void) {
hw_key_hash = NULL;
}
-static struct rom_driver_ops romcode_driver = {
+static struct container_verification_code c1vc = {
.name = DRIVER_NAME,
.verify = romcode_verify,
.sha512 = romcode_sha512,
@@ -134,5 +134,5 @@ void romcode_probe(const struct dt_node *node)
* the ROM code or set the memory region as executable.
* skiboot accesses the physical memory directly. Real mode.
*/
- rom_set_driver(&romcode_driver);
+ rom_set_driver(&c1vc);
}
diff --git a/libstb/drivers/sw_driver.c b/libstb/drivers/sw_driver.c
index e7f3740..55224a2 100644
--- a/libstb/drivers/sw_driver.c
+++ b/libstb/drivers/sw_driver.c
@@ -44,7 +44,7 @@ static void stb_software_cleanup(void)
return;
}
-static struct rom_driver_ops sw_driver = {
+static struct container_verification_code c1vc = {
.name = "software",
.verify = stb_software_verify,
.sha512 = stb_software_sha512,
@@ -72,5 +72,5 @@ void stb_software_probe(const struct dt_node *node)
}
hw_key_hash = (sha2_hash_t*) dt_prop_get(node, "hw-key-hash");
- rom_set_driver(&sw_driver);
+ rom_set_driver(&c1vc);
}
diff --git a/libstb/rom.c b/libstb/rom.c
index 5f9abd2..27b65c9 100644
--- a/libstb/rom.c
+++ b/libstb/rom.c
@@ -19,37 +19,37 @@
#include "drivers/romcode.h"
#include "drivers/sw_driver.h"
-static struct rom_driver_ops *rom_driver = NULL;
+static struct container_verification_code *c1vc = NULL;
-struct rom_driver_ops* rom_init(const struct dt_node *node __unused)
+struct container_verification_code* rom_init(const struct dt_node *node __unused)
{
- if (rom_driver)
+ if (c1vc)
goto end;
/* ROM drivers supported */
romcode_probe(node);
- if (!rom_driver)
+ if (!c1vc)
stb_software_probe(node);
- if (!rom_driver)
+ if (!c1vc)
prlog(PR_NOTICE, "ROM: no rom driver found\n");
end:
- return rom_driver;
+ return c1vc;
}
-void rom_set_driver(struct rom_driver_ops *driver)
+void rom_set_driver(struct container_verification_code *driver)
{
- if (rom_driver) {
+ if (c1vc) {
/**
* @fwts-label ROMAlreadyRegistered
* @fwts-advice ibm,secureboot already registered. Check if
* rom_init called twice or the same driver is probed twice
*/
prlog(PR_WARNING, "ROM: %s driver already registered\n",
- driver->name);
+ c1vc->name);
return;
}
- rom_driver = driver;
- prlog(PR_NOTICE, "ROM: %s driver registered\n", driver->name);
+ c1vc = driver;
+ prlog(PR_NOTICE, "ROM: %s driver registered\n", c1vc->name);
}
diff --git a/libstb/rom.h b/libstb/rom.h
index e1a7497..972a19b 100644
--- a/libstb/rom.h
+++ b/libstb/rom.h
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include "container.h"
-struct rom_driver_ops {
+struct container_verification_code {
const char* name;
int (*verify)(void *container);
void (*sha512)(const uint8_t *data, size_t len, uint8_t *digest);
@@ -33,11 +33,11 @@ struct rom_driver_ops {
* Load a compatible driver to access the functions of the
* verification code flashed in the secure ROM
*/
-extern struct rom_driver_ops* rom_init(const struct dt_node *node);
+extern struct container_verification_code* rom_init(const struct dt_node *node);
/*
* Set the rom driver that will be used
*/
-extern void rom_set_driver(struct rom_driver_ops *driver);
+extern void rom_set_driver(struct container_verification_code *driver);
#endif /* __ROM_H */
diff --git a/libstb/stb.c b/libstb/stb.c
index ed34c6a..eb77038 100644
--- a/libstb/stb.c
+++ b/libstb/stb.c
@@ -32,7 +32,7 @@
static bool secure_mode = false;
static bool trusted_mode = false;
-static struct rom_driver_ops *rom_driver = NULL;
+static struct container_verification_code *c1vc = NULL;
/*
* This maps a PCR for each resource we can measure. The PCR number is
@@ -124,8 +124,8 @@ void stb_init(void)
if (!secure_mode && !trusted_mode)
return;
- rom_driver = rom_init(ibm_secureboot);
- if (secure_mode && !rom_driver) {
+ c1vc = rom_init(ibm_secureboot);
+ if (secure_mode && !c1vc) {
prlog(PR_EMERG, "STB: compatible romcode driver not found\n");
sb_enforce();
}
@@ -167,9 +167,8 @@ int stb_final(void)
}
tpm_add_status_property();
}
- if (rom_driver) {
- rom_driver->cleanup();
- rom_driver = NULL;
+ if (c1vc) {
+ c1vc = NULL;
}
tpm_cleanup();
secure_mode = false;
@@ -235,9 +234,8 @@ int tb_measure(enum resource_id id, void *buf, size_t len)
abort();
}
- rom_driver->sha512(
- (void*)((uint8_t*)buf + SECURE_BOOT_HEADERS_SIZE),
- len - SECURE_BOOT_HEADERS_SIZE, digest);
+ c1vc->sha512((void*) buf + SECURE_BOOT_HEADERS_SIZE,
+ len - SECURE_BOOT_HEADERS_SIZE, digest);
prlog(PR_INFO, "STB: %s sha512 hash re-calculated\n", name);
if (memcmp(digestp, digest, TPM_ALG_SHA256_SIZE) != 0) {
@@ -251,7 +249,7 @@ int tb_measure(enum resource_id id, void *buf, size_t len)
abort();
}
} else {
- rom_driver->sha512(buf, len, digest);
+ c1vc->sha512(buf, len, digest);
prlog(PR_INFO, "STB: %s sha512 hash calculated\n", name);
}
@@ -287,7 +285,7 @@ int sb_verify(enum resource_id id, void *buf, size_t len)
"resource_id=%d unknown\n", id);
sb_enforce();
}
- if (!rom_driver || !rom_driver->verify) {
+ if (!c1vc || !c1vc->verify) {
prlog(PR_EMERG, "STB: secure boot not initialized\n");
sb_enforce();
}
@@ -296,7 +294,7 @@ int sb_verify(enum resource_id id, void *buf, size_t len)
__func__, id, buf, len);
sb_enforce();
}
- if (rom_driver->verify(buf)) {
+ if (c1vc->verify(buf)) {
prlog(PR_EMERG, "STB: %s failed: resource %s, "
"eyecatcher 0x%016llx\n", __func__, name,
*((uint64_t*)buf));
--
2.7.4
More information about the Skiboot
mailing list