Re: [PATCH V2 1/2] Abstract out support for locating an EFI config table

2019-06-13 Thread Jarkko Sakkinen
On Fri, Jun 07, 2019 at 01:51:46PM -0700, Matthew Garrett wrote:
> We want to grab a pointer to the TPM final events table, so abstract out
> the existing code for finding an FDT table and make it generic.
> 
> Signed-off-by: Matthew Garrett 

Reviewed-by: Jarkko Sakkinen 

/Jarkko


Re: [PATCH V2 1/2] Abstract out support for locating an EFI config table

2019-06-12 Thread Jarkko Sakkinen
On Mon, Jun 10, 2019 at 10:46:35AM -0700, Matthew Garrett wrote:
> On Mon, Jun 10, 2019 at 9:58 AM Jarkko Sakkinen
>  wrote:
> >
> > On Fri, Jun 07, 2019 at 01:51:46PM -0700, Matthew Garrett wrote:
> > > We want to grab a pointer to the TPM final events table, so abstract out
> > > the existing code for finding an FDT table and make it generic.
> > >
> > > Signed-off-by: Matthew Garrett 
> >
> > Just to clarify are these extensions to what you did before and not
> > something that needs be squashed your commits pipelined for v5.3?
> 
> Correct - they handle a corner case. Ideally they'd hit 5.3 as well,
> but if you'd prefer I'm ok waiting.

Probably makes sense to have them in the PR.

/Jarkko


Re: [PATCH V2 1/2] Abstract out support for locating an EFI config table

2019-06-10 Thread Matthew Garrett
On Mon, Jun 10, 2019 at 9:58 AM Jarkko Sakkinen
 wrote:
>
> On Fri, Jun 07, 2019 at 01:51:46PM -0700, Matthew Garrett wrote:
> > We want to grab a pointer to the TPM final events table, so abstract out
> > the existing code for finding an FDT table and make it generic.
> >
> > Signed-off-by: Matthew Garrett 
>
> Just to clarify are these extensions to what you did before and not
> something that needs be squashed your commits pipelined for v5.3?

Correct - they handle a corner case. Ideally they'd hit 5.3 as well,
but if you'd prefer I'm ok waiting.


Re: [PATCH V2 1/2] Abstract out support for locating an EFI config table

2019-06-10 Thread Jarkko Sakkinen
On Fri, Jun 07, 2019 at 01:51:46PM -0700, Matthew Garrett wrote:
> We want to grab a pointer to the TPM final events table, so abstract out
> the existing code for finding an FDT table and make it generic.
> 
> Signed-off-by: Matthew Garrett 

Just to clarify are these extensions to what you did before and not
something that needs be squashed your commits pipelined for v5.3?

/Jarkko


Re: [PATCH V2 1/2] Abstract out support for locating an EFI config table

2019-06-07 Thread Ard Biesheuvel
On Fri, 7 Jun 2019 at 22:52, Matthew Garrett  wrote:
>
> We want to grab a pointer to the TPM final events table, so abstract out
> the existing code for finding an FDT table and make it generic.
>
> Signed-off-by: Matthew Garrett 
> ---
>  .../firmware/efi/libstub/efi-stub-helper.c| 15 +++
>  drivers/firmware/efi/libstub/efistub.h|  2 ++
>  drivers/firmware/efi/libstub/fdt.c| 27 +++
>  3 files changed, 26 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c 
> b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index e4610e72b78f..1db780c0f07b 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
> @@ -926,3 +926,18 @@ efi_status_t efi_exit_boot_services(efi_system_table_t 
> *sys_table_arg,
>  fail:
> return status;
>  }
> +
> +void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid)
> +{
> +   efi_config_table_t *tables = (efi_config_table_t *)sys_table->tables;
> +   int i;
> +
> +   for (i = 0; i < sys_table->nr_tables; i++) {
> +   if (efi_guidcmp(tables[i].guid, guid) != 0)
> +   continue;
> +
> +   return (void *)tables[i].table;
> +   }
> +
> +   return NULL;
> +}
> diff --git a/drivers/firmware/efi/libstub/efistub.h 
> b/drivers/firmware/efi/libstub/efistub.h
> index 1b1dfcaa6fb9..7f1556fd867d 100644
> --- a/drivers/firmware/efi/libstub/efistub.h
> +++ b/drivers/firmware/efi/libstub/efistub.h
> @@ -65,6 +65,8 @@ efi_status_t check_platform_features(efi_system_table_t 
> *sys_table_arg);
>
>  efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
>
> +void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid);
> +
>  /* Helper macros for the usual case of using simple C variables: */
>  #ifndef fdt_setprop_inplace_var
>  #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
> diff --git a/drivers/firmware/efi/libstub/fdt.c 
> b/drivers/firmware/efi/libstub/fdt.c
> index 5440ba17a1c5..0bf0190917e0 100644
> --- a/drivers/firmware/efi/libstub/fdt.c
> +++ b/drivers/firmware/efi/libstub/fdt.c
> @@ -363,26 +363,17 @@ efi_status_t 
> allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
>
>  void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
>  {
> -   efi_guid_t fdt_guid = DEVICE_TREE_GUID;
> -   efi_config_table_t *tables;
> -   int i;
> +   void *fdt;
>
> -   tables = (efi_config_table_t *)sys_table->tables;
> +   fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID);
>
> -   for (i = 0; i < sys_table->nr_tables; i++) {
> -   void *fdt;
> +   if (!fdt)
> +   return NULL;
>
> -   if (efi_guidcmp(tables[i].guid, fdt_guid) != 0)
> -   continue;
> -
> -   fdt = (void *)tables[i].table;
> -   if (fdt_check_header(fdt) != 0) {
> -   pr_efi_err(sys_table, "Invalid header detected on 
> UEFI supplied FDT, ignoring ...\n");
> -   return NULL;
> -   }
> -   *fdt_size = fdt_totalsize(fdt);
> -   return fdt;
> +   if (fdt_check_header(fdt) != 0) {
> +   pr_efi_err(sys_table, "Invalid header detected on UEFI 
> supplied FDT, ignoring ...\n");
> +   return NULL;
> }
> -
> -   return NULL;
> +   *fdt_size = fdt_totalsize(fdt);
> +   return fdt;
>  }

Reviewed-by: Ard Biesheuvel 


[PATCH V2 1/2] Abstract out support for locating an EFI config table

2019-06-07 Thread Matthew Garrett
We want to grab a pointer to the TPM final events table, so abstract out
the existing code for finding an FDT table and make it generic.

Signed-off-by: Matthew Garrett 
---
 .../firmware/efi/libstub/efi-stub-helper.c| 15 +++
 drivers/firmware/efi/libstub/efistub.h|  2 ++
 drivers/firmware/efi/libstub/fdt.c| 27 +++
 3 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c 
b/drivers/firmware/efi/libstub/efi-stub-helper.c
index e4610e72b78f..1db780c0f07b 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -926,3 +926,18 @@ efi_status_t efi_exit_boot_services(efi_system_table_t 
*sys_table_arg,
 fail:
return status;
 }
+
+void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid)
+{
+   efi_config_table_t *tables = (efi_config_table_t *)sys_table->tables;
+   int i;
+
+   for (i = 0; i < sys_table->nr_tables; i++) {
+   if (efi_guidcmp(tables[i].guid, guid) != 0)
+   continue;
+
+   return (void *)tables[i].table;
+   }
+
+   return NULL;
+}
diff --git a/drivers/firmware/efi/libstub/efistub.h 
b/drivers/firmware/efi/libstub/efistub.h
index 1b1dfcaa6fb9..7f1556fd867d 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -65,6 +65,8 @@ efi_status_t check_platform_features(efi_system_table_t 
*sys_table_arg);
 
 efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
 
+void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid);
+
 /* Helper macros for the usual case of using simple C variables: */
 #ifndef fdt_setprop_inplace_var
 #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
diff --git a/drivers/firmware/efi/libstub/fdt.c 
b/drivers/firmware/efi/libstub/fdt.c
index 5440ba17a1c5..0bf0190917e0 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -363,26 +363,17 @@ efi_status_t 
allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
 
 void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
 {
-   efi_guid_t fdt_guid = DEVICE_TREE_GUID;
-   efi_config_table_t *tables;
-   int i;
+   void *fdt;
 
-   tables = (efi_config_table_t *)sys_table->tables;
+   fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID);
 
-   for (i = 0; i < sys_table->nr_tables; i++) {
-   void *fdt;
+   if (!fdt)
+   return NULL;
 
-   if (efi_guidcmp(tables[i].guid, fdt_guid) != 0)
-   continue;
-
-   fdt = (void *)tables[i].table;
-   if (fdt_check_header(fdt) != 0) {
-   pr_efi_err(sys_table, "Invalid header detected on UEFI 
supplied FDT, ignoring ...\n");
-   return NULL;
-   }
-   *fdt_size = fdt_totalsize(fdt);
-   return fdt;
+   if (fdt_check_header(fdt) != 0) {
+   pr_efi_err(sys_table, "Invalid header detected on UEFI supplied 
FDT, ignoring ...\n");
+   return NULL;
}
-
-   return NULL;
+   *fdt_size = fdt_totalsize(fdt);
+   return fdt;
 }
-- 
2.22.0.rc2.383.gf4fbbf30c2-goog