ibmvtpm: Add support for trusted boot using a vTPM 2.0
PATCH 1/1 ibmvtpm: Add support for trusted boot using a vTPM 2.0
From: Stefan Berger <[email protected]>
Add support for trusted boot using a vTPM 2.0 on the IBM ieee1275 platform. With this patch grub now measures text and binary data into the TPM's PCRs 8 and 9 in the same way as the x86_64 platform does.
This patch requires Daniel Axtens's patches for claiming more memory.
--- grub-core/Makefile.core.def | 8 ++ grub-core/commands/ieee1275/ibmvtpm.c | 118 ++++++++++++++++++++++++++ grub-core/kern/ieee1275/ibmvtpm.c | 62 ++++++++++++++ include/grub/ieee1275/ibmvtpm.h | 32 +++++++ 4 files changed, 220 insertions(+) create mode 100644 grub-core/commands/ieee1275/ibmvtpm.c create mode 100644 grub-core/kern/ieee1275/ibmvtpm.c create mode 100644 include/grub/ieee1275/ibmvtpm.h
grub-core/Makefile.core.def +8 -0
@@ -1166,6 +1166,14 @@ module = { enable = powerpc_ieee1275; }; +module = { + name = tpm; + common = commands/tpm.c; + common = kern/ieee1275/ibmvtpm.c; + ieee1275 = commands/ieee1275/ibmvtpm.c; + enable = powerpc_ieee1275; +}; + module = { name = terminal; common = commands/terminal.c;
grub-core/commands/ieee1275/ibmvtpm.c new file +118 -0
118 lines not on this page · raw message
grub-core/kern/ieee1275/ibmvtpm.c new file +62 -0
62 lines not on this page · raw message
include/grub/ieee1275/ibmvtpm.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef GRUB_IEEE1275_IBMVTPM_HEADER +#define GRUB_IEEE1275_IBMVTPM_HEADER 1 + +#include <stdbool.h> + +bool EXPORT_FUNC (grub_ieee1275_ibmvtpm_2hash_ext_log ) ( +grub_uint32_t ihandle, +grub_uint8_t pcrindex, +grub_uint32_t eventtype, +const char *description, +grub_size_t description_size, +void *buf,grub_size_t size); + +#endif
Signature · 1 line
2.31.1
CC-ing folks CC-ed in Daniel's patch series and Eric.
Quoted 8 lines · Stefan Berger
From: Stefan Berger <[email protected]>
Add support for trusted boot using a vTPM 2.0 on the IBM ieee1275 platform. With this patch grub now measures text and binary data into the TPM's PCRs 8 and 9 in the same way as the
x86_64platform does.This patch requires Daniel Axtens's patches for claiming more memory.
Would not be it simpler if you take out the memory mgmt changes patches from Daniel's patch series?
Daniel, are you OK with it?
Additionally, please CC Eric when you post IEEE1275 patches next time.
Quoted 16 lines
Signed-off-by Stefan Berger <[email protected]>--- grub-core/Makefile.core.def | 8 ++ grub-core/commands/ieee1275/ibmvtpm.c | 118 ++++++++++++++++++++++++++ grub-core/kern/ieee1275/ibmvtpm.c | 62 ++++++++++++++ include/grub/ieee1275/ibmvtpm.h | 32 +++++++ 4 files changed, 220 insertions(+) create mode 100644 grub-core/commands/ieee1275/ibmvtpm.c create mode 100644 grub-core/kern/ieee1275/ibmvtpm.c create mode 100644 include/grub/ieee1275/ibmvtpm.hgrub-core/Makefile.core.def +0
-0
grub-core/Makefile.core.def module = { · line 1173
Quoted 8 lines
grub-core/Makefile.core.def +5
-0@@ -1166,6 +1166,14 @@ module = { enable = powerpc_ieee1275; }; +module = { + name = tpm; + common = commands/tpm.c; + common = kern/ieee1275/ibmvtpm.c; + ieee1275 = commands/ieee1275/ibmvtpm.c;
s/ieee1275/common/?
Quoted 12 lines
grub-core/Makefile.core.def +3
-0+ enable = powerpc_ieee1275; +}; + module = { name = terminal; common = commands/terminal.c;grub-core/commands/ieee1275/ibmvtpm.c new file +0
-0
grub-core/commands/ieee1275/ibmvtpm.c line 3
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0@@ -0,0 +1,118 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation
Copyright (C) 2021 Free Software Foundation, Inc.
Or both if you strongly need IBM...
Quoted 18 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +18
-0+* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +* +* IBM vTPM support code. +*/ + +#include <grub/err.h> +#include <grub/types.h>
grub-core/commands/ieee1275/ibmvtpm.c line 32
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +10
-0+#include <grub/tpm.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h> +#include <grub/mm.h> +#include <grub/misc.h> + +static grub_ieee1275_ihandle_t grub_tpm_ihandle; +static grub_uint8_t grub_tpm_version; + +static void grub_ieee1275_tpm_init (grub_ieee1275_ihandle_t *tpm_ihandle)
You can drop from static functions, variables, etc. names "grub_" prefix.
grub-core/commands/ieee1275/ibmvtpm.c line 39
Quoted 7 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +7
-0+{ +static int init_called =0 ; + +if (!init_called) { + init_called =1 ; +grub_ieee1275_open ("/vdevice/vtpm" , &grub_tpm_ihandle); + }
Incorrect formatting. It should be
if (!init_called)
{
init_called = 1;
grub_ieee1275_open ("/vdevice/vtpm", &grub_tpm_ihandle);}
You can always refer to grub-core/kern/efi/sb.c to get formatting examples for various pieces of the GRUB code.
Please fix similar issues below too.
Quoted 13 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +13
-0+ *tpm_ihandle = grub_tpm_ihandle; +} + +static grub_err_t +grub_tpm_get_tpm_version (grub_uint8_t *protocol_version) +{ +static int version_probed =0 ; +grub_ieee1275_phandle_t vtpm; +char buffer[20 ]; +grub_ssize_t buffer_size; + +if (!version_probed) { + version_probed =1 ;
grub-core/commands/ieee1275/ibmvtpm.c line 63
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +10
-0+if (!grub_ieee1275_finddevice ("/vdevice/vtpm" , &vtpm) && + !grub_ieee1275_get_property (vtpm,"compatible" , buffer, +sizeof buffer, &buffer_size) && + !grub_strcmp (buffer,"IBM,vtpm20" )) { + grub_tpm_version =2 ; + } + } + *protocol_version = grub_tpm_version; + +return 0 ;
You ignore this value later.
I think the prototype of this function should be following:
grub_uint8_t get_tpm_version (void)
Which means you should return the TPM version.
grub-core/commands/ieee1275/ibmvtpm.c line 66
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+} + +static grub_int8_t
static grub_err_t
grub-core/commands/ieee1275/ibmvtpm.c line 72
Quoted 6 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +6
-0+grub_tpm_handle_find (grub_ieee1275_ihandle_t *tpm_handle, + grub_uint8_t *protocol_version) +{ +grub_ieee1275_tpm_init (tpm_handle); +if (*tpm_handle ==NULL ) +return 0 ;
return GRUB_ERR_UNKNOWN_DEVICE;
grub-core/commands/ieee1275/ibmvtpm.c line 76
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+grub_tpm_get_tpm_version (protocol_version); + +return 1 ;
return GRUB_ERR_NONE;
grub-core/commands/ieee1275/ibmvtpm.c line 85
Quoted 9 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+} + +static grub_err_t +grub_tpm2_log_event (grub_ieee1275_ihandle_t tpm_handle,unsigned char *buf, +grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +static int error_displayed; +bool succ;
s/bool/grub_err_t/
grub-core/commands/ieee1275/ibmvtpm.c line 94
Quoted 9 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+ + succ =grub_ieee1275_ibmvtpm_2hash_ext_log (tpm_handle, + pcr,EV_IPL , + description, +grub_strlen (description) +1 , + buf, size); +if (!succ && !error_displayed) { + error_displayed =1 ; +grub_printf ("2HASH-EXT-LOG failed: Firmware is likely too old.\n" );
s/grub_printf/grub_error/
grub-core/commands/ieee1275/ibmvtpm.c line 105
Quoted 11 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +11
-0+ } + +return 0 ; +} + +grub_err_t +grub_tpm_measure (unsigned char *buf,grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +grub_ieee1275_ihandle_t tpm_handle; +grub_uint8_t protocol_version =0 ;
It seems to me that you have the same information in the grub_tpm_version global variable. So, I think you should you use it and drop all instances of protocol_version.
Quoted 33 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +12
-0+/* Absence of a TPM isn't a failure. */ +if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) +return 0 ; + +grub_dprintf ("tpm" ,"log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE", %s\n" , + pcr, size, description); + +if (protocol_version ==2 ) +return grub_tpm2_log_event (tpm_handle, buf, size, pcr, description); + +return 0 ; +}grub-core/kern/ieee1275/ibmvtpm.c new file +15
-0@@ -0,0 +1,62 @@ +/* ibmvtpm.c - Client interface to access the IBM vTPM */ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +*
grub-core/kern/ieee1275/ibmvtpm.c line 25
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +10
-0+* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/types.h> +#include <grub/misc.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h> + +bool
s/bool/grub_err_t/
grub-core/kern/ieee1275/ibmvtpm.c line 31
Quoted 6 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +6
-0+grub_ieee1275_ibmvtpm_2hash_ext_log (grub_uint32_t ihandle, + grub_uint8_t pcrindex, + grub_uint32_t eventtype, + const char *description, + grub_size_t description_size, + void *buf, grub_size_t size)
I cannot see any reason to make this function part of the GRUB kernel. I think it should be in grub-core/commands/ieee1275/ibmvtpm.c.
grub-core/kern/ieee1275/ibmvtpm.c line 33
Quoted 2 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +2
-0+{ +struct tpm_2hash_ext_log
Please define this struct before the function, somewhere after includes.
grub-core/kern/ieee1275/ibmvtpm.c line 46
Quoted 13 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +13
-0+ { +struct grub_ieee1275_common_hdr common; +grub_ieee1275_cell_t method; +grub_ieee1275_cell_t ihandle; +grub_ieee1275_cell_t size; +void *buf; +grub_ieee1275_cell_t description_size; +const char *description; +grub_ieee1275_cell_t eventtype; +grub_ieee1275_cell_t pcrindex; +grub_ieee1275_cell_t catch_result; +grub_ieee1275_cell_t rc; + }
GRUB_PACKED?
Quoted 6 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +6
-0+ args; + +INIT_IEEE1275_COMMON (&args.common,"call-method" ,8 ,2 ); + args.method = (grub_ieee1275_cell_t )"2hash-ext-log" ; + args.ihandle = ihandle; + args.pcrindex = pcrindex;
grub-core/kern/ieee1275/ibmvtpm.c line 62
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +10
-0+ args.eventtype = eventtype; + args.description = description; + args.description_size = description_size; + args.buf = buf; + args.size = (grub_ieee1275_cell_t ) size; + +if (IEEE1275_CALL_ENTRY_FN (&args) ==-1 ) +return false; +return !!args.rc; +}
Daniel
Quoted 5 lines · Daniel Kiper
CC-ing folks CC-ed in Daniel's patch series and Eric.
Quoted 2 lines · Stefan Berger
From: Stefan Berger <[email protected]>
Quoted 8 lines
Quoted 6 lines
Add support for trusted boot using a vTPM 2.0 on the IBM ieee1275 platform. With this patch grub now measures text and binary data into the TPM's PCRs 8 and 9 in the same way as the
x86_64platform does.This patch requires Daniel Axtens's patches for claiming more memory.
Would not be it simpler if you take out the memory mgmt changes patches from Daniel's patch series?
You mean reposting this series with his 3 patches upfront? I can certainly do that.
Quoted 4 lines
Daniel, are you OK with it?
Additionally, please CC Eric when you post IEEE1275 patches next time.
Will do.
Quoted 271 lines
Quoted 17 lines
Signed-off-by Stefan Berger <[email protected]>--- grub-core/Makefile.core.def | 8 ++ grub-core/commands/ieee1275/ibmvtpm.c | 118 ++++++++++++++++++++++++++ grub-core/kern/ieee1275/ibmvtpm.c | 62 ++++++++++++++ include/grub/ieee1275/ibmvtpm.h | 32 +++++++ 4 files changed, 220 insertions(+)create mode 100644
grub-core/commands/ieee1275/ibmvtpm.ccreate mode 100644grub-core/kern/ieee1275/ibmvtpm.ccreate mode 100644include/grub/ieee1275/ibmvtpm.hgrub-core/Makefile.core.def +0
-0grub-core/Makefile.core.def module = { · line 1173
Quoted 8 lines
grub-core/Makefile.core.def +5
-0@@ -1166,6 +1166,14 @@ module = { enable = powerpc_ieee1275; }; +module = { + name = tpm; + common = commands/tpm.c; + common = kern/ieee1275/ibmvtpm.c; + ieee1275 = commands/ieee1275/ibmvtpm.c;s/ieee1275/common/?
Quoted 12 lines
grub-core/Makefile.core.def +3
-0+ enable = powerpc_ieee1275; +}; + module = { name = terminal; common = commands/terminal.c;grub-core/commands/ieee1275/ibmvtpm.c new file +0
-0grub-core/commands/ieee1275/ibmvtpm.c line 3
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0@@ -0,0 +1,118 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation Copyright (C) 2021 Free Software Foundation, Inc.
Or both if you strongly need IBM...
Quoted 18 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +18
-0+* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +* +* IBM vTPM support code. +*/ + +#include <grub/err.h> +#include <grub/types.h> grub-core/commands/ieee1275/ibmvtpm.c line 32
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +10
-0+#include <grub/tpm.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h> +#include <grub/mm.h> +#include <grub/misc.h> + +static grub_ieee1275_ihandle_t grub_tpm_ihandle; +static grub_uint8_t grub_tpm_version; + +static void grub_ieee1275_tpm_init (grub_ieee1275_ihandle_t *tpm_ihandle)You can drop from static functions, variables, etc. names "
grub_" prefix.grub-core/commands/ieee1275/ibmvtpm.c line 39
Quoted 7 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +7
-0+{ +static int init_called =0 ; + +if (!init_called) { + init_called =1 ; +grub_ieee1275_open ("/vdevice/vtpm" , &grub_tpm_ihandle); + }Incorrect formatting. It should be
if (!init_called)
{ init_called = 1; grub_ieee1275_open ("/vdevice/vtpm", &grub_tpm_ihandle);}
You can always refer to
grub-core/kern/efi/sb.cto get formatting examples for various pieces of the GRUB code.Please fix similar issues below too.
Quoted 13 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +13
-0+ *tpm_ihandle = grub_tpm_ihandle; +} + +static grub_err_t +grub_tpm_get_tpm_version (grub_uint8_t *protocol_version) +{ +static int version_probed =0 ; +grub_ieee1275_phandle_t vtpm; +char buffer[20 ]; +grub_ssize_t buffer_size; + +if (!version_probed) { + version_probed =1 ;grub-core/commands/ieee1275/ibmvtpm.c line 63
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +10
-0+if (!grub_ieee1275_finddevice ("/vdevice/vtpm" , &vtpm) && + !grub_ieee1275_get_property (vtpm,"compatible" , buffer, +sizeof buffer, &buffer_size) && + !grub_strcmp (buffer,"IBM,vtpm20" )) { + grub_tpm_version =2 ; + } + } + *protocol_version = grub_tpm_version; + +return 0 ;You ignore this value later.
I think the prototype of this function should be following:
grub_uint8_tget_tpm_version(void)Which means you should return the TPM version.
grub-core/commands/ieee1275/ibmvtpm.c line 66
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+} + +static grub_int8_tstatic
grub_err_tgrub-core/commands/ieee1275/ibmvtpm.c line 72
Quoted 6 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +6
-0+grub_tpm_handle_find (grub_ieee1275_ihandle_t *tpm_handle, + grub_uint8_t *protocol_version) +{ +grub_ieee1275_tpm_init (tpm_handle); +if (*tpm_handle ==NULL ) +return 0 ;return
GRUB_ERR_UNKNOWN_DEVICE;grub-core/commands/ieee1275/ibmvtpm.c line 76
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+grub_tpm_get_tpm_version (protocol_version); + +return 1 ;return
GRUB_ERR_NONE;grub-core/commands/ieee1275/ibmvtpm.c line 85
Quoted 9 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+} + +static grub_err_t +grub_tpm2_log_event (grub_ieee1275_ihandle_t tpm_handle,unsigned char *buf, +grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +static int error_displayed; +bool succ;s/bool/grub_err_t/
grub-core/commands/ieee1275/ibmvtpm.c line 94
Quoted 9 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+ + succ =grub_ieee1275_ibmvtpm_2hash_ext_log (tpm_handle, + pcr,EV_IPL , + description, +grub_strlen (description) +1 , + buf, size); +if (!succ && !error_displayed) { + error_displayed =1 ; +grub_printf ("2HASH-EXT-LOG failed: Firmware is likely too old.\n" );s/grub_printf/grub_error/
grub-core/commands/ieee1275/ibmvtpm.c line 105
Quoted 11 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +11
-0+ } + +return 0 ; +} + +grub_err_t +grub_tpm_measure (unsigned char *buf,grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +grub_ieee1275_ihandle_t tpm_handle; +grub_uint8_t protocol_version =0 ;It seems to me that you have the same information in the
grub_tpm_versionglobal variable. So, I think you should you use it and drop all instances ofprotocol_version.Quoted 33 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +12
-0+/* Absence of a TPM isn't a failure. */ +if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) +return 0 ; + +grub_dprintf ("tpm" ,"log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE", %s\n" , + pcr, size, description); + +if (protocol_version ==2 ) +return grub_tpm2_log_event (tpm_handle, buf, size, pcr, description); + +return 0 ; +}grub-core/kern/ieee1275/ibmvtpm.c new file +15
-0@@ -0,0 +1,62 @@ +/* ibmvtpm.c - Client interface to access the IBM vTPM */ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* grub-core/kern/ieee1275/ibmvtpm.c line 25
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +10
-0+* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/types.h> +#include <grub/misc.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h> + +bool s/bool/grub_err_t/
grub-core/kern/ieee1275/ibmvtpm.c line 31
Quoted 6 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +6
-0+grub_ieee1275_ibmvtpm_2hash_ext_log (grub_uint32_t ihandle, + grub_uint8_t pcrindex, + grub_uint32_t eventtype, + const char *description, + grub_size_t description_size, + void *buf, grub_size_t size)I cannot see any reason to make this function part of the GRUB kernel. I think it should be in
grub-core/commands/ieee1275/ibmvtpm.c.grub-core/kern/ieee1275/ibmvtpm.c line 33
Quoted 2 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +2
-0+{ +struct tpm_2hash_ext_log Please define this struct before the function, somewhere after includes.
grub-core/kern/ieee1275/ibmvtpm.c line 46
Quoted 13 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +13
-0+ { +struct grub_ieee1275_common_hdr common; +grub_ieee1275_cell_t method; +grub_ieee1275_cell_t ihandle; +grub_ieee1275_cell_t size; +void *buf; +grub_ieee1275_cell_t description_size; +const char *description; +grub_ieee1275_cell_t eventtype; +grub_ieee1275_cell_t pcrindex; +grub_ieee1275_cell_t catch_result; +grub_ieee1275_cell_t rc; + }
GRUB_PACKED?Quoted 6 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +6
-0+ args; + +INIT_IEEE1275_COMMON (&args.common,"call-method" ,8 ,2 ); + args.method = (grub_ieee1275_cell_t )"2hash-ext-log" ; + args.ihandle = ihandle; + args.pcrindex = pcrindex;grub-core/kern/ieee1275/ibmvtpm.c line 62
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +10
-0+ args.eventtype = eventtype; + args.description = description; + args.description_size = description_size; + args.buf = buf; + args.size = (grub_ieee1275_cell_t ) size; + +if (IEEE1275_CALL_ENTRY_FN (&args) ==-1 ) +return false; +return !!args.rc; +}Daniel
Quoted 11 lines · Stefan Berger
Quoted 10 lines · Daniel Kiper
CC-ing folks CC-ed in Daniel's patch series and Eric.
Quoted 7 lines · Stefan Berger
From: Stefan Berger <[email protected]>
Add support for trusted boot using a vTPM 2.0 on the IBM ieee1275 platform. With this patch grub now measures text and binary data into the TPM's PCRs 8 and 9 in the same way as the
x86_64platform does.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
This patch requires Daniel Axtens's patches for claiming more memory.
Would not be it simpler if you take out the memory mgmt changes patches from Daniel's patch series?
You mean reposting this series with his 3 patches upfront? I can certainly do that.
Quoted 3 lines
Daniel, are you OK with it?
I don't mind what series the patches go through, as long as they get merged at some point :)
Kind regards,
Daniel
Quoted 277 lines
Quoted 1 line
Additionally, please CC Eric when you post IEEE1275 patches next time.
Will do.
Quoted 271 lines
Quoted 17 lines
Signed-off-by Stefan Berger <[email protected]>--- grub-core/Makefile.core.def | 8 ++ grub-core/commands/ieee1275/ibmvtpm.c | 118 ++++++++++++++++++++++++++ grub-core/kern/ieee1275/ibmvtpm.c | 62 ++++++++++++++ include/grub/ieee1275/ibmvtpm.h | 32 +++++++ 4 files changed, 220 insertions(+)create mode 100644
grub-core/commands/ieee1275/ibmvtpm.ccreate mode 100644grub-core/kern/ieee1275/ibmvtpm.ccreate mode 100644include/grub/ieee1275/ibmvtpm.hgrub-core/Makefile.core.def +0
-0grub-core/Makefile.core.def module = { · line 1173
Quoted 8 lines
grub-core/Makefile.core.def +5
-0@@ -1166,6 +1166,14 @@ module = { enable = powerpc_ieee1275; }; +module = { + name = tpm; + common = commands/tpm.c; + common = kern/ieee1275/ibmvtpm.c; + ieee1275 = commands/ieee1275/ibmvtpm.c;s/ieee1275/common/?
Quoted 12 lines
grub-core/Makefile.core.def +3
-0+ enable = powerpc_ieee1275; +}; + module = { name = terminal; common = commands/terminal.c;grub-core/commands/ieee1275/ibmvtpm.c new file +0
-0grub-core/commands/ieee1275/ibmvtpm.c line 3
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0@@ -0,0 +1,118 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation Copyright (C) 2021 Free Software Foundation, Inc.
Or both if you strongly need IBM...
Quoted 18 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +18
-0+* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +* +* IBM vTPM support code. +*/ + +#include <grub/err.h> +#include <grub/types.h> grub-core/commands/ieee1275/ibmvtpm.c line 32
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +10
-0+#include <grub/tpm.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h> +#include <grub/mm.h> +#include <grub/misc.h> + +static grub_ieee1275_ihandle_t grub_tpm_ihandle; +static grub_uint8_t grub_tpm_version; + +static void grub_ieee1275_tpm_init (grub_ieee1275_ihandle_t *tpm_ihandle)You can drop from static functions, variables, etc. names "
grub_" prefix.grub-core/commands/ieee1275/ibmvtpm.c line 39
Quoted 7 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +7
-0+{ +static int init_called =0 ; + +if (!init_called) { + init_called =1 ; +grub_ieee1275_open ("/vdevice/vtpm" , &grub_tpm_ihandle); + }Incorrect formatting. It should be
if (!init_called)
{ init_called = 1; grub_ieee1275_open ("/vdevice/vtpm", &grub_tpm_ihandle);}
You can always refer to
grub-core/kern/efi/sb.cto get formatting examples for various pieces of the GRUB code.Please fix similar issues below too.
Quoted 13 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +13
-0+ *tpm_ihandle = grub_tpm_ihandle; +} + +static grub_err_t +grub_tpm_get_tpm_version (grub_uint8_t *protocol_version) +{ +static int version_probed =0 ; +grub_ieee1275_phandle_t vtpm; +char buffer[20 ]; +grub_ssize_t buffer_size; + +if (!version_probed) { + version_probed =1 ;grub-core/commands/ieee1275/ibmvtpm.c line 63
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +10
-0+if (!grub_ieee1275_finddevice ("/vdevice/vtpm" , &vtpm) && + !grub_ieee1275_get_property (vtpm,"compatible" , buffer, +sizeof buffer, &buffer_size) && + !grub_strcmp (buffer,"IBM,vtpm20" )) { + grub_tpm_version =2 ; + } + } + *protocol_version = grub_tpm_version; + +return 0 ;You ignore this value later.
I think the prototype of this function should be following:
grub_uint8_tget_tpm_version(void)Which means you should return the TPM version.
grub-core/commands/ieee1275/ibmvtpm.c line 66
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+} + +static grub_int8_tstatic
grub_err_tgrub-core/commands/ieee1275/ibmvtpm.c line 72
Quoted 6 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +6
-0+grub_tpm_handle_find (grub_ieee1275_ihandle_t *tpm_handle, + grub_uint8_t *protocol_version) +{ +grub_ieee1275_tpm_init (tpm_handle); +if (*tpm_handle ==NULL ) +return 0 ;return
GRUB_ERR_UNKNOWN_DEVICE;grub-core/commands/ieee1275/ibmvtpm.c line 76
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+grub_tpm_get_tpm_version (protocol_version); + +return 1 ;return
GRUB_ERR_NONE;grub-core/commands/ieee1275/ibmvtpm.c line 85
Quoted 9 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+} + +static grub_err_t +grub_tpm2_log_event (grub_ieee1275_ihandle_t tpm_handle,unsigned char *buf, +grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +static int error_displayed; +bool succ;s/bool/grub_err_t/
grub-core/commands/ieee1275/ibmvtpm.c line 94
Quoted 9 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+ + succ =grub_ieee1275_ibmvtpm_2hash_ext_log (tpm_handle, + pcr,EV_IPL , + description, +grub_strlen (description) +1 , + buf, size); +if (!succ && !error_displayed) { + error_displayed =1 ; +grub_printf ("2HASH-EXT-LOG failed: Firmware is likely too old.\n" );s/grub_printf/grub_error/
grub-core/commands/ieee1275/ibmvtpm.c line 105
Quoted 11 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +11
-0+ } + +return 0 ; +} + +grub_err_t +grub_tpm_measure (unsigned char *buf,grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +grub_ieee1275_ihandle_t tpm_handle; +grub_uint8_t protocol_version =0 ;It seems to me that you have the same information in the
grub_tpm_versionglobal variable. So, I think you should you use it and drop all instances ofprotocol_version.Quoted 33 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +12
-0+/* Absence of a TPM isn't a failure. */ +if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) +return 0 ; + +grub_dprintf ("tpm" ,"log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE", %s\n" , + pcr, size, description); + +if (protocol_version ==2 ) +return grub_tpm2_log_event (tpm_handle, buf, size, pcr, description); + +return 0 ; +}grub-core/kern/ieee1275/ibmvtpm.c new file +15
-0@@ -0,0 +1,62 @@ +/* ibmvtpm.c - Client interface to access the IBM vTPM */ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* grub-core/kern/ieee1275/ibmvtpm.c line 25
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +10
-0+* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <grub/types.h> +#include <grub/misc.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h> + +bool s/bool/grub_err_t/
grub-core/kern/ieee1275/ibmvtpm.c line 31
Quoted 6 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +6
-0+grub_ieee1275_ibmvtpm_2hash_ext_log (grub_uint32_t ihandle, + grub_uint8_t pcrindex, + grub_uint32_t eventtype, + const char *description, + grub_size_t description_size, + void *buf, grub_size_t size)I cannot see any reason to make this function part of the GRUB kernel. I think it should be in
grub-core/commands/ieee1275/ibmvtpm.c.grub-core/kern/ieee1275/ibmvtpm.c line 33
Quoted 2 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +2
-0+{ +struct tpm_2hash_ext_log Please define this struct before the function, somewhere after includes.
grub-core/kern/ieee1275/ibmvtpm.c line 46
Quoted 13 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +13
-0+ { +struct grub_ieee1275_common_hdr common; +grub_ieee1275_cell_t method; +grub_ieee1275_cell_t ihandle; +grub_ieee1275_cell_t size; +void *buf; +grub_ieee1275_cell_t description_size; +const char *description; +grub_ieee1275_cell_t eventtype; +grub_ieee1275_cell_t pcrindex; +grub_ieee1275_cell_t catch_result; +grub_ieee1275_cell_t rc; + }
GRUB_PACKED?Quoted 6 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +6
-0+ args; + +INIT_IEEE1275_COMMON (&args.common,"call-method" ,8 ,2 ); + args.method = (grub_ieee1275_cell_t )"2hash-ext-log" ; + args.ihandle = ihandle; + args.pcrindex = pcrindex;grub-core/kern/ieee1275/ibmvtpm.c line 62
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +10
-0+ args.eventtype = eventtype; + args.description = description; + args.description_size = description_size; + args.buf = buf; + args.size = (grub_ieee1275_cell_t ) size; + +if (IEEE1275_CALL_ENTRY_FN (&args) ==-1 ) +return false; +return !!args.rc; +}Daniel
Quoted 19 lines · Daniel Kiper
Signed-off-by Stefan Berger <[email protected]>Quoted 18 lines
--- grub-core/Makefile.core.def | 8 ++ grub-core/commands/ieee1275/ibmvtpm.c | 118 ++++++++++++++++++++++++++ grub-core/kern/ieee1275/ibmvtpm.c | 62 ++++++++++++++ include/grub/ieee1275/ibmvtpm.h | 32 +++++++ 4 files changed, 220 insertions(+)create mode 100644
grub-core/commands/ieee1275/ibmvtpm.ccreate mode 100644grub-core/kern/ieee1275/ibmvtpm.ccreate mode 100644include/grub/ieee1275/ibmvtpm.hgrub-core/Makefile.core.def +0
-0@@ -1166,6 +1166,14 @@ module = { enable = powerpc_ieee1275; };
Quoted 6 lines
grub-core/Makefile.core.def module = { · line 1173
Quoted 5 lines
grub-core/Makefile.core.def +5
-0+module = { + name = tpm; + common = commands/tpm.c; + common = kern/ieee1275/ibmvtpm.c; + ieee1275 = commands/ieee1275/ibmvtpm.c;s/ieee1275/common/?
It looks like this now:
module = {
name = tpm;
common = commands/tpm.c;
ieee1275 = commands/ieee1275/ibmvtpm.c;
enable = powerpc_ieee1275;
};
Quoted 18 lines
Quoted 13 lines
grub-core/Makefile.core.def +3
-0+ enable = powerpc_ieee1275; +}; + module = { name = terminal; common = commands/terminal.c;grub-core/commands/ieee1275/ibmvtpm.c new file +0
-0grub-core/commands/ieee1275/ibmvtpm.c line 3
Quoted 3 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0@@ -0,0 +1,118 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation Copyright (C) 2021 Free Software Foundation, Inc.
Quoted 1 line
Or both if you strongly need IBM...
Doing both.
Quoted 22 lines
Quoted 22 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +21
-0+* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +* +* IBM vTPM support code. +*/ + +#include <grub/err.h> +#include <grub/types.h> +#include <grub/tpm.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h>
Quoted 8 lines
grub-core/commands/ieee1275/ibmvtpm.c line 32
Quoted 7 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +7
-0+#include <grub/mm.h> +#include <grub/misc.h> + +static grub_ieee1275_ihandle_t grub_tpm_ihandle; +static grub_uint8_t grub_tpm_version; + +static void grub_ieee1275_tpm_init (grub_ieee1275_ihandle_t *tpm_ihandle)You can drop from static functions, variables, etc. names "
grub_" prefix.
Done.
Quoted 14 lines
grub-core/commands/ieee1275/ibmvtpm.c line 39
Quoted 8 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +7
-0+{ +static int init_called =0 ; + +if (!init_called) { + init_called =1 ; +grub_ieee1275_open ("/vdevice/vtpm" , &grub_tpm_ihandle); + }Incorrect formatting. It should be
if (!init_called)
{ init_called = 1; grub_ieee1275_open ("/vdevice/vtpm", &grub_tpm_ihandle);
Quoted 6 lines
}
You can always refer to
grub-core/kern/efi/sb.cto get formatting examples for various pieces of the GRUB code.Please fix similar issues below too.
Done.
Quoted 26 lines
Quoted 14 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +13
-0+ *tpm_ihandle = grub_tpm_ihandle; +} + +static grub_err_t +grub_tpm_get_tpm_version (grub_uint8_t *protocol_version) +{ +static int version_probed =0 ; +grub_ieee1275_phandle_t vtpm; +char buffer[20 ]; +grub_ssize_t buffer_size; + +if (!version_probed) { + version_probed =1 ;grub-core/commands/ieee1275/ibmvtpm.c line 63
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +10
-0+if (!grub_ieee1275_finddevice ("/vdevice/vtpm" , &vtpm) && + !grub_ieee1275_get_property (vtpm,"compatible" , buffer, +sizeof buffer, &buffer_size) && + !grub_strcmp (buffer,"IBM,vtpm20" )) { + grub_tpm_version =2 ; + } + } + *protocol_version = grub_tpm_version; + +return 0 ;You ignore this value later.
Quoted 4 lines
I think the prototype of this function should be following:
grub_uint8_tget_tpm_version(void)Which means you should return the TPM version.
Done
Quoted 5 lines
grub-core/commands/ieee1275/ibmvtpm.c line 66
Quoted 4 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+} + +static grub_int8_tstatic
grub_err_t
Done
Quoted 8 lines
grub-core/commands/ieee1275/ibmvtpm.c line 72
Quoted 7 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +6
-0+grub_tpm_handle_find (grub_ieee1275_ihandle_t *tpm_handle, + grub_uint8_t *protocol_version) +{ +grub_ieee1275_tpm_init (tpm_handle); +if (*tpm_handle ==NULL ) +return 0 ;return
GRUB_ERR_UNKNOWN_DEVICE;
Done
Quoted 5 lines
grub-core/commands/ieee1275/ibmvtpm.c line 76
Quoted 4 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +3
-0+grub_tpm_get_tpm_version (protocol_version); + +return 1 ;return
GRUB_ERR_NONE;
Done
Quoted 23 lines
grub-core/commands/ieee1275/ibmvtpm.c line 85
Quoted 10 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+} + +static grub_err_t +grub_tpm2_log_event (grub_ieee1275_ihandle_t tpm_handle,unsigned char *buf, +grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +static int error_displayed; +bool succ;s/bool/grub_err_t/
grub-core/commands/ieee1275/ibmvtpm.c line 94
Quoted 9 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +9
-0+ + succ =grub_ieee1275_ibmvtpm_2hash_ext_log (tpm_handle, + pcr,EV_IPL , + description, +grub_strlen (description) +1 , + buf, size); +if (!succ && !error_displayed) { + error_displayed =1 ; +grub_printf ("2HASH-EXT-LOG failed: Firmware is likely too old.\n" );s/grub_printf/grub_error/
Quoted 14 lines
grub-core/commands/ieee1275/ibmvtpm.c line 105
Quoted 11 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +11
-0+ } + +return 0 ; +} + +grub_err_t +grub_tpm_measure (unsigned char *buf,grub_size_t size,grub_uint8_t pcr, +const char *description) +{ +grub_ieee1275_ihandle_t tpm_handle; +grub_uint8_t protocol_version =0 ;It seems to me that you have the same information in the
grub_tpm_versionglobal variable. So, I think you should you use it and drop all instances ofprotocol_version.
Done
Quoted 37 lines
Quoted 37 lines
grub-core/commands/ieee1275/ibmvtpm.c new file +12
-0+/* Absence of a TPM isn't a failure. */ +if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) +return 0 ; + +grub_dprintf ("tpm" ,"log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE", %s\n" , + pcr, size, description); + +if (protocol_version ==2 ) +return grub_tpm2_log_event (tpm_handle, buf, size, pcr, description); + +return 0 ; +}grub-core/kern/ieee1275/ibmvtpm.c new file +18
-0@@ -0,0 +1,62 @@ +/* ibmvtpm.c - Client interface to access the IBM vTPM */ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2021 IBM Corporation +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/
Quoted 8 lines
grub-core/kern/ieee1275/ibmvtpm.c line 25
Quoted 7 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +7
-0+ +#include <grub/types.h> +#include <grub/misc.h> +#include <grub/ieee1275/ieee1275.h> +#include <grub/ieee1275/ibmvtpm.h> + +bool s/bool/grub_err_t/
All the other ones ( grub-core/kern/ieee1275/ieee1275.c ) actually have int. Using int now.
Quoted 9 lines
grub-core/kern/ieee1275/ibmvtpm.c line 31
Quoted 7 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +6
-0+grub_ieee1275_ibmvtpm_2hash_ext_log (grub_uint32_t ihandle, + grub_uint8_t pcrindex, + grub_uint32_t eventtype, + const char *description, + grub_size_t description_size, + void *buf, grub_size_t size)I cannot see any reason to make this function part of the GRUB kernel. I think it should be in
grub-core/commands/ieee1275/ibmvtpm.c.
Moved it.
Quoted 4 lines
grub-core/kern/ieee1275/ibmvtpm.c line 33
Quoted 3 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +2
-0+{ +struct tpm_2hash_ext_log Please define this struct before the function, somewhere after includes.
Done.
Quoted 14 lines
Quoted 4 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +3
-0+ { +struct grub_ieee1275_common_hdr common; +grub_ieee1275_cell_t method;grub-core/kern/ieee1275/ibmvtpm.c line 46
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +10
-0+grub_ieee1275_cell_t ihandle; +grub_ieee1275_cell_t size; +void *buf; +grub_ieee1275_cell_t description_size; +const char *description; +grub_ieee1275_cell_t eventtype; +grub_ieee1275_cell_t pcrindex; +grub_ieee1275_cell_t catch_result; +grub_ieee1275_cell_t rc; + }
Quoted 1 line
GRUB_PACKED?
Per the other examples in the code this doesn't seem to be necessary. I also replaced void * and char * with the grub_ieee1275_cell_t.
Quoted 10 lines
Quoted 10 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +9
-0+ args; + +INIT_IEEE1275_COMMON (&args.common,"call-method" ,8 ,2 ); + args.method = (grub_ieee1275_cell_t )"2hash-ext-log" ; + args.ihandle = ihandle; + args.pcrindex = pcrindex; + args.eventtype = eventtype; + args.description = description; + args.description_size = description_size;
Quoted 8 lines
grub-core/kern/ieee1275/ibmvtpm.c line 62
Quoted 7 lines
grub-core/kern/ieee1275/ibmvtpm.c new file +7
-0+ args.buf = buf; + args.size = (grub_ieee1275_cell_t ) size; + +if (IEEE1275_CALL_ENTRY_FN (&args) ==-1 ) +return false; +return !!args.rc; +}Daniel
Thanks.