ia64/xen-unstable
changeset 9116:f3661f9a95dd
VTPM_Tools: Fix error when closing only vtpm, and fix restore bug when
no dmis exist
The first bug prevented the TPM tests from running successfully more
than once in a row.
Signed-off-by: Vinnie Scarlata <vincent.r.scarlata@intel.com>
no dmis exist
The first bug prevented the TPM tests from running successfully more
than once in a row.
Signed-off-by: Vinnie Scarlata <vincent.r.scarlata@intel.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Fri Mar 03 10:46:06 2006 +0100 (2006-03-03) |
parents | 46a6d9626911 |
children | ec7802acc8c9 |
files | tools/vtpm_manager/manager/dmictl.c tools/vtpm_manager/manager/securestorage.c tools/vtpm_manager/manager/vtpm_manager.c tools/vtpm_manager/manager/vtpmpriv.h |
line diff
1.1 --- a/tools/vtpm_manager/manager/dmictl.c Fri Mar 03 10:44:40 2006 +0100 1.2 +++ b/tools/vtpm_manager/manager/dmictl.c Fri Mar 03 10:46:06 2006 +0100 1.3 @@ -74,7 +74,13 @@ TPM_RESULT close_dmi( VTPM_DMI_RESOURCE 1.4 1.5 close(dmi_res->guest_tx_fh); dmi_res->guest_tx_fh = -1; 1.6 close(dmi_res->vtpm_tx_fh); dmi_res->vtpm_tx_fh = -1; 1.7 - 1.8 + vtpm_globals->connected_dmis--; 1.9 + 1.10 + if (vtpm_globals->connected_dmis == 0) { 1.11 + // No more DMI's connected. Close fifo to prevent a broken pipe. 1.12 + close(vtpm_globals->guest_rx_fh); 1.13 + vtpm_globals->guest_rx_fh = -1; 1.14 + } 1.15 #ifndef MANUAL_DM_LAUNCH 1.16 if (dmi_res->dmi_id != VTPM_CTL_DM) { 1.17 if (dmi_res->dmi_pid != 0) { 1.18 @@ -118,6 +124,7 @@ TPM_RESULT VTPM_Handle_New_DMI( const bu 1.19 status = TPM_BAD_PARAMETER; 1.20 goto abort_egress; 1.21 } else { 1.22 + vtpm_globals->connected_dmis++; // Put this here so we don't count Dom0 1.23 BSG_UnpackList( param_buf->bytes, 3, 1.24 BSG_TYPE_BYTE, &type, 1.25 BSG_TYPE_UINT32, &domain_id,
2.1 --- a/tools/vtpm_manager/manager/securestorage.c Fri Mar 03 10:44:40 2006 +0100 2.2 +++ b/tools/vtpm_manager/manager/securestorage.c Fri Mar 03 10:46:06 2006 +0100 2.3 @@ -307,8 +307,8 @@ TPM_RESULT VTPM_SaveService(void) { 2.4 TPM_RESULT status=TPM_SUCCESS; 2.5 int fh, dmis=-1; 2.6 2.7 - BYTE *flat_boot_key, *flat_dmis, *flat_enc; 2.8 - buffer_t clear_flat_global, enc_flat_global; 2.9 + BYTE *flat_boot_key=NULL, *flat_dmis=NULL, *flat_enc=NULL; 2.10 + buffer_t clear_flat_global=NULL_BUF, enc_flat_global=NULL_BUF; 2.11 UINT32 storageKeySize = buffer_len(&vtpm_globals->storageKeyWrap); 2.12 UINT32 bootKeySize = buffer_len(&vtpm_globals->bootKeyWrap); 2.13 struct pack_buf_t storage_key_pack = {storageKeySize, vtpm_globals->storageKeyWrap.bytes}; 2.14 @@ -328,12 +328,9 @@ TPM_RESULT VTPM_SaveService(void) { 2.15 sizeof(UINT32) +// storagekeysize 2.16 storageKeySize, NULL) ); // storage key 2.17 2.18 - flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num DMIS (-1 for Dom0) 2.19 - (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info 2.20 2.21 flat_boot_key = (BYTE *) malloc( boot_key_size ); 2.22 flat_enc = (BYTE *) malloc( sizeof(UINT32) ); 2.23 - flat_dmis = (BYTE *) malloc( flat_dmis_size ); 2.24 2.25 boot_key_size = BSG_PackList(flat_boot_key, 1, 2.26 BSG_TPM_SIZE32_DATA, &boot_key_pack); 2.27 @@ -349,9 +346,13 @@ TPM_RESULT VTPM_SaveService(void) { 2.28 2.29 BSG_PackConst(buffer_len(&enc_flat_global), 4, flat_enc); 2.30 2.31 - // Per DMI values to be saved 2.32 + // Per DMI values to be saved (if any exit) 2.33 if (hashtable_count(vtpm_globals->dmi_map) > 0) { 2.34 2.35 + flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num DMIS (-1 for Dom0) 2.36 + (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info 2.37 + flat_dmis = (BYTE *) malloc( flat_dmis_size ); 2.38 + 2.39 dmi_itr = hashtable_iterator(vtpm_globals->dmi_map); 2.40 do { 2.41 dmi_res = (VTPM_DMI_RESOURCE *) hashtable_iterator_value(dmi_itr);
3.1 --- a/tools/vtpm_manager/manager/vtpm_manager.c Fri Mar 03 10:44:40 2006 +0100 3.2 +++ b/tools/vtpm_manager/manager/vtpm_manager.c Fri Mar 03 10:46:06 2006 +0100 3.3 @@ -754,6 +754,7 @@ TPM_RESULT VTPM_Init_Service() { 3.4 #ifndef VTPM_MULTI_VM 3.5 vtpm_globals->vtpm_rx_fh = -1; 3.6 vtpm_globals->guest_rx_fh = -1; 3.7 + vtpm_globals->connected_dmis = 0; 3.8 #endif 3.9 if ((vtpm_globals->dmi_map = create_hashtable(10, hashfunc32, equals32)) == NULL){ 3.10 status = TPM_FAIL;
4.1 --- a/tools/vtpm_manager/manager/vtpmpriv.h Fri Mar 03 10:44:40 2006 +0100 4.2 +++ b/tools/vtpm_manager/manager/vtpmpriv.h Fri Mar 03 10:46:06 2006 +0100 4.3 @@ -98,6 +98,7 @@ typedef struct tdVTPM_GLOBALS { 4.4 #ifndef VTPM_MULTI_VM 4.5 int vtpm_rx_fh; 4.6 int guest_rx_fh; 4.7 + int connected_dmis; // Used to close guest_rx when no dmis are connected 4.8 4.9 pid_t master_pid; 4.10 #endif