|
From: Joseph C. <jos...@in...> - 2011-05-06 05:32:09
|
changeset d30472020794 in /var/www/tboot.hg
details: tboot.hg?cmd=changeset;node=d30472020794
description:
Various cleanups to output and checks to make it more readable
Signed-off-by: Joseph Cihula <jos...@in...>
diffstat:
tboot/txt/acmod.c | 66 +++++++++++++++++++--------------
tboot/txt/errors.c | 10 ++--
tboot/txt/heap.c | 25 +++++++-----
tboot/txt/txt.c | 6 +-
4 files changed, 60 insertions(+), 47 deletions(-)
diffs (201 lines):
diff -r 3af0f4081fdf -r d30472020794 tboot/txt/acmod.c
--- a/tboot/txt/acmod.c Wed Apr 20 16:46:24 2011 -0700
+++ b/tboot/txt/acmod.c Thu May 05 22:39:42 2011 -0700
@@ -531,43 +531,53 @@
return false;
}
-#ifndef IS_INCLUDED /* defined in txt-test/dump-acm.c */
+#ifndef IS_INCLUDED
+acm_hdr_t *get_bios_sinit(void *sinit_region_base)
+{
+ txt_heap_t *txt_heap = get_txt_heap();
+ bios_data_t *bios_data = get_bios_data_start(txt_heap);
+
+ if ( bios_data->bios_sinit_size == 0 )
+ return NULL;
+
+ /* BIOS has loaded an SINIT module, so verify that it is valid */
+ printk("BIOS has already loaded an SINIT module\n");
+
+ /* is it a valid SINIT module? */
+ if ( !is_sinit_acmod(sinit_region_base, bios_data->bios_sinit_size, false) ||
+ !does_acmod_match_platform((acm_hdr_t *)sinit_region_base) )
+ return NULL;
+
+ return (acm_hdr_t *)sinit_region_base;
+}
+
acm_hdr_t *copy_sinit(acm_hdr_t *sinit)
{
- void *sinit_region_base;
- uint32_t sinit_region_size;
- txt_heap_t *txt_heap;
- bios_data_t *bios_data;
-
- /* get BIOS-reserved region from LT.SINIT.BASE config reg */
- sinit_region_base =
+ /* get BIOS-reserved region from TXT.SINIT.BASE config reg */
+ void *sinit_region_base =
(void*)(unsigned long)read_pub_config_reg(TXTCR_SINIT_BASE);
- sinit_region_size = (uint32_t)read_pub_config_reg(TXTCR_SINIT_SIZE);
+ uint32_t sinit_region_size = (uint32_t)read_pub_config_reg(TXTCR_SINIT_SIZE);
+ printk("TXT.SINIT.BASE: %p\n", sinit_region_base);
+ printk("TXT.SINIT.SIZE: 0x%x (%u)\n", sinit_region_size, sinit_region_size);
/*
* check if BIOS already loaded an SINIT module there
*/
- txt_heap = get_txt_heap();
- bios_data = get_bios_data_start(txt_heap);
- /* BIOS has loaded an SINIT module, so verify that it is valid */
- if ( bios_data->bios_sinit_size != 0 ) {
- printk("BIOS has already loaded an SINIT module\n");
- /* is it a valid SINIT module? */
- if ( is_sinit_acmod(sinit_region_base, bios_data->bios_sinit_size, false) &&
- does_acmod_match_platform((acm_hdr_t *)sinit_region_base) ) {
- /* no other SINIT was provided so must use one BIOS provided */
- if ( sinit == NULL )
- return (acm_hdr_t *)sinit_region_base;
+ acm_hdr_t *bios_sinit = get_bios_sinit(sinit_region_base);
+ if ( bios_sinit != NULL ) {
+ /* no other SINIT was provided so must use one BIOS provided */
+ if ( sinit == NULL ) {
+ printk("no SINIT provided by bootloader; using BIOS SINIT\n");
+ return bios_sinit;
+ }
- /* is it newer than the one we've been provided? */
- if ( ((acm_hdr_t *)sinit_region_base)->date >= sinit->date ) {
- printk("BIOS-provided SINIT is newer, so using it\n");
- return (acm_hdr_t *)sinit_region_base; /* yes */
- }
- else
- printk("BIOS-provided SINIT is older: date=%x\n",
- ((acm_hdr_t *)sinit_region_base)->date);
+ /* is it newer than the one we've been provided? */
+ if ( bios_sinit->date >= sinit->date ) {
+ printk("BIOS-provided SINIT is newer, so using it\n");
+ return bios_sinit; /* yes */
}
+ else
+ printk("BIOS-provided SINIT is older: date=%x\n", bios_sinit->date);
}
/* our SINIT is newer than BIOS's (or BIOS did not have one) */
diff -r 3af0f4081fdf -r d30472020794 tboot/txt/errors.c
--- a/tboot/txt/errors.c Wed Apr 20 16:46:24 2011 -0700
+++ b/tboot/txt/errors.c Thu May 05 22:39:42 2011 -0700
@@ -52,7 +52,7 @@
acmod_error_t acmod_err;
/*
- * display LT.ERRORODE error
+ * display TXT.ERRORODE error
*/
err = (txt_errorcode_t)read_pub_config_reg(TXTCR_ERRORCODE);
printk("TXT.ERRORCODE: 0x%Lx\n", err._raw);
@@ -82,16 +82,16 @@
}
/*
- * display LT.ESTS error
+ * display TXT.ESTS error
*/
ests = (txt_ests_t)read_pub_config_reg(TXTCR_ESTS);
- printk("LT.ESTS=%Lx\n", ests._raw);
+ printk("TXT.ESTS: 0x%Lx\n", ests._raw);
/*
- * display LT.E2STS error
+ * display TXT.E2STS error
*/
e2sts = (txt_e2sts_t)read_pub_config_reg(TXTCR_E2STS);
- printk("LT.E2STS=%Lx\n", e2sts._raw);
+ printk("TXT.E2STS: 0x%Lx\n", e2sts._raw);
}
bool txt_get_error(void)
diff -r 3af0f4081fdf -r d30472020794 tboot/txt/heap.c
--- a/tboot/txt/heap.c Wed Apr 20 16:46:24 2011 -0700
+++ b/tboot/txt/heap.c Thu May 05 22:39:42 2011 -0700
@@ -227,12 +227,17 @@
bool verify_bios_data(txt_heap_t *txt_heap)
{
- uint64_t size, heap_size;
- bios_data_t *bios_data;
+ uint64_t heap_base = read_pub_config_reg(TXTCR_HEAP_BASE);
+ uint64_t heap_size = read_pub_config_reg(TXTCR_HEAP_SIZE);
+ printk("TXT.HEAP.BASE: 0x%jx\n", heap_base);
+ printk("TXT.HEAP.SIZE: 0x%jx (%ju)\n", heap_size, heap_size);
+
+ /* verify that heap base/size are valid */
+ if ( txt_heap == NULL || heap_base == 0 || heap_size == 0 )
+ return false;
/* check size */
- heap_size = read_priv_config_reg(TXTCR_HEAP_SIZE);
- size = get_bios_data_size(txt_heap);
+ uint64_t size = get_bios_data_size(txt_heap);
if ( size == 0 ) {
printk("BIOS data size is 0\n");
return false;
@@ -243,7 +248,7 @@
return false;
}
- bios_data = get_bios_data_start(txt_heap);
+ bios_data_t *bios_data = get_bios_data_start(txt_heap);
/* check version */
if ( bios_data->version < 2 ) {
@@ -489,8 +494,6 @@
bool verify_txt_heap(txt_heap_t *txt_heap, bool bios_data_only)
{
- uint64_t size1, size2, size3, size4;
-
/* verify BIOS to OS data */
if ( !verify_bios_data(txt_heap) )
return false;
@@ -499,10 +502,10 @@
return true;
/* check that total size is within the heap */
- size1 = get_bios_data_size(txt_heap);
- size2 = get_os_mle_data_size(txt_heap);
- size3 = get_os_sinit_data_size(txt_heap);
- size4 = get_sinit_mle_data_size(txt_heap);
+ uint64_t size1 = get_bios_data_size(txt_heap);
+ uint64_t size2 = get_os_mle_data_size(txt_heap);
+ uint64_t size3 = get_os_sinit_data_size(txt_heap);
+ uint64_t size4 = get_sinit_mle_data_size(txt_heap);
/* overflow? */
if ( plus_overflow_u64(size1, size2) ) {
diff -r 3af0f4081fdf -r d30472020794 tboot/txt/txt.c
--- a/tboot/txt/txt.c Wed Apr 20 16:46:24 2011 -0700
+++ b/tboot/txt/txt.c Thu May 05 22:39:42 2011 -0700
@@ -668,10 +668,10 @@
if ( err != TB_ERR_NONE )
return err;
- /* always set the LT.CMD.SECRETS flag */
+ /* always set the TXT.CMD.SECRETS flag */
write_priv_config_reg(TXTCR_CMD_SECRETS, 0x01);
read_priv_config_reg(TXTCR_E2STS); /* just a fence, so ignore return */
- printk("set LT.CMD.SECRETS flag\n");
+ printk("set TXT.CMD.SECRETS flag\n");
/* open TPM locality 1 */
write_priv_config_reg(TXTCR_CMD_OPEN_LOCALITY1, 0x01);
@@ -780,7 +780,7 @@
halt();
}
- /* set LT.CMD.NO-SECRETS flag (i.e. clear SECRETS flag) */
+ /* set TXT.CMD.NO-SECRETS flag (i.e. clear SECRETS flag) */
write_priv_config_reg(TXTCR_CMD_NO_SECRETS, 0x01);
read_priv_config_reg(TXTCR_E2STS); /* fence */
printk("secrets flag cleared\n");
|