From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60916 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7ApE-00040t-Dh for qemu-devel@nongnu.org; Tue, 05 Apr 2011 14:18:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7ApD-00084Y-1w for qemu-devel@nongnu.org; Tue, 05 Apr 2011 14:18:00 -0400 Received: from mail-vx0-f173.google.com ([209.85.220.173]:43261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7ApC-00084T-TY for qemu-devel@nongnu.org; Tue, 05 Apr 2011 14:17:59 -0400 Received: by vxb41 with SMTP id 41so572459vxb.4 for ; Tue, 05 Apr 2011 11:17:58 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110405120743.768171177@linux.vnet.ibm.com> References: <20110405120722.169862275@linux.vnet.ibm.com> <20110405120743.768171177@linux.vnet.ibm.com> From: Blue Swirl Date: Tue, 5 Apr 2011 21:17:38 +0300 Message-ID: Subject: Re: [Qemu-devel] [PATCH V3 8/8] Optional tests for the TIS interface Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Berger Cc: seabios@seabios.org, qemu-devel@nongnu.org On Tue, Apr 5, 2011 at 3:07 PM, Stefan Berger wrote: > This patch adds an optional test suite (CONFIG_TIS_TEST) for the TIS inte= rface > 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 previo= us > patch to 98.4%. > > v3: > =C2=A0- use if (CONFIG_TIS_TEST) ... where possible, otherwise use #if CO= NFIG_... > > Signed-off-by: Stefan Berger > > --- > =C2=A0Makefile =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A02 > =C2=A0src/Kconfig =C2=A0 =C2=A0| =C2=A0 =C2=A07 > =C2=A0src/tcgbios.c =C2=A0| =C2=A0 33 +- > =C2=A0src/tis_test.c | =C2=A0846 ++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++ > =C2=A0src/tis_test.h | =C2=A0 52 +++ > =C2=A05 files changed, 931 insertions(+), 9 deletions(-) > > Index: seabios/Makefile > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- seabios.orig/Makefile > +++ seabios/Makefile > @@ -20,7 +20,7 @@ SRC16=3D$(SRCBOTH) system.c disk.c font.c > =C2=A0SRC32FLAT=3D$(SRCBOTH) post.c shadow.c memmap.c coreboot.c boot.c \ > =C2=A0 =C2=A0 =C2=A0 acpi.c smm.c mptable.c smbios.c pciinit.c optionroms= .c mtrr.c \ > =C2=A0 =C2=A0 =C2=A0 lzmadecode.c bootsplash.c jpeg.c usb-hub.c paravirt.= c dev-i440fx.c \ > - =C2=A0 =C2=A0 =C2=A0pci_region.c tcgbios.c tpm_drivers.c sha1.c > + =C2=A0 =C2=A0 =C2=A0pci_region.c tcgbios.c tpm_drivers.c sha1.c tis_tes= t.c > =C2=A0SRC32SEG=3Dutil.c output.c pci.c pcibios.c apm.c stacks.c > > =C2=A0cc-option =3D $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \ > Index: seabios/src/tcgbios.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- seabios.orig/src/tcgbios.c > +++ seabios/src/tcgbios.c > @@ -18,6 +18,9 @@ > =C2=A0#include "sha1.h" =C2=A0// sha1 > =C2=A0#include "smbios.h" // get_smbios_entry_point > > +#if CONFIG_TIS_TEST > +#include "tis_test.h" > +#endif > > =C2=A0static const u8 Startup_ST_CLEAR[2] =3D { 0x00, TPM_ST_CLEAR }; > =C2=A0static const u8 Startup_ST_STATE[2] =3D { 0x00, TPM_ST_STATE }; > @@ -697,6 +700,9 @@ pass_through_to_tpm(struct pttti *pttti, > =C2=A0 =C2=A0 iovec[1].data =C2=A0 =3D NULL; > =C2=A0 =C2=A0 iovec[1].length =3D 0; > > + =C2=A0 =C2=A0if (CONFIG_TIS_TEST) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0locty =3D pttti->reserved; > + > =C2=A0 =C2=A0 rc =3D transmit(locty, iovec, pttto->tpmopout, &resbuflen); > =C2=A0 =C2=A0 if (rc) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto err_exit; > @@ -1732,26 +1738,29 @@ err_exit: > =C2=A0} > > > -static void > +static int > =C2=A0show_tpm_state(void) > =C2=A0{ > + =C2=A0 =C2=A0int state =3D 0; > =C2=A0 =C2=A0 struct tpm_permanent_flags pf; > =C2=A0 =C2=A0 u8 has_owner; > > =C2=A0 =C2=A0 if (read_permanent_flags((char *)&pf, sizeof(pf)) || > =C2=A0 =C2=A0 =C2=A0 =C2=A0 read_has_owner(&has_owner)) > - =C2=A0 =C2=A0 =C2=A0 =C2=A0return; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0return ~0; > > =C2=A0 =C2=A0 printf("TPM is "); > > - =C2=A0 =C2=A0if (pf.flags[PERM_FLAG_IDX_DISABLE]) > + =C2=A0 =C2=A0if (pf.flags[PERM_FLAG_IDX_DISABLE]) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("disabled"); > - =C2=A0 =C2=A0else > + =C2=A0 =C2=A0 =C2=A0 =C2=A0state |=3D 1 << PERM_FLAG_IDX_DISABLE; > + =C2=A0 =C2=A0} else > =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("enabled"); > > - =C2=A0 =C2=A0if (pf.flags[PERM_FLAG_IDX_DEACTIVATED]) > + =C2=A0 =C2=A0if (pf.flags[PERM_FLAG_IDX_DEACTIVATED]) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf(", deactivated"); > - =C2=A0 =C2=A0else > + =C2=A0 =C2=A0 =C2=A0 =C2=A0state |=3D 1 << PERM_FLAG_IDX_DEACTIVATED; > + =C2=A0 =C2=A0} else > =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf(", active"); > > =C2=A0 =C2=A0 if (has_owner) > @@ -1764,6 +1773,7 @@ show_tpm_state(void) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("and an owner cannot be = installed.\n"); > =C2=A0 =C2=A0 } > > + =C2=A0 =C2=A0return state; > =C2=A0} > > > @@ -1822,7 +1832,7 @@ tcpa_menu(void) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 return; > > =C2=A0 =C2=A0 int show_menu =3D 1; > - =C2=A0 =C2=A0int scan_code; > + =C2=A0 =C2=A0int scan_code, state; > =C2=A0 =C2=A0 u32 rc; > =C2=A0 =C2=A0 tpm_bios_cfg_t cfg =3D { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 .op =C2=A0=3D 0, > @@ -1841,9 +1851,12 @@ tcpa_menu(void) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"5. = Clear ownership\n" > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"6. = Allow installation of owner\n" > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"7. = Prevent installation of owner\n" > +#if CONFIG_TIS_TEST > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "8. TIS = test\n" > +#endif > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Esc= ape for previous menu.\n"); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 show_menu =3D 0; > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show_tpm_state(); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0state =3D show_tpm_state(); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 cfg.op =3D 0; > @@ -1857,6 +1870,10 @@ tcpa_menu(void) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 case 2 ... 8: > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cfg.op =3D scan_code - 1; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break; > +#if CONFIG_TIS_TEST > + =C2=A0 =C2=A0 =C2=A0 =C2=A0case 9: > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tis_test(state); > +#endif > =C2=A0 =C2=A0 =C2=A0 =C2=A0 default: > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 continue; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > Index: seabios/src/tis_test.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- /dev/null > +++ seabios/src/tis_test.c > @@ -0,0 +1,846 @@ > +/* > + * =C2=A0TIS interface tests > + * > + * =C2=A0This library is free software; you can redistribute it and/or > + * =C2=A0modify it under the terms of the GNU Lesser General Public > + * =C2=A0License as published by the Free Software Foundation; either > + * =C2=A0version 2 of the License, or (at your option) any later version= . > + * > + * =C2=A0This library is distributed in the hope that it will be useful, > + * =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty of > + * =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =C2=A0See = the GNU > + * =C2=A0Lesser General Public License for more details. > + * > + * =C2=A0You should have received a copy of the GNU Lesser General Publi= c > + * =C2=A0License along with this library; if not, write to the Free Soft= ware > + * =C2=A0Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA =C2=A0= 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.