[SeaBIOS] [Qemu-devel] [PATCH V3 8/8] Optional tests for the TIS interface
Blue Swirl
blauwirbel at gmail.com
Tue Apr 5 20:17:38 CEST 2011
On Tue, Apr 5, 2011 at 3:07 PM, Stefan Berger
<stefanb at linux.vnet.ibm.com> wrote:
> This patch adds an optional test suite (CONFIG_TIS_TEST) for the TIS interface
> to SeaBIOS. If compiled into the BIOS, it can be invoked through the
> TPM-specific menu item 8.
>
> 1. Enable TPM
> 2. Disable TPM
> 3. Activate TPM
> 4. Deactivate TPM
> 5. Clear ownership
> 6. Allow installation of owner
> 7. Prevent installation of owner
> 8. TIS test
>
> I would like to see this code become part of the SeaBIOS code base
> but I understand that a test suite in a BIOS is not the right place...
> Nevertheless, for testing the TIS emulation in Qemu, I am posting it here.
> The test suite fills up the available BIOS space from 92.6% at the previous
> patch to 98.4%.
>
> v3:
> - use if (CONFIG_TIS_TEST) ... where possible, otherwise use #if CONFIG_...
>
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
>
> ---
> Makefile | 2
> src/Kconfig | 7
> src/tcgbios.c | 33 +-
> src/tis_test.c | 846 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/tis_test.h | 52 +++
> 5 files changed, 931 insertions(+), 9 deletions(-)
>
> Index: seabios/Makefile
> ===================================================================
> --- seabios.orig/Makefile
> +++ seabios/Makefile
> @@ -20,7 +20,7 @@ SRC16=$(SRCBOTH) system.c disk.c font.c
> SRC32FLAT=$(SRCBOTH) post.c shadow.c memmap.c coreboot.c boot.c \
> acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c mtrr.c \
> lzmadecode.c bootsplash.c jpeg.c usb-hub.c paravirt.c dev-i440fx.c \
> - pci_region.c tcgbios.c tpm_drivers.c sha1.c
> + pci_region.c tcgbios.c tpm_drivers.c sha1.c tis_test.c
> SRC32SEG=util.c output.c pci.c pcibios.c apm.c stacks.c
>
> cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
> Index: seabios/src/tcgbios.c
> ===================================================================
> --- seabios.orig/src/tcgbios.c
> +++ seabios/src/tcgbios.c
> @@ -18,6 +18,9 @@
> #include "sha1.h" // sha1
> #include "smbios.h" // get_smbios_entry_point
>
> +#if CONFIG_TIS_TEST
> +#include "tis_test.h"
> +#endif
>
> static const u8 Startup_ST_CLEAR[2] = { 0x00, TPM_ST_CLEAR };
> static const u8 Startup_ST_STATE[2] = { 0x00, TPM_ST_STATE };
> @@ -697,6 +700,9 @@ pass_through_to_tpm(struct pttti *pttti,
> iovec[1].data = NULL;
> iovec[1].length = 0;
>
> + if (CONFIG_TIS_TEST)
> + locty = pttti->reserved;
> +
> rc = transmit(locty, iovec, pttto->tpmopout, &resbuflen);
> if (rc)
> goto err_exit;
> @@ -1732,26 +1738,29 @@ err_exit:
> }
>
>
> -static void
> +static int
> show_tpm_state(void)
> {
> + int state = 0;
> struct tpm_permanent_flags pf;
> u8 has_owner;
>
> if (read_permanent_flags((char *)&pf, sizeof(pf)) ||
> read_has_owner(&has_owner))
> - return;
> + return ~0;
>
> printf("TPM is ");
>
> - if (pf.flags[PERM_FLAG_IDX_DISABLE])
> + if (pf.flags[PERM_FLAG_IDX_DISABLE]) {
> printf("disabled");
> - else
> + state |= 1 << PERM_FLAG_IDX_DISABLE;
> + } else
> printf("enabled");
>
> - if (pf.flags[PERM_FLAG_IDX_DEACTIVATED])
> + if (pf.flags[PERM_FLAG_IDX_DEACTIVATED]) {
> printf(", deactivated");
> - else
> + state |= 1 << PERM_FLAG_IDX_DEACTIVATED;
> + } else
> printf(", active");
>
> if (has_owner)
> @@ -1764,6 +1773,7 @@ show_tpm_state(void)
> printf("and an owner cannot be installed.\n");
> }
>
> + return state;
> }
>
>
> @@ -1822,7 +1832,7 @@ tcpa_menu(void)
> return;
>
> int show_menu = 1;
> - int scan_code;
> + int scan_code, state;
> u32 rc;
> tpm_bios_cfg_t cfg = {
> .op = 0,
> @@ -1841,9 +1851,12 @@ tcpa_menu(void)
> "5. Clear ownership\n"
> "6. Allow installation of owner\n"
> "7. Prevent installation of owner\n"
> +#if CONFIG_TIS_TEST
> + "8. TIS test\n"
> +#endif
> "Escape for previous menu.\n");
> show_menu = 0;
> - show_tpm_state();
> + state = show_tpm_state();
> }
>
> cfg.op = 0;
> @@ -1857,6 +1870,10 @@ tcpa_menu(void)
> case 2 ... 8:
> cfg.op = scan_code - 1;
> break;
> +#if CONFIG_TIS_TEST
> + case 9:
> + tis_test(state);
> +#endif
> default:
> continue;
> }
> Index: seabios/src/tis_test.c
> ===================================================================
> --- /dev/null
> +++ seabios/src/tis_test.c
> @@ -0,0 +1,846 @@
> +/*
> + * TIS interface tests
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The current FSF's address is:
51 Franklin Street, Fifth Floor
Boston, MA 02110-1301
USA
Actually FSF recommends to use the web address these days.
More information about the SeaBIOS
mailing list