diff options
author | Matthew Fioravante <matthew.fioravante@jhuapl.edu> | 2013-01-18 10:55:42 +0000 |
---|---|---|
committer | Matthew Fioravante <matthew.fioravante@jhuapl.edu> | 2013-01-18 10:55:42 +0000 |
commit | d463e3c5a341ece638a7a2067406fab7c03f30de (patch) | |
tree | 1987cc7e62f9043c3a876698908f2dff442c50fd /stubdom/vtpm/vtpm_pcrs.c | |
parent | 5e5e2d2a340238680100dd511bde3b5ca75c3b0d (diff) | |
download | xen-d463e3c5a341ece638a7a2067406fab7c03f30de.tar.gz xen-d463e3c5a341ece638a7a2067406fab7c03f30de.tar.bz2 xen-d463e3c5a341ece638a7a2067406fab7c03f30de.zip |
add vtpm-stubdom code
Add the code base for vtpm-stubdom to the stubdom
heirarchy. Makefile changes in later patch.
Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'stubdom/vtpm/vtpm_pcrs.c')
-rw-r--r-- | stubdom/vtpm/vtpm_pcrs.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/stubdom/vtpm/vtpm_pcrs.c b/stubdom/vtpm/vtpm_pcrs.c new file mode 100644 index 0000000000..22a6cef50d --- /dev/null +++ b/stubdom/vtpm/vtpm_pcrs.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2010-2012 United States Government, as represented by + * the Secretary of Defense. All rights reserved. + * + * THIS SOFTWARE AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT + * ANY EXPRESS OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES + * INCLUDING, BUT NOT LIMITED TO, PERFORMANCE, MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT ARE HEREBY + * DISCLAIMED. USERS ASSUME THE ENTIRE RISK AND LIABILITY OF USING THE + * SOFTWARE. + */ + +#include "vtpm_pcrs.h" +#include "vtpm_cmd.h" +#include "tpm/tpm_data.h" + +#define PCR_VALUE tpmData.permanent.data.pcrValue + +static int write_pcr_direct(unsigned int pcrIndex, uint8_t* val) { + if(pcrIndex > TPM_NUM_PCR) { + return TPM_BADINDEX; + } + memcpy(&PCR_VALUE[pcrIndex], val, sizeof(TPM_PCRVALUE)); + return TPM_SUCCESS; +} + +TPM_RESULT vtpm_initialize_hw_pcrs(struct tpmfront_dev* tpmfront_dev, unsigned long pcrs) +{ + TPM_RESULT rc = TPM_SUCCESS; + uint8_t digest[sizeof(TPM_PCRVALUE)]; + + for(unsigned int i = 0; i < TPM_NUM_PCR; ++i) { + if(pcrs & 1 << i) { + if((rc = VTPM_PCRRead(tpmfront_dev, i, digest)) != TPM_SUCCESS) { + error("TPM_PCRRead failed with error : %d", rc); + return rc; + } + write_pcr_direct(i, digest); + } + } + + return rc; +} |