tools: vtpm compile fixes
cover tools: vtpm compile fixes
Fix compilation of vtpm in mini-os and stubdom.
This is a result of the discussion in the thread "xen-unstable stubdom build-failure when debug=n".
Olaf Hering (3):
mini-os: tpm: fix array access in locality_enabled
mini-os: tpm: remove usage of inline keyword
stubdom: fix -Wextra usage in vtpm_emulator
extras/mini-os/tpm_tis.c | 2 +- extras/mini-os/tpmback.c | 8 ++++---- stubdom/Makefile | 1 + stubdom/vtpm-cmake-Wextra.patch | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 stubdom/vtpm-cmake-Wextra.patch
PATCH 1/3 mini-os: tpm: fix array access in locality_enabled
gcc-4.3 fails to prove that array indices will remain positive. Add a hint for the compiler and check the index value before using it.
--- extras/mini-os/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
extras/mini-os/tpm_tis.c +1 -1
@@ -611,7 +611,7 @@ s_time_t tpm_calc_ordinal_duration(struct tpm_chip *chip,static int locality_enabled (struct tpm_chip * tpm,int l) { -return tpm->enabled_localities & (1 << l); +return l >=0 && tpm->enabled_localities & (1 << l); }static int check_locality (struct tpm_chip * tpm,int l) {
PATCH 2/3 mini-os: tpm: remove usage of inline keyword
In reply to Olaf HeringCompilation fails with gcc-4.3:
tpmback.c: In function 'tpmback_resp':
tpmback.c:148: error: inlining failed in call to 'tpmdev_check_req': call is unlikely and code size would grow tpmback.c:165: error: called from heretpmback.c: In function 'new_tpmif':
tpmback.c:384: error: inlining failed in call to '__init_tpmif': call is unlikely and code size would grow tpmback.c:425: error: called from here
Adjust code to use static instead of inline, it has the same effect. Change also tpmif_req_ready and tpmif_req_finished before they start to cause failures.
--- extras/mini-os/tpmback.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
extras/mini-os/tpmback.c +4 -4
@@ -140,12 +140,12 @@ int globalinit = 0;* Duplicates are not allowed * **********************************/ -inline void tpmif_req_ready (tpmif_t * tpmif) { +static void tpmif_req_ready (tpmif_t * tpmif) { tpmif->flags |=TPMIF_REQ_READY ; gtpmdev.flags |=TPMIF_REQ_READY ; } -inline void tpmdev_check_req (void ) { +static void tpmdev_check_req (void ) {int i;int flags;local_irq_save (flags);
@@ -160,7 +160,7 @@ inline void tpmdev_check_req(void) {local_irq_restore (flags); } -inline void tpmif_req_finished (tpmif_t * tpmif) { +static void tpmif_req_finished (tpmif_t * tpmif) { tpmif->flags &= ~TPMIF_REQ_READY ;tpmdev_check_req (); }
@@ -382,7 +382,7 @@ int tpmif_change_state(tpmif_t* tpmif, enum xenbus_state state)/********************************** * TPMIF CREATION AND DELETION * *******************************/ -inline tpmif_t *__init_tpmif (domid_t domid,unsigned int handle) +static tpmif_t *__init_tpmif (domid_t domid,unsigned int handle) {tpmif_t * tpmif; tpmif =malloc (sizeof (*tpmif));
PATCH 3/3 stubdom: fix -Wextra usage in vtpm_emulator
In reply to Olaf HeringIf -Wextra is appended to CFLAGS it will enable all warnings. Previous options such as -Wno-unused-parameters have no effect anymore. As a result compilation will fail with gcc-4.3. Newer versions of gcc will appearently remember -Wno-* options before -Wextra. Rearrange warning options for gcc so that -Wextra comes before other -W options. This fixes compilation of stubdom in SLES11.
--- stubdom/Makefile | 1 + stubdom/vtpm-cmake-Wextra.patch | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 stubdom/vtpm-cmake-Wextra.patch
stubdom/Makefile +1 -0
@@ -210,6 +210,7 @@ tpm_emulator-$(XEN_TARGET_ARCH): tpm_emulator-$(TPMEMU_VERSION).tar.gz patch -d $@ -p1 < vtpm-locality.patch patch -d $@ -p1 < vtpm-parent-sign-ek.patch patch -d $@ -p1 < vtpm-deepquote.patch + patch -d $@ -p1 < vtpm-cmake-Wextra.patch mkdir $@/build cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement" touch $@
stubdom/vtpm-cmake-Wextra.patch new file +21 -0
@@ -0,0 +1,21 @@ +--- + CMakeLists.txt | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +Index: tpm_emulator-x86_64/CMakeLists.txt +=================================================================== +--- tpm_emulator-x86_64.orig/CMakeLists.txt ++++ tpm_emulator-x86_64/CMakeLists.txt +@@ -40,10 +40,11 @@ set(TPM_STORAGE_NAME "/var/lib/tpm/tpm_e + set(TPM_DEVICE_NAME "/dev/tpm") + endif() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +-add_definitions(-Wall -Werror -Wno-unused-parameter -Wpointer-arith -Wcast-align -Wwrite-strings) ++add_definitions(-Wall -Werror) + if("${CMAKE_SYSTEM}" MATCHES "Linux") + add_definitions(-Wextra) + endif() ++add_definitions(-Wno-unused-parameter -Wpointer-arith -Wcast-align -Wwrite-strings) + if(USE_OPENSSL) + add_definitions(-DUSE_OPENSSL) + endif()
Re: [PATCH 1/3] mini-os: tpm: fix array access in locality_enabled
In reply to Olaf HeringQuoted 4 lines · Olaf Hering, le Tue 22 Jul 2014 09:19:15 +0200, a écrit :
gcc-4.3 fails to prove that array indices will remain positive. Add a hint for the compiler and check the index value before using it.
Signed-off-by Olaf Hering <[email protected]>
Quoted 23 lines
--- extras/mini-os/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)extras/mini-os/tpm_tis.c +1
-1@@ -611,7 +611,7 @@ s_time_t tpm_calc_ordinal_duration(struct tpm_chip *chip,static int locality_enabled (struct tpm_chip * tpm,int l) { -return tpm->enabled_localities & (1 << l); +return l >=0 && tpm->enabled_localities & (1 << l); }static int check_locality (struct tpm_chip * tpm,int l) {_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 2 lines
Samuel "2 + 2 = 5 pour d'assez grandes valeurs de 2"
Re: [PATCH 3/3] stubdom: fix -Wextra usage in vtpm_emulator
In reply to Olaf HeringQuoted 8 lines · Olaf Hering, le Tue 22 Jul 2014 09:19:17 +0200, a écrit :
If -Wextra is appended to CFLAGS it will enable all warnings. Previous options such as -Wno-unused-parameters have no effect anymore. As a result compilation will fail with gcc-4.3. Newer versions of gcc will appearently remember -Wno-* options before -Wextra. Rearrange warning options for gcc so that -Wextra comes before other -W options. This fixes compilation of stubdom in SLES11.
Signed-off-by Olaf Hering <[email protected]>
Quoted 51 lines
--- stubdom/Makefile | 1 + stubdom/vtpm-cmake-Wextra.patch | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 stubdom/vtpm-cmake-Wextra.patchstubdom/Makefile +1
-0@@ -210,6 +210,7 @@ tpm_emulator-$(XEN_TARGET_ARCH): tpm_emulator-$(TPMEMU_VERSION).tar.gz patch -d $@ -p1 < vtpm-locality.patch patch -d $@ -p1 < vtpm-parent-sign-ek.patch patch -d $@ -p1 < vtpm-deepquote.patch + patch -d $@ -p1 < vtpm-cmake-Wextra.patch mkdir $@/build cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement" touch $@stubdom/vtpm-cmake-Wextra.patch new file +21
-0@@ -0,0 +1,21 @@ +--- + CMakeLists.txt | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +Index: tpm_emulator-x86_64/CMakeLists.txt +=================================================================== +--- tpm_emulator-x86_64.orig/CMakeLists.txt ++++ tpm_emulator-x86_64/CMakeLists.txt +@@ -40,10 +40,11 @@ set(TPM_STORAGE_NAME "/var/lib/tpm/tpm_e + set(TPM_DEVICE_NAME "/dev/tpm") + endif() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +-add_definitions(-Wall -Werror -Wno-unused-parameter -Wpointer-arith -Wcast-align -Wwrite-strings) ++add_definitions(-Wall -Werror) + if("${CMAKE_SYSTEM}" MATCHES "Linux") + add_definitions(-Wextra) + endif() ++add_definitions(-Wno-unused-parameter -Wpointer-arith -Wcast-align -Wwrite-strings) + if(USE_OPENSSL) + add_definitions(-DUSE_OPENSSL) + endif()_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 3 lines
Samuel <A> sauf que le firewall bloque tout sauf internet -+- ben ouais, il bloque ipx/spx ! -+-
Re: [PATCH 2/3] mini-os: tpm: remove usage of inline keyword
In reply to Olaf HeringQuoted 9 lines · Olaf Hering, le Tue 22 Jul 2014 09:19:16 +0200, a écrit :
Compilation fails with gcc-4.3:
tpmback.c: In function 'tpmback_resp':
tpmback.c:148: error: inlining failed in call to 'tpmdev_check_req': call is unlikely and code size would grow tpmback.c:165: error: called from heretpmback.c: In function 'new_tpmif':
tpmback.c:384: error: inlining failed in call to '__init_tpmif': call is unlikely and code size would grow tpmback.c:425: error: called from here
Quoted 5 lines
Adjust code to use static instead of inline, it has the same effect. Change also
tpmif_req_readyandtpmif_req_finishedbefore they start to cause failures.Signed-off-by Olaf Hering <[email protected]>
Quoted 47 lines
--- extras/mini-os/tpmback.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)extras/mini-os/tpmback.c +4
-4@@ -140,12 +140,12 @@ int globalinit = 0;* Duplicates are not allowed * **********************************/ -inline void tpmif_req_ready (tpmif_t * tpmif) { +static void tpmif_req_ready (tpmif_t * tpmif) { tpmif->flags |=TPMIF_REQ_READY ; gtpmdev.flags |=TPMIF_REQ_READY ; } -inline void tpmdev_check_req (void ) { +static void tpmdev_check_req (void ) {int i;int flags;local_irq_save (flags);@@ -160,7 +160,7 @@ inline void tpmdev_check_req(void) {local_irq_restore (flags); } -inline void tpmif_req_finished (tpmif_t * tpmif) { +static void tpmif_req_finished (tpmif_t * tpmif) { tpmif->flags &= ~TPMIF_REQ_READY ;tpmdev_check_req (); }@@ -382,7 +382,7 @@ int tpmif_change_state(tpmif_t* tpmif, enum xenbus_state state)/********************************** * TPMIF CREATION AND DELETION * *******************************/ -inline tpmif_t *__init_tpmif (domid_t domid,unsigned int handle) +static tpmif_t *__init_tpmif (domid_t domid,unsigned int handle) {tpmif_t * tpmif; tpmif =malloc (sizeof (*tpmif));_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 3 lines
Samuel void packerFlushTheToiletFirstThingInTheMorning( void* arg ) -+- chromium's source code -+-
Quoted 3 lines · Olaf Hering
Fix compilation of vtpm in mini-os and stubdom.
This is a result of the discussion in the thread "xen-unstable stubdom build-failure when debug=n".
All applied with Samuel's acks.
Ian.