diff mbox series

[1/2] tpm: Implement firmware API call get-maximum-cmd-size

Message ID 20241023001346.2500239-2-stefanb@linux.ibm.com
State New
Headers show
Series [1/2] tpm: Implement firmware API call get-maximum-cmd-size | expand

Commit Message

Stefan Berger Oct. 23, 2024, 12:13 a.m. UTC
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 board-qemu/slof/vio-vtpm-cdriver.fs |  8 ++++++++
 lib/libtpm/tcgbios.c                |  5 +++++
 lib/libtpm/tcgbios.h                |  1 +
 lib/libtpm/tpm.code                 | 10 ++++++++++
 lib/libtpm/tpm.in                   |  1 +
 5 files changed, 25 insertions(+)
diff mbox series

Patch

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)