Skip to contentSkip to conversation

re-send:Fix vTPM function in HVM domain

PATCH New Kouichi Yasaki 2 participants 4 messages Sep 18, 2007 – Dec 20, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 re-send:Fix vTPM function in HVM domain

Hi,

In Windows on HVM domain, GetPubkey function and Seal function become an error. Attached is a patch that fixes the error.

In this patch, I use tpm-emulator0.5 code that fixed this bug.

Thanks
Kouichi YASAKI

tools/vtpm/tpm_emulator.patch +29 -3
diff -r 9071521d4864 tools/vtpm/tpm_emulator.patch
@@ -547,10 +547,31 @@ diff -uprN orig/tpm_emulator-0.4/README 
  Installation
  --------------------------------------------------------------------------
  The compilation and installation process uses the build environment for 
+diff -uprN orig/tpm_emulator-0.4/tpm/tpm_cmd_handler.c tpm_emulator/tpm/tpm_cmd_handler.c
+--- orig/tpm_emulator-0.4/tpm/tpm_cmd_handler.c	2006-06-23 19:37:07.000000000 +0900
++++ tpm_emulator/tpm/tpm_cmd_handler.c	2007-09-12 20:23:00.000000000 +0900
+@@ -565,7 +565,7 @@ static TPM_RESULT execute_TPM_Seal(TPM_R
+   if (tpm_unmarshal_TPM_KEY_HANDLE(&ptr, &len, &keyHandle)
+       || tpm_unmarshal_TPM_ENCAUTH(&ptr, &len, &encAuth)
+       || tpm_unmarshal_UINT32(&ptr, &len, &pcrInfoSize)
+-      || tpm_unmarshal_TPM_PCR_INFO(&ptr, &len, &pcrInfo)
++      || (pcrInfoSize >0 && tpm_unmarshal_TPM_PCR_INFO(&ptr, &len, &pcrInfo))
+       || tpm_unmarshal_UINT32(&ptr, &len, &inDataSize)
+       || tpm_unmarshal_BLOB(&ptr, &len, &inData, inDataSize)
+       || len != 0) return TPM_BAD_PARAMETER;
+@@ -798,7 +798,7 @@ static TPM_RESULT execute_TPM_Sealx(TPM_
+   if (tpm_unmarshal_TPM_KEY_HANDLE(&ptr, &len, &keyHandle)
+       || tpm_unmarshal_TPM_ENCAUTH(&ptr, &len, &encAuth)
+       || tpm_unmarshal_UINT32(&ptr, &len, &pcrInfoSize)
+-      || tpm_unmarshal_TPM_PCR_INFO(&ptr, &len, &pcrInfo)
++      || (pcrInfoSize > 0 && tpm_unmarshal_TPM_PCR_INFO(&ptr, &len, &pcrInfo))
+       || tpm_unmarshal_UINT32(&ptr, &len, &inDataSize)
+       || tpm_unmarshal_BLOB(&ptr, &len, &inData, inDataSize)
+       || len != 0) return TPM_BAD_PARAMETER;
 diff -uprN orig/tpm_emulator-0.4/tpm/tpm_credentials.c tpm_emulator/tpm/tpm_credentials.c
---- orig/tpm_emulator-0.4/tpm/tpm_credentials.c	2006-06-23 03:37:07.000000000 -0700
-+++ tpm_emulator/tpm/tpm_credentials.c	2006-07-24 14:35:35.000000000 -0700
-@@ -47,16 +47,16 @@ int tpm_compute_pubkey_checksum(TPM_NONC
+--- orig/tpm_emulator-0.4/tpm/tpm_credentials.c	2006-06-23 19:37:07.000000000 +0900
++++ tpm_emulator/tpm/tpm_credentials.c	2007-09-12 20:23:30.000000000 +0900
+@@ -47,20 +47,20 @@ int tpm_compute_pubkey_checksum(TPM_NONC
  
  TPM_RESULT tpm_get_pubek(TPM_PUBKEY *pubEndorsementKey)
  {
@@ -572,6 +593,11 @@ diff -uprN orig/tpm_emulator-0.4/tpm/tpm
    pubEndorsementKey->algorithmParms.algorithmID = TPM_ALG_RSA;
    pubEndorsementKey->algorithmParms.encScheme = TPM_ES_RSAESOAEP_SHA1_MGF1;
    pubEndorsementKey->algorithmParms.sigScheme = TPM_SS_NONE;
+-  pubEndorsementKey->algorithmParms.parms.rsa.keyLength = key_length;
++  pubEndorsementKey->algorithmParms.parms.rsa.keyLength = key_length << 3;
+   pubEndorsementKey->algorithmParms.parms.rsa.numPrimes = 2;
+   pubEndorsementKey->algorithmParms.parms.rsa.exponentSize = 0;
+   pubEndorsementKey->algorithmParms.parms.rsa.exponent = NULL;
 @@ -175,6 +175,7 @@ TPM_RESULT TPM_OwnerReadInternalPub(TPM_
  {
    TPM_RESULT res;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

PATCH 1/1 Fix TPMD and QEMU connection

Hi,

In HVM domain, MA_Transmit function in tcgbios sometimes become an error (TCG_NO_RESPONSE). The cause of the error is not to make connection of QEMU and TPMD instance within a timeout of MA_Transmit function.

Before the MA_Transmit function was called, the attached patch corrected so that connection of QEMU and TPMD might be completed.

Thanks
Kouichi YASAKI

tools/ioemu/hw/tpm_tis.c +4 -0
diff -r d9ab9eb2bfee tools/ioemu/hw/tpm_tis.c
@@ -904,6 +904,10 @@ void tpm_tis_init(SetIRQFunc *set_irq, v
     memset(s->buffer.buf,0,sizeof(s->buffer.buf));
 
     register_savevm("tpm-tis", 0, 1, tpm_save, tpm_load, s);
+
+    while(!IS_COMM_WITH_VTPM(s)){
+       open_vtpm_channel(s);
+    }
 }
 
 /****************************************************************************/

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Re: [PATCH][BIOS]Fix TPMD and QEMU connection

[email protected] wrote on 12/19/2007 07:53:11 PM:

Quoted 7 lines

Hi,

In HVM domain, MA_Transmit function in tcgbios sometimes become an error (TCG_NO_RESPONSE). The cause of the error is not to make connection of QEMU and TPMD instance within a timeout of MA_Transmit function.

Before the MA_Transmit function was called, the attached patch corrected

so

Quoted 11 lines

that connection of QEMU and TPMD might be completed.

Thanks
Kouichi YASAKI

diff -r d9ab9eb2bfee tools/ioemu/hw/tpm_tis.c

tools/ioemu/hw/tpm_tis.c Mon Dec 17 19:46:42 2007 +0900 void tpm_tis_init(SetIRQFunc *set_irq, v · line 911

Quoted 8 lines
tools/ioemu/hw/tpm_tis.c Mon Dec 17 19:46:42 2007 +0900 renamed from tools/ioemu/hw/tpm_tis.c Sat Dec 15 18:29:27 2007 +0000 +4 -0
@@ -904,6 +904,10 @@ void tpm_tis_init(SetIRQFunc *set_irq, v
     memset(s->buffer.buf,0,sizeof(s->buffer.buf));
 
     register_savevm("tpm-tis", 0, 1, tpm_save, tpm_load, s);
+
+    while(!IS_COMM_WITH_VTPM(s)){
+       open_vtpm_channel(s);
+    }
 }

I'll have a look at this. The problem probably stems from the vTPM manager starting the vTPM up too late while qemu is already up and running, so it's a timing problem between the two processes. I don't think it should try to connect endlessly in a busy loop. At least there should be a counter that tries this for maybe 5 times followed by a [u]sleep() in the loop.

    int ctr = 0;
    while(!IS_COMM_WITH_VTPM(s) && ctr < 5){
       open_vtpm_channel(s);
       ctr ++;
       sleep(1);
    }

Stefan

Quoted 3 lines

/****************************************************************************/

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw

Re: [PATCH][BIOS]Fix TPMD and QEMU connection

Hi Stefan-san,

Thank you for correcting my patch.
I also think that it should not try to connect endlessly in a busy loop.

attached file is the corrected patch.

Thanks
Kouichi YASAKI

Quoted 41 lines

[email protected] wrote on 12/19/2007 07:53:11 PM:

Quoted 7 lines

Hi,

In HVM domain, MA_Transmit function in tcgbios sometimes become an error (TCG_NO_RESPONSE). The cause of the error is not to make connection of QEMU and TPMD instance within a timeout of MA_Transmit function.

Before the MA_Transmit function was called, the attached patch

corrected so

Quoted 11 lines

that connection of QEMU and TPMD might be completed.

Thanks
Kouichi YASAKI

diff -r d9ab9eb2bfee tools/ioemu/hw/tpm_tis.c

tools/ioemu/hw/tpm_tis.c Mon Dec 17 19:46:42 2007 +0900 void tpm_tis_init(SetIRQFunc *set_irq, v · line 911

Quoted 8 lines
tools/ioemu/hw/tpm_tis.c Mon Dec 17 19:46:42 2007 +0900 renamed from tools/ioemu/hw/tpm_tis.c Sat Dec 15 18:29:27 2007 +0000 +4 -0
@@ -904,6 +904,10 @@ void tpm_tis_init(SetIRQFunc *set_irq, v
     memset(s->buffer.buf,0,sizeof(s->buffer.buf));
 
     register_savevm("tpm-tis", 0, 1, tpm_save, tpm_load, s);
+
+    while(!IS_COMM_WITH_VTPM(s)){
+       open_vtpm_channel(s);
+    }
 }

I'll have a look at this. The problem probably stems from the vTPM manager starting the vTPM up too late while qemu is already up and running, so it's a timing problem between the two processes. I don't think it should try to connect endlessly in a busy loop. At least there should be a counter that tries this for maybe 5 times followed by a [u]sleep() in the loop.

    int ctr = 0;
    while(!IS_COMM_WITH_VTPM(s) && ctr < 5){
      open_vtpm_channel(s);
       ctr ++;
       sleep(1);

}

Quoted 10 lines

Stefan

Quoted 3 lines

/****************************************************************************/

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

tools/ioemu/hw/tpm_tis.c +7 -0
diff -r 966a6d3b7408 tools/ioemu/hw/tpm_tis.c
@@ -904,6 +904,13 @@ void tpm_tis_init(SetIRQFunc *set_irq, v
     memset(s->buffer.buf,0,sizeof(s->buffer.buf));
 
     register_savevm("tpm-tis", 0, 1, tpm_save, tpm_load, s);
+
+    int ctr = 0;
+    while(!IS_COMM_WITH_VTPM(s) && ctr < 5){
+       open_vtpm_channel(s);
+       ctr++;
+       sleep(1);
+    }
 }
 
 /****************************************************************************/

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel