Hi.

Some updates.

I fixed one of the failed test on s390x.
https://github.com/tpm2-software/tpm2-tss/pull/2675
So now libtpms tests passed. (test/unit/tcti-libtpms).

The problem here is that it tries to make a call to libtpms but passing (size_t 
*) to (uint32_t *).
That works in little-endian (if the memory are cleared to zero and alignment are padded) but not working on bit-endian (the value will be changed).

The patch is as attachment.

But there are 3 more test that needed to be fixed.
1. test/unit/fapi-eventlog
2. test/unit/tcti-spi-helper
3. test/unit/fapi-ima-eventlog

I'll find some time to fix the rest of the failure and do a single upload that fixes every s390x test failure.

Yours,
Paul
From 9ae85535d6383a50731ad9e70c16b55622e126ae Mon Sep 17 00:00:00 2001
From: "Ying-Chun Liu (PaulLiu)" <paul...@debian.org>
Date: Sun, 6 Aug 2023 05:24:02 +0800
Subject: [PATCH] tss2-tcti: tcti-libtpms: fix test failure on big-endian
 platform

Due to tcti_libtpms->response_len and tcti_libtpms->response_buffer_len
are size_t. We cannot convert the (size_t *) to (uint32_t *) on big-endian
platforms. Thus we create temp uint32_t variables. Make the call and
then assign it back to size_t variables.

This commit partially fix the test failure on big-endian platforms.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paul...@debian.org>
---
 src/tss2-tcti/tcti-libtpms.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/tss2-tcti/tcti-libtpms.c b/src/tss2-tcti/tcti-libtpms.c
index 922a4402..10ed913d 100644
--- a/src/tss2-tcti/tcti-libtpms.c
+++ b/src/tss2-tcti/tcti-libtpms.c
@@ -370,6 +370,8 @@ tcti_libtpms_transmit(
     tpm_header_t header;
     TSS2_RC rc;
     TPM_RESULT ret;
+    uint32_t resp_size;
+    uint32_t respbufsize;
 
     rc = tcti_common_transmit_checks(tcti_common, cmd_buf, TCTI_LIBTPMS_MAGIC);
     if (rc != TSS2_RC_SUCCESS) {
@@ -386,11 +388,16 @@ tcti_libtpms_transmit(
     }
 
     LOGBLOB_DEBUG(cmd_buf, size, "Sending command with TPM_CC 0x%" PRIx32, header.size);
+    resp_size = (uint32_t) tcti_libtpms->response_len;
+    respbufsize = (uint32_t) tcti_libtpms->response_buffer_len;
     LIBTPMS_API_CALL(fail, tcti_libtpms, TPMLIB_Process, &tcti_libtpms->response_buffer,
-                                                         (uint32_t *) &tcti_libtpms->response_len,
-                                                         (uint32_t *) &tcti_libtpms->response_buffer_len,
+                                                         (uint32_t *) &resp_size,
+                                                         (uint32_t *) &respbufsize,
                                                          (uint8_t *) cmd_buf,
                                                          size);
+    tcti_libtpms->response_len = resp_size;
+    tcti_libtpms->response_buffer_len = respbufsize;
+
     rc = tcti_libtpms_store_state(tcti_libtpms);
     if (rc != TSS2_RC_SUCCESS) {
         LOG_ERROR("Failed to store state file");
-- 
2.40.1

Attachment: OpenPGP_0x44173FA13D058888.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to