[SLOF] [PATCH v3 17/17] Set the driver in pseudo failure state after handover
Stefan Berger
stefanb at us.ibm.com
Tue Dec 1 09:02:00 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 | 12 ++++++++++++
lib/libtpm/tcgbios.h | 1 +
lib/libtpm/tpm.code | 10 ++++++++++
lib/libtpm/tpm.in | 1 +
lib/libtpm/tpm_drivers.c | 5 +++++
lib/libtpm/tpm_drivers.h | 1 +
7 files changed, 34 insertions(+)
diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs
index 96e612d..6854697 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 BUFFER: 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 9e52d1a..388f7c6 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -221,6 +221,18 @@ uint32_t tpm_driver_get_failure_reason(void)
return spapr_vtpm_get_error();
}
+/*
+ * tpm_driver_set_failure_reason: Function for interfacing with the firmware
+ * API
+ */
+void tpm_driver_set_failure_reason(uint32_t errcode)
+{
+ if (!tpm_state.tpm_found)
+ return;
+
+ spapr_vtpm_set_error(errcode);
+}
+
static uint32_t transmit(struct tpm_req_header *req,
uint8_t *respbuffer, uint32_t *respbufferlen,
enum tpm_duration_type to_t)
diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h
index 0ddd537..e37d075 100644
--- a/lib/libtpm/tcgbios.h
+++ b/lib/libtpm/tcgbios.h
@@ -38,6 +38,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 dd08fb9..f671123 100644
--- a/lib/libtpm/tpm.code
+++ b/lib/libtpm/tpm.code
@@ -97,6 +97,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 88d8a14..3c3b745 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 f3c28ef..894a8e8 100644
--- a/lib/libtpm/tpm_drivers.c
+++ b/lib/libtpm/tpm_drivers.c
@@ -445,6 +445,11 @@ vtpm_drv_error spapr_vtpm_get_error(void)
return vtpm_drv_error_get();
}
+void spapr_vtpm_set_error(vtpm_drv_error errcode)
+{
+ spapr_vtpm.driver_error = errcode;
+}
+
/**** higher layer interface ****/
bool spapr_is_vtpm_present(void)
diff --git a/lib/libtpm/tpm_drivers.h b/lib/libtpm/tpm_drivers.h
index b89c6b0..2306f24 100644
--- a/lib/libtpm/tpm_drivers.h
+++ b/lib/libtpm/tpm_drivers.h
@@ -86,5 +86,6 @@ void spapr_vtpm_set_durations(const uint32_t durations[TPM_NUM_DURATIONS]);
uint32_t spapr_vtpm_get_buffersize(void);
vtpm_drv_state spapr_vtpm_get_state(void);
vtpm_drv_error spapr_vtpm_get_error(void);
+void spapr_vtpm_set_error(vtpm_drv_error errcode);
#endif /* TPM_DRIVERS_H */
--
2.4.3
More information about the SLOF
mailing list