[SLOF] [PATCH 02/16] Add TPM initialization support

Thomas Huth thuth at redhat.com
Mon Nov 9 22:52:16 AEDT 2015


On 09/11/15 09:29, Nikunj A Dadhania wrote:
> Stefan Berger <stefanb at linux.vnet.ibm.com> writes:
> 
>> This patch implements the main part of the fimrmware extensions. It provides
>> the following functionality:
>>
>> - initialization of the TPM by sending a sequence of commands to it
>> - proper setup of the TPM before the firmware hands over control to the bootloader
>>
>> Structures that are needed in subsequent patches are also included in the
>> private header file tcgbios_int.h at this point.
>>
>> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
...
>> diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs
>> new file mode 100644
>> index 0000000..72edac0
>> --- /dev/null
>> +++ b/board-qemu/slof/vtpm-sml.fs
>> @@ -0,0 +1,56 @@
>> +\ *****************************************************************************
>> +\ * Copyright (c) 2015 IBM Corporation
>> +\ * All rights reserved.
>> +\ * This program and the accompanying materials
>> +\ * are made available under the terms of the BSD License
>> +\ * which accompanies this distribution, and is available at
>> +\ * http://www.opensource.org/licenses/bsd-license.php
>> +\ *
>> +\ * Contributors:
>> +\ *     IBM Corporation - initial implementation
>> +\ ****************************************************************************/
>> +
>> +\ KVM/qemu TPM SML entries in /ibm,vtpm
> 
> Why is it there in root, is this documented in PAPR?
> 
> We generally push such changes in /openprom.
> 
> Thomas do you have some suggestions here?

There seems to be already some code in the Linux kernel that expects
this under /ibm,vtpm - so this location is likely be fixed already.
Apart from that, I did not spot it in LoPAPR, so I don't know whether
there is a proper binding for this already.

>> diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
>> new file mode 100644
>> index 0000000..efa4cdf
>> --- /dev/null
>> +++ b/lib/libtpm/tcgbios.c
>> @@ -0,0 +1,371 @@
>> +/*****************************************************************************
>> + * Copyright (c) 2015 IBM Corporation
>> + * All rights reserved.
>> + * This program and the accompanying materials
>> + * are made available under the terms of the BSD License
>> + * which accompanies this distribution, and is available at
>> + * http://www.opensource.org/licenses/bsd-license.php
>> + *
>> + * Contributors:
>> + *     IBM Corporation - initial implementation
>> + *****************************************************************************/
>> +
>> +/*
>> + *  Implementation of the TPM BIOS extension according to the specification
>> + *  described in the IBM VTPM Firmware document and the TCG Specification
>> + *  that can be found here under the following link:
>> + *  http://www.trustedcomputinggroup.org/resources/pc_client_work_group_specific_implementation_specification_for_conventional_bios
>> + */
>> +
>> +#include "types.h"
>> +#include "byteorder.h"
>> +#include "tpm_drivers.h"
>> +#include "string.h"
>> +#include "tcgbios.h"
>> +#include "tcgbios_int.h"
>> +#include "stdio.h"
>> +
>> +#define DEBUG 0
>> +#define dprintf(_x ...) do { \
>> +	if (DEBUG) { \
>> +		printf("TCGBIOS: " _x); \
>> +	} \
>> +} while (0);
> 
> This will be do { if (0)  { printf (); } } while(0);
> 
> which i assume compiler can optimize, but as suggested in earlier patch
> can we make it more explicit ?

Also, I know we don't have dprintf in the SLOF libc yet, but actually
dprintf is a valid POSIX libc function name, so I'd like to suggest to
use a different name for this macro instead.

 Thomas



More information about the SLOF mailing list