Skip to contentSkip to conversation

Build: Fix stubdom vtpm build failure

PATCH Superseded Quan Xu 2 participants 4 messages Mar 14, 2015 – Mar 16, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Quan Xu

author
#0 lore raw

PATCH 1/1 Build: Fix stubdom vtpm build failure

Typedefs are duplicated in stubdom/vtpmmgr/tcg.h and supported compilers do not cope with current staging branch.

---
 stubdom/vtpmmgr/common_types.h |    9 +++++++++
 stubdom/vtpmmgr/tcg.h          |    7 +------
 stubdom/vtpmmgr/tpm2.c         |   10 +++++-----
 stubdom/vtpmmgr/tpm2.h         |    6 +++---
 stubdom/vtpmmgr/tpm2_types.h   |   42 +++++++++++++++-------------------------
 stubdom/vtpmmgr/vtpmmgr.h      |    4 ++--
 6 files changed, 36 insertions(+), 42 deletions(-)
 create mode 100644 stubdom/vtpmmgr/common_types.h
stubdom/vtpmmgr/common_types.h new file +9 -0
new file mode 100644
index 0000000..7321bb6
@@ -0,0 +1,9 @@
+#ifndef VTPM_COMMON_TYPES
+#define VTPM_COMMON_TYPES 1
+typedef unsigned char BYTE;
+typedef unsigned char BOOL;
+typedef unsigned char UINT8;
+typedef uint16_t UINT16;
+typedef uint32_t UINT32;
+typedef uint64_t UINT64;
+#endif
stubdom/vtpmmgr/tcg.h +1 -6
index 7321ec6..813ce57 100644
@@ -39,6 +39,7 @@
 
 #include <stdlib.h>
 #include <stdint.h>
+#include "common_types.h"
 
 // **************************** CONSTANTS *********************************
 
@@ -401,12 +402,6 @@
 
 
 // *************************** TYPEDEFS *********************************
-typedef unsigned char BYTE;
-typedef unsigned char BOOL;
-typedef uint16_t UINT16;
-typedef uint32_t UINT32;
-typedef uint64_t UINT64;
-
 typedef UINT32 TPM_RESULT;
 typedef UINT32 TPM_PCRINDEX;
 typedef UINT32 TPM_DIRINDEX;
stubdom/vtpmmgr/tpm2.c +5 -5
index 1903e27..c9f1016 100644
@@ -167,7 +167,7 @@ egress:
 TPM_RC TPM2_Load(TPMI_DH_OBJECT parentHandle,
                  TPM2B_PRIVATE *inPrivate, /* in */
                  TPM2B_PUBLIC *inPublic, /* in */
-                 TPM_HANDLE *objectHandle, /* out */
+                 TPM2_HANDLE *objectHandle, /* out */
                  TPM2B_NAME *name /* out */)
 {
     TPM_BEGIN(TPM_ST_SESSIONS, TPM_CC_Load);
@@ -185,7 +185,7 @@ TPM_RC TPM2_Load(TPMI_DH_OBJECT parentHandle,
     if (objectHandle != NULL) {
         ptr = unpack_TPM_HANDLE(ptr, objectHandle);
     } else {
-        TPM_HANDLE tmp;
+        TPM2_HANDLE tmp;
         ptr = unpack_TPM_HANDLE(ptr, &tmp);
     }
 
@@ -248,7 +248,7 @@ egress:
 
 TPM_RC TPM2_CreatePrimary(TPMI_RH_HIERARCHY primaryHandle,
                           TPM2_Create_Params_in *in,
-                          TPM_HANDLE *objHandle,
+                          TPM2_HANDLE *objHandle,
                           TPM2_Create_Params_out *out)
 {
     UINT32 param_size;
@@ -281,7 +281,7 @@ TPM_RC TPM2_CreatePrimary(TPMI_RH_HIERARCHY primaryHandle,
     if (objHandle != NULL)
         ptr = unpack_TPM_HANDLE(ptr, objHandle);
     else {
-        TPM_HANDLE handle;
+        TPM2_HANDLE handle;
         ptr = unpack_TPM_HANDLE(ptr, &handle);
     }
     ptr = unpack_UINT32(ptr, &param_size);
@@ -302,7 +302,7 @@ egress:
    return status;
 }
 
-TPM_RC TPM2_HierachyChangeAuth(TPMI_RH_HIERARCHY_AUTH authHandle, TPM2B_AUTH *newAuth)
+TPM_RC TPM2_HierachyChangeAuth(TPM2I_RH_HIERARCHY_AUTH authHandle, TPM2B_AUTH *newAuth)
 {
     TPM_BEGIN(TPM_ST_SESSIONS, TPM_CC_HierarchyChangeAuth);
     ptr = pack_UINT32(ptr, authHandle);
stubdom/vtpmmgr/tpm2.h +3 -3
index 9f597ee..9e01286 100644
@@ -57,7 +57,7 @@ TPM_RC TPM2_PCR_Read(TPML_PCR_SELECTION pcrSelectionIn,
 TPM_RC TPM2_Load(TPMI_DH_OBJECT parentHandle,
                  TPM2B_PRIVATE *inPrivate,
                  TPM2B_PUBLIC *inPublic,
-                 TPM_HANDLE *objectHandle,
+                 TPM2_HANDLE *objectHandle,
                  TPM2B_NAME *name);
 
 TPM_RC TPM2_Create(TPMI_DH_OBJECT parentHandle,
@@ -66,10 +66,10 @@ TPM_RC TPM2_Create(TPMI_DH_OBJECT parentHandle,
 
 TPM_RC TPM2_CreatePrimary(TPMI_RH_HIERARCHY primaryHandle,
                           TPM2_Create_Params_in *objHandle,
-                          TPM_HANDLE *in,
+                          TPM2_HANDLE *in,
                           TPM2_Create_Params_out *out);
 
-TPM_RC TPM2_HierachyChangeAuth(TPMI_RH_HIERARCHY_AUTH authHandle,
+TPM_RC TPM2_HierachyChangeAuth(TPM2I_RH_HIERARCHY_AUTH authHandle,
                                TPM2B_AUTH *newAuth);
 
 TPM_RC TPM2_RSA_ENCRYPT(TPMI_DH_OBJECT keyHandle,
stubdom/vtpmmgr/tpm2_types.h +16 -26

93 lines not on this page · raw message

stubdom/vtpmmgr/vtpmmgr.h +2 -2
index 46fd14f..2e6f8de 100644
@@ -76,8 +76,8 @@ struct vtpm_globals {
     /* TPM 2.0 */
     TPM_AuthArea       pw_auth;
     TPM_AuthArea       srk_auth_area;
-    TPM_HANDLE         srk_handle;
-    TPM_HANDLE         sk_handle;
+    TPM2_HANDLE        srk_handle;
+    TPM2_HANDLE        sk_handle;
     TPM2B_NAME         sk_name;
     TPM2_RSA_KEY       tpm2_storage_key;
 };
Signature · 1 line
1.7.10.4
author
#1 lore raw

Olaf,
Could you help me test this patch in SLE_11_SP3/openSUSE_11.4?

Quan

Quoted 256 lines

-----Original Message-----
From: Xu, Quan
Sent: Saturday, March 14, 2015 10:37 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Xu, Quan
Subject: [PATCH] Build: Fix stubdom vtpm build failure

Typedefs are duplicated in stubdom/vtpmmgr/tcg.h and supported compilers do not cope with current staging branch.

---
 stubdom/vtpmmgr/common_types.h |    9 +++++++++
 stubdom/vtpmmgr/tcg.h          |    7 +------
 stubdom/vtpmmgr/tpm2.c         |   10 +++++-----
 stubdom/vtpmmgr/tpm2.h         |    6 +++---
 stubdom/vtpmmgr/tpm2_types.h   |   42
+++++++++++++++-------------------------
 stubdom/vtpmmgr/vtpmmgr.h      |    4 ++--
 6 files changed, 36 insertions(+), 42 deletions(-)  create mode 100644

stubdom/vtpmmgr/common_types.h

(quoted diff) +0 -0

b/stubdom/vtpmmgr/common_types.h new file mode 100644 index 0000000..7321bb6

stubdom/vtpmmgr/common_types.h new file +9 -0
@@ -0,0 +1,9 @@
+#ifndef VTPM_COMMON_TYPES
+#define VTPM_COMMON_TYPES 1
+typedef unsigned char BYTE;
+typedef unsigned char BOOL;
+typedef unsigned char UINT8;
+typedef uint16_t UINT16;
+typedef uint32_t UINT32;
+typedef uint64_t UINT64;
+#endif
stubdom/vtpmmgr/tcg.h index renamed from stubdom/vtpmmgr/tcg.h +0 -0

7321ec6..813ce57 100644

stubdom/vtpmmgr/tcg.h +1 -2
@@ -39,6 +39,7 @@
 
 #include <stdlib.h>
 #include <stdint.h>
+#include "common_types.h"
 
 // **************************** CONSTANTS
 *********************************
@@ -401,12 +402,6 @@
 
 
 // *************************** TYPEDEFS
 ********************************* -typedef unsigned char BYTE;
-typedef unsigned char BOOL; -typedef uint16_t UINT16; -typedef uint32_t
 UINT32; -typedef uint64_t UINT64;
-
 typedef UINT32 TPM_RESULT;
 typedef UINT32 TPM_PCRINDEX;
 typedef UINT32 TPM_DIRINDEX;
stubdom/vtpmmgr/tpm2.c index renamed from stubdom/vtpmmgr/tpm2.c +0 -0

1903e27..c9f1016 100644

stubdom/vtpmmgr/tpm2.c +1 -1
@@ -167,7 +167,7 @@ egress:
 TPM_RC TPM2_Load(TPMI_DH_OBJECT parentHandle,
                  TPM2B_PRIVATE *inPrivate, /* in */
                  TPM2B_PUBLIC *inPublic, /* in */
-                 TPM_HANDLE *objectHandle, /* out */
+                 TPM2_HANDLE *objectHandle, /* out */
                  TPM2B_NAME *name /* out */)  {
     TPM_BEGIN(TPM_ST_SESSIONS, TPM_CC_Load); @@ -185,7 +185,7 @@
 TPM_RC TPM2_Load(TPMI_DH_OBJECT parentHandle,
     if (objectHandle != NULL) {
         ptr = unpack_TPM_HANDLE(ptr, objectHandle);
     } else {
stubdom/vtpmmgr/tpm2.c +3 -3
-        TPM_HANDLE tmp;
+        TPM2_HANDLE tmp;
         ptr = unpack_TPM_HANDLE(ptr, &tmp);
     }
@@ -248,7 +248,7 @@ egress:
 
 TPM_RC TPM2_CreatePrimary(TPMI_RH_HIERARCHY primaryHandle,
                           TPM2_Create_Params_in *in,
-                          TPM_HANDLE *objHandle,
+                          TPM2_HANDLE *objHandle,
                           TPM2_Create_Params_out *out)  {
     UINT32 param_size;
@@ -281,7 +281,7 @@ TPM_RC TPM2_CreatePrimary(TPMI_RH_HIERARCHY
 primaryHandle,
     if (objHandle != NULL)
         ptr = unpack_TPM_HANDLE(ptr, objHandle);
     else {
-        TPM_HANDLE handle;
+        TPM2_HANDLE handle;
         ptr = unpack_TPM_HANDLE(ptr, &handle);
     }
     ptr = unpack_UINT32(ptr, &param_size); @@ -302,7 +302,7 @@ egress:
    return status;

}

-TPM_RC TPM2_HierachyChangeAuth(TPMI_RH_HIERARCHY_AUTH authHandle, TPM2B_AUTH *newAuth)
+TPM_RC TPM2_HierachyChangeAuth(TPM2I_RH_HIERARCHY_AUTH authHandle,
+TPM2B_AUTH *newAuth)

 {
     TPM_BEGIN(TPM_ST_SESSIONS, TPM_CC_HierarchyChangeAuth);
     ptr = pack_UINT32(ptr, authHandle); diff --git a/stubdom/vtpmmgr/tpm2.h

b/stubdom/vtpmmgr/tpm2.h index 9f597ee..9e01286 100644

stubdom/vtpmmgr/tpm2.h +1 -1
@@ -57,7 +57,7 @@ TPM_RC TPM2_PCR_Read(TPML_PCR_SELECTION
 pcrSelectionIn,  TPM_RC TPM2_Load(TPMI_DH_OBJECT parentHandle,
                  TPM2B_PRIVATE *inPrivate,
                  TPM2B_PUBLIC *inPublic,
-                 TPM_HANDLE *objectHandle,
+                 TPM2_HANDLE *objectHandle,
                  TPM2B_NAME *name);
 
 TPM_RC TPM2_Create(TPMI_DH_OBJECT parentHandle, @@ -66,10 +66,10 @@

TPM_RC TPM2_Create(TPMI_DH_OBJECT parentHandle,

TPM_RC TPM2_CreatePrimary(TPMI_RH_HIERARCHY primaryHandle,
TPM2_Create_Params_in *objHandle,

stubdom/vtpmmgr/tpm2.h +2 -2
-                          TPM_HANDLE *in,
+                          TPM2_HANDLE *in,
                           TPM2_Create_Params_out *out);
 
-TPM_RC TPM2_HierachyChangeAuth(TPMI_RH_HIERARCHY_AUTH authHandle,
+TPM_RC TPM2_HierachyChangeAuth(TPM2I_RH_HIERARCHY_AUTH

authHandle,

                                TPM2B_AUTH *newAuth);

TPM_RC TPM2_RSA_ENCRYPT(TPMI_DH_OBJECT keyHandle, diff --git
a/stubdom/vtpmmgr/tpm2_types.h b/stubdom/vtpmmgr/tpm2_types.h index ac2830d..d2e1311 100644

stubdom/vtpmmgr/tpm2_types.h +15 -15
@@ -3,6 +3,7 @@
 
 #include <stdlib.h>
 #include <stdint.h>
+#include "common_types.h"
 
 // "implementation.h"
 // Table 212 -- Logic Values
@@ -82,14 +83,6 @@
 #define    MAX_ECC_KEY_BITS     256
 #define    MAX_ECC_KEY_BYTES    ((MAX_ECC_KEY_BITS + 7) / 8)
 
-
-typedef unsigned char BYTE;
-typedef unsigned char BOOL;
-typedef uint8_t       UINT8;
-typedef uint16_t      UINT16;
-typedef uint32_t      UINT32;
-typedef uint64_t      UINT64;
-
 // TPM2 command code
 
 typedef UINT32 TPM_CC;
@@ -216,7 +209,7 @@ typedef UINT16 TPM_ST;
 
 
 // TPM Handle types
-typedef UINT32 TPM_HANDLE;
+typedef UINT32 TPM2_HANDLE;
 typedef UINT8 TPM_HT;
 
 
@@ -261,50 +254,47 @@ typedef BYTE TPMA_LOCALITY;  // Table 37 --
 TPMI_YES_NO Type <I/O>  typedef BYTE TPMI_YES_NO;
 
-typedef TPM_HANDLE TPMI_RH_HIERARCHY_AUTH;
-
 // Table 38 -- TPMI_DH_OBJECT Type <I/O> -typedef TPM_HANDLE
 TPMI_DH_OBJECT;
+typedef TPM2_HANDLE TPMI_DH_OBJECT;
 
 // Table 39 -- TPMI_DH_PERSISTENT Type <I/O> -typedef TPM_HANDLE
 TPMI_DH_PERSISTENT;
+typedef TPM2_HANDLE TPMI_DH_PERSISTENT;
 
 // Table 42 -- TPMI_SH_AUTH_SESSION Type <I/O> -typedef TPM_HANDLE
 TPMI_SH_AUTH_SESSION;
+typedef TPM2_HANDLE TPMI_SH_AUTH_SESSION;
 
 // Table 40 -- TPMI_DH_ENTITY Type <I>
-typedef TPM_HANDLE TPMI_DH_ENTITY;
+typedef TPM2_HANDLE TPMI_DH_ENTITY;
 
 // Table 45 -- TPMI_DH_CONTEXT Type <I/O> -typedef TPM_HANDLE
 TPMI_DH_CONTEXT;
+typedef TPM2_HANDLE TPMI_DH_CONTEXT;
 
 // Table 46 -- TPMI_RH_HIERARCHY Type <I/O> -typedef TPM_HANDLE
 TPMI_RH_HIERARCHY;
+typedef TPM2_HANDLE TPMI_RH_HIERARCHY;
 
-// Table 47 -- TPMI_RH_HIERARCHY_AUTH Type <I> -typedef TPM_HANDLE
 TPMI_RH_HIERARCHY_AUTH;
+// Table 47 -- TPM2I_RH_HIERARCHY_AUTH Type <I> typedef TPM2_HANDLE
+TPM2I_RH_HIERARCHY_AUTH;
 
 // Table 48 -- TPMI_RH_PLATFORM Type <I> -typedef TPM_HANDLE
 TPMI_RH_PLATFORM;
+typedef TPM2_HANDLE TPMI_RH_PLATFORM;
 
 // Table 49 -- TPMI_RH_OWNER Type <I>
-typedef TPM_HANDLE TPMI_RH_OWNER;
+typedef TPM2_HANDLE TPMI_RH_OWNER;
 
 // Table 50 -- TPMI_RH_ENDORSEMENT Type <I> -typedef TPM_HANDLE
 TPMI_RH_ENDORSEMENT;
+typedef TPM2_HANDLE TPMI_RH_ENDORSEMENT;
 
 // Table 51 -- TPMI_RH_PROVISION Type <I> -typedef TPM_HANDLE
 TPMI_RH_PROVISION;
+typedef TPM2_HANDLE TPMI_RH_PROVISION;
 
 // Table 52 -- TPMI_RH_CLEAR Type <I>
-typedef TPM_HANDLE TPMI_RH_CLEAR;
+typedef TPM2_HANDLE TPMI_RH_CLEAR;
 
 // Table 54 -- TPMI_RH_LOCKOUT Type <I> -typedef TPM_HANDLE

TPMI_RH_LOCKOUT;

stubdom/vtpmmgr/tpm2_types.h +1 -1
+typedef TPM2_HANDLE TPMI_RH_LOCKOUT;
 
 // Table 7 -- TPM_ALG_ID
 typedef UINT16 TPM_ALG_ID;
-typedef UINT16 TPM_ALG_ID;
 
 #define    TPM2_ALG_ERROR             (TPM_ALG_ID)(0x0000) // a: ; D:
 #define    TPM2_ALG_FIRST             (TPM_ALG_ID)(0x0001) // a: ; D:
stubdom/vtpmmgr/vtpmmgr.h +2 -3
index 46fd14f..2e6f8de 100644
@@ -76,8 +76,8 @@ struct vtpm_globals {
     /* TPM 2.0 */
     TPM_AuthArea       pw_auth;
     TPM_AuthArea       srk_auth_area;
-    TPM_HANDLE         srk_handle;
-    TPM_HANDLE         sk_handle;
+    TPM2_HANDLE        srk_handle;
+    TPM2_HANDLE        sk_handle;
     TPM2B_NAME         sk_name;
     TPM2_RSA_KEY       tpm2_storage_key;
 };
--

1.7.10.4

#2 lore raw
In reply to Quan Xu
Quoted 2 lines · Quan Xu

Typedefs are duplicated in stubdom/vtpmmgr/tcg.h and supported compilers do not cope with current staging branch.

What remains after applying this patch is this error:

[ 665s] tpm2_types.h:229:19: error: redefinition of typedef 'TPM_ALGORITHM_ID' [ 665s] tcg.h:420:16: note: previous declaration of 'TPM_ALGORITHM_ID' was here

Olaf

author
#3 lore raw

Thanks Olaf.
I will continue to send out v2 to fix it. I will change from 'TPM_ALGORITHM_ID' to 'TPM2_ALGORITHM_ID'.

Quan

Quoted 21 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Monday, March 16, 2015 5:16 PM
To: Xu, Quan
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Build: Fix stubdom vtpm build failure

Quoted 2 lines · Quan Xu

Typedefs are duplicated in stubdom/vtpmmgr/tcg.h and supported compilers do not cope with current staging branch.

What remains after applying this patch is this error:

[ 665s] tpm2_types.h:229:19: error: redefinition of typedef 'TPM_ALGORITHM_ID'
[ 665s] tcg.h:420:16: note: previous declaration of 'TPM_ALGORITHM_ID' was here

Olaf