Received: from [140.186.70.92] (port=59148 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6br9-0005mF-Vv for qemu-devel@nongnu.org; Mon, 04 Apr 2011 00:57:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q6br8-0008LQ-O7 for qemu-devel@nongnu.org; Mon, 04 Apr 2011 00:57:39 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:48675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q6br8-0008LH-JQ for qemu-devel@nongnu.org; Mon, 04 Apr 2011 00:57:38 -0400 Received: by qwj8 with SMTP id 8so3856745qwj.4 for ; Sun, 03 Apr 2011 21:57:37 -0700 (PDT) Date: Mon, 4 Apr 2011 00:57:35 -0400 From: Kevin O'Connor Subject: Re: [Qemu-devel] [PATCH V1 6/8] Add measurement code to the BIOS Message-ID: <20110404045735.GD13528@morn.localdomain> References: <20110330175534.302129463@linux.vnet.ibm.com> <20110330175600.001739348@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110330175600.001739348@linux.vnet.ibm.com> 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 Wed, Mar 30, 2011 at 01:55:40PM -0400, Stefan Berger wrote: > This patch adds invocactions of functions that measure various parts of the > code and data through various parts of the BIOS code. It follows TCG > specifications on what needs to be measured. It also adds the implementation > of the called functions. [...] > void VISIBLE32FLAT > startBoot(void) > { > + tcpa_calling_int19h(); > + tcpa_add_event_separators(); Why add two functions here, instead of just one function that does both actions? [...] > // Initialize tpm (after acpi tables were written) > tcpa_acpi_init(); > tcpa_startup(); > + tcpa_measure_post((void *)0xE0000, (void *)0xFFFFF); > + tcpa_smbios_measure(); Same here. Also, I'm not sure I understand why you're measuring 0xE0000-0xFFFFF - if the intent is to measure the code, then it's a bit more complicated as the init code has already been relocated by this point. [...] > + tcpa_option_rom(FLATPTR_TO_SEG(rom), len); You're better off just defining tcpa_option_rom() to take a regular pointer. [...] > + /* specs: 8.2.3 step 5 and 8.2.5.6, measure El Torito boot catalog */ > + /* measure 2048 bytes (one sector) */ > + tcpa_add_bootdevice(1, 0); > + tcpa_ipl(IPL_EL_TORITO_2, GET_SEG(SS), (u32)buffer, 2048); Same here for tcpa_ipl(). GET_SEG() always returns 0 in 32bit mode and this code is only run in 32bit mode. [...] > +static struct smbios_entry_point * > +find_smbios_entry_point(void) > +{ The smbios table is built in smbios.c:smbios_entry_point_init() - instead of scanning for the table, just record where the table is in a global variable. [...] > +u32 > +tcpa_smbios_measure(void) > +{ > + u32 rc; > + struct pcctes pcctes = { > + .eventid = 1, /* 10.4.2.3.1 */ > + .eventdatasize = SHA1_BUFSIZE, > + }; > + struct smbios_entry_point *sep = find_smbios_entry_point(); > + > + if (!has_working_tpm()) > + return 0; BTW - SeaBIOS uses C99, so it's fine to move "if (!has_working_tpm())" above the variable declarations. -Kevin