[SLOF] [PATCH v2 19/20] Set the driver in pseudo failure state after handover
Stefan Berger
stefanb at us.ibm.com
Wed Nov 18 04:02:35 AEDT 2015
From: Stefan Berger <stefanb at linux.vnet.ibm.com>
One sml-handover has been called, set the driver into
pseudo failure state.
Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
---
board-qemu/slof/vtpm-sml.fs | 4 ++++
lib/libtpm/tcgbios.c | 14 ++++++++++++++
lib/libtpm/tcgbios.h | 1 +
lib/libtpm/tpm.code | 10 ++++++++++
lib/libtpm/tpm.in | 1 +
lib/libtpm/tpm_drivers.c | 6 ++++++
lib/libtpm/tpm_drivers.h | 1 +
7 files changed, 37 insertions(+)
diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs
index f19676c..9e5523e 100644
--- a/board-qemu/slof/vtpm-sml.fs
+++ b/board-qemu/slof/vtpm-sml.fs
@@ -20,6 +20,8 @@ false VALUE vtpm-debug?
0 VALUE log-base
40000 CONSTANT LOG-SIZE \ 256k per VTPM FW spec.
+e CONSTANT VTPM_DRV_ERROR_SML_HANDED_OVER
+
LOG-SIZE alloc-mem to log-base
\ create /ibm,vtpm
@@ -50,6 +52,8 @@ log-base LOG-SIZE tpm-set-log-parameters
log-base ( dest size src )
-rot ( src dest size )
move
+
+ VTPM_DRV_ERROR_SML_HANDED_OVER tpm-driver-set-failure-reason
;
: get-state ( -- state )
diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index c404410..1f2d4ff 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -1610,3 +1610,17 @@ uint32_t tpm_driver_get_failure_reason(void)
return td->geterror();
}
+
+/*
+ * tpm_driver_set_failure_reason: Function for interfacing with the firmware
+ * API
+ */
+void tpm_driver_set_failure_reason(uint32_t errcode)
+{
+ struct tpm_driver *td = tpm_state.tpm_drv;
+
+ if (!td)
+ return;
+
+ td->seterror(errcode);
+}
diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h
index 5bd8ab4..eb8c03f 100644
--- a/lib/libtpm/tcgbios.h
+++ b/lib/libtpm/tcgbios.h
@@ -45,6 +45,7 @@ uint32_t tpm_get_maximum_cmd_size(void);
uint32_t tpm_pass_through_to_tpm(unsigned char *buf, uint32_t cmdlen);
uint32_t tpm_driver_get_state(void);
uint32_t tpm_driver_get_failure_reason(void);
+void tpm_driver_set_failure_reason(uint32_t errcode);
/* flags returned by tpm_get_state */
#define TPM_STATE_ENABLED 1
diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code
index ee6e81c..2ee31ef 100644
--- a/lib/libtpm/tpm.code
+++ b/lib/libtpm/tpm.code
@@ -173,6 +173,16 @@ PRIM(tpm_X2d_driver_X2d_get_X2d_failure_X2d_reason)
TOS.n = tpm_driver_get_failure_reason();
MIRP
+/********************************************************/
+/* Firmware API */
+/* SLOF: tpm-driver-set-failure_reason ( errcode -- ) */
+/* LIBTPM: tpm_driver_set_failure_reason(errcode) */
+/********************************************************/
+PRIM(tpm_X2d_driver_X2d_set_X2d_failure_X2d_reason)
+ int errcode = TOS.u; POP;
+ tpm_driver_set_failure_reason(errcode);
+MIRP
+
/*****************************************************************/
/* Firmware API */
/* SLOF: tpm-hash-all ( data-ptr data-len hash-ptr -- errcode) */
diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in
index 797a49e..5ca0a79 100644
--- a/lib/libtpm/tpm.in
+++ b/lib/libtpm/tpm.in
@@ -31,3 +31,4 @@ cod(tpm-get-maximum-cmd-size)
cod(tpm-pass-through-to-tpm)
cod(tpm-driver-get-state)
cod(tpm-driver-get-failure-reason)
+cod(tpm-driver-set-failure-reason)
diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c
index 900ba38..865a34c 100644
--- a/lib/libtpm/tpm_drivers.c
+++ b/lib/libtpm/tpm_drivers.c
@@ -474,6 +474,11 @@ static vtpm_drv_error spapr_vtpm_get_error(void)
return vtpm_drv_error_get();
}
+static void spapr_vtpm_set_error(vtpm_drv_error errcode)
+{
+ spapr_vtpm.driver_error = errcode;
+}
+
/**** driver structures ****/
struct tpm_driver tpm_drivers[TPM_NUM_DRIVERS] = {
@@ -491,5 +496,6 @@ struct tpm_driver tpm_drivers[TPM_NUM_DRIVERS] = {
.getbuffersize = spapr_vtpm_get_buffersize,
.getstate = spapr_vtpm_get_state,
.geterror = spapr_vtpm_get_error,
+ .seterror = spapr_vtpm_set_error,
},
};
diff --git a/lib/libtpm/tpm_drivers.h b/lib/libtpm/tpm_drivers.h
index 0e81762..dc6c528 100644
--- a/lib/libtpm/tpm_drivers.h
+++ b/lib/libtpm/tpm_drivers.h
@@ -89,6 +89,7 @@ struct tpm_driver {
uint32_t (*getbuffersize)(void);
vtpm_drv_state (*getstate)(void);
vtpm_drv_error (*geterror)(void);
+ void (*seterror) (vtpm_drv_error errcode);
};
/* the max. buffer size by the external TPM is 4k */
--
2.4.3
More information about the SLOF
mailing list