On 7/25/19 7:08 AM, Marc-André Lureau wrote:
Hi

On Thu, Jul 25, 2019 at 2:58 PM Stefan Berger
<[email protected]> wrote:
Implement a function to translate TPM error codes to strings so that
at least the most common error codes can be translated to human
readable strings.

Signed-off-by: Stefan Berger <[email protected]>
---
  hw/tpm/tpm_emulator.c | 50 ++++++++++++++++++++++++++++++++++---------
  1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
index 1288cbcb8d..186dde0838 100644
--- a/hw/tpm/tpm_emulator.c
+++ b/hw/tpm/tpm_emulator.c
@@ -82,6 +82,30 @@ typedef struct TPMEmulator {
      TPMBlobBuffers state_blobs;
  } TPMEmulator;

+struct tpm_error {
+    uint32_t tpm_result;
+    const char *string;
+};
+
+static const struct tpm_error tpm_errors[] = {
+    {  9 , "operation failed" },
+    {  32, "encryption error" },
+    {  33, "decryption error" },
+    /* TPM 2 codes */
+    { 0x101, "operation failed" },
+};
Wouldn't those codes be better defined in tpm_ioctl.h?

tpm_int.h has some already. will add some more there.


Stefan



Reply via email to