aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.ibm.com>2024-10-29 08:49:33 -0400
committerAlexey Kardashevskiy <aik@ozlabs.ru>2024-11-06 14:48:54 +1100
commit4ef07b9071a8601457ac7a55c981a69e03c5ea06 (patch)
tree5c120828f3f8f29d9d678f6ee8419d49a7717edb
parent2451d058b3261939f106f6e26da99ef86384c574 (diff)
downloadSLOF-4ef07b9071a8601457ac7a55c981a69e03c5ea06.zip
SLOF-4ef07b9071a8601457ac7a55c981a69e03c5ea06.tar.gz
SLOF-4ef07b9071a8601457ac7a55c981a69e03c5ea06.tar.bz2
tpm: Implement firmware API call get-maximum-cmd-size
Implement the firmware API call get-maximum-cmd-size that returns a TPM's maximum command size. The caller should use the size returned by this function to allocate a buffer large enough for TPM commands and also responses. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
-rw-r--r--board-qemu/slof/vio-vtpm-cdriver.fs8
-rw-r--r--lib/libtpm/tcgbios.c5
-rw-r--r--lib/libtpm/tcgbios.h1
-rw-r--r--lib/libtpm/tpm.code10
-rw-r--r--lib/libtpm/tpm.in1
5 files changed, 25 insertions, 0 deletions
diff --git a/board-qemu/slof/vio-vtpm-cdriver.fs b/board-qemu/slof/vio-vtpm-cdriver.fs
index df966a2..21c2190 100644
--- a/board-qemu/slof/vio-vtpm-cdriver.fs
+++ b/board-qemu/slof/vio-vtpm-cdriver.fs
@@ -57,6 +57,14 @@ LOG-SIZE BUFFER: log-base
THEN
;
+\ firmware API call
+: get-maximum-cmd-size ( -- max-size )
+ vtpm-debug? IF
+ ." Call to get-maximum-cmd-size" cr
+ THEN
+ tpm-get-maximum-cmd-size ( max-size )
+;
+
0 0 s" ibm,sml-efi-reformat-supported" property
\ firmware API call
diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index aefa865..a64afde 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -967,6 +967,11 @@ uint32_t tpm_2hash_ext_log(uint32_t pcrindex,
return 0; // FALSE
}
+uint32_t tpm_get_maximum_cmd_size(void)
+{
+ return PAPR_VTPM_MAX_BUFFER_SIZE;
+}
+
/*
* Add an EV_ACTION measurement to the list of measurements
*/
diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h
index 021e219..83148e0 100644
--- a/lib/libtpm/tcgbios.h
+++ b/lib/libtpm/tcgbios.h
@@ -41,5 +41,6 @@ uint32_t tpm_2hash_ext_log(uint32_t pcrindex,
uint32_t eventtype,
const char *info, uint32_t infolen,
const void *data, uint64_t datalen);
+uint32_t tpm_get_maximum_cmd_size(void);
#endif /* TCGBIOS_H */
diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code
index f5e1d39..23075b8 100644
--- a/lib/libtpm/tpm.code
+++ b/lib/libtpm/tpm.code
@@ -206,3 +206,13 @@ PRIM(tpm_X2d_2hash_X2d_ext_X2d_log)
info, infolen,
data, datalen);
MIRP
+
+/****************************************************************************************/
+/* Firmware API */
+/* SLOF: tpm-get-maximum-cmd-size ( -- max-size ) */
+/* LIBTPM: maxsize = tpm-get-maximum-cmd-size */
+/****************************************************************************************/
+PRIM(tpm_X2d_get_X2d_maximum_X2d_cmd_X2d_size)
+ PUSH;
+ TOS.u = tpm_get_maximum_cmd_size();
+MIRP
diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in
index 2f80624..d76c479 100644
--- a/lib/libtpm/tpm.in
+++ b/lib/libtpm/tpm.in
@@ -30,3 +30,4 @@ cod(tpm-gpt-add-entry)
cod(tpm-measure-gpt)
cod(tpm-hash-log-extend-event-buffer)
cod(tpm-2hash-ext-log)
+cod(tpm-get-maximum-cmd-size)