[SLOF] [PATCH v3 04/17] Add initial support for logging

Thomas Huth thuth at redhat.com
Tue Dec 15 07:37:13 AEDT 2015


On 30/11/15 23:01, Stefan Berger wrote:
> From: Stefan Berger <stefanb at linux.vnet.ibm.com>
> 
> This patch adds initial support for the logging that will be done
> following measurements done by further code added to SLOF.
> 
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
> Reviewed-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
> ---
>  board-qemu/slof/vtpm-sml.fs |  3 +++
>  lib/libtpm/tcgbios.c        | 14 ++++++++++++++
>  lib/libtpm/tcgbios.h        |  1 +
>  lib/libtpm/tpm.code         | 11 +++++++++++
>  lib/libtpm/tpm.in           |  1 +
>  5 files changed, 30 insertions(+)
> 
> diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs
> index 4d63b70..2d1eb32 100644
> --- a/board-qemu/slof/vtpm-sml.fs
> +++ b/board-qemu/slof/vtpm-sml.fs
> @@ -25,6 +25,9 @@ LOG-SIZE BUFFER: log-base
>  \ create /ibm,vtpm
>  s" ibm,vtpm" 2dup device-name device-type
>  
> +\ convey logbase and size to the C driver
> +log-base LOG-SIZE tpm-set-log-parameters
> +
>  : sml-get-allocated-size ( -- buffer-size)
>      vtpm-debug? IF
>          ." Call to sml-get-allocated-size; size = 0x" LOG-SIZE . cr
> diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
> index dd0d801..5fca5cc 100644
> --- a/lib/libtpm/tcgbios.c
> +++ b/lib/libtpm/tcgbios.c
> @@ -69,6 +69,12 @@ struct tpm_state {
>  	unsigned tpm_probed:1;
>  	unsigned tpm_found:1;
>  	unsigned tpm_working:1;
> +
> +	/* base address of the log area */
> +	uint8_t *log_base;
> +
> +	/* size of the logging area */
> +	uint32_t log_area_size;
>  };
>  
>  static struct tpm_state tpm_state;
> @@ -77,6 +83,14 @@ static struct tpm_state tpm_state;
>    Extensions for TCG-enabled BIOS
>   *******************************************************/
>  
> +void tpm_set_log_parameters(void *addr, unsigned int size)
> +{
> +	dprintf("Log is at 0x%llx; size is %u bytes\n",
> +		(uint64_t)addr, size);
> +	tpm_state.log_base = addr;
> +	tpm_state.log_area_size = size;
> +}
> +
>  static void probe_tpm(void)
>  {
>  	tpm_state.tpm_probed = true;
> diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h
> index 5b5e481..7f7691a 100644
> --- a/lib/libtpm/tcgbios.h
> +++ b/lib/libtpm/tcgbios.h
> @@ -18,5 +18,6 @@
>  uint32_t tpm_start(void);
>  void tpm_finalize(void);
>  uint32_t tpm_unassert_physical_presence(void);
> +void tpm_set_log_parameters(void *address, unsigned int size);
>  
>  #endif /* TCGBIOS_H */
> diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code
> index 08f52e9..2f3e198 100644
> --- a/lib/libtpm/tpm.code
> +++ b/lib/libtpm/tpm.code
> @@ -44,3 +44,14 @@ PRIM(tpm_X2d_unassert_X2d_physical_X2d_presence)
>  	PUSH;
>  	TOS.n = tpm_unassert_physical_presence();
>  MIRP
> +
> +/*************************************************************/
> +/* Convey log address and size                               */
> +/* SLOF:   tpm-set-log-parameters  ( addr size -- )          */
> +/* LIBTPM: tpm_set_log_parameters(void *addr, uint64_t size) */
> +/*************************************************************/
> +PRIM(tpm_X2d_set_X2d_log_X2d_parameters)
> +	int size = TOS.u; POP;
> +	void *addr = TOS.a; POP;
> +	tpm_set_log_parameters(addr, size);
> +MIRP
> diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in
> index e212483..c6ad91c 100644
> --- a/lib/libtpm/tpm.in
> +++ b/lib/libtpm/tpm.in
> @@ -16,3 +16,4 @@
>  cod(tpm-start)
>  cod(tpm-finalize)
>  cod(tpm-unassert-physical-presence)
> +cod(tpm-set-log-parameters)
> 

Reviewed-by: Thomas Huth <thuth at redhat.com>



More information about the SLOF mailing list