[PATCH 08/13] Xen: EFI: Parse DT parameters for Xen specific UEFI

Ard Biesheuvel ard.biesheuvel at linaro.org
Tue Nov 17 03:25:58 PST 2015


On 17 November 2015 at 10:57,  <shannon.zhao at linaro.org> wrote:
> From: Shannon Zhao <shannon.zhao at linaro.org>
>
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
>
> Signed-off-by: Shannon Zhao <shannon.zhao at linaro.org>
> ---
>  drivers/firmware/efi/efi.c | 67 ++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 62 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index d6144e3..629bd06 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -24,6 +24,7 @@
>  #include <linux/of_fdt.h>
>  #include <linux/io.h>
>  #include <linux/platform_device.h>
> +#include <xen/xen.h>
>
>  struct efi __read_mostly efi = {
>         .mps        = EFI_INVALID_TABLE_ADDR,
> @@ -488,12 +489,60 @@ static __initdata struct {
>         UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>
> +static __initdata struct {
> +       const char name[32];
> +       const char propname[32];
> +       int offset;
> +       int size;
> +} xen_dt_params[] = {
> +       UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +       UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +       UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +       UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +       UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +

We discussed (and agreed afair) that dropping the "linux," prefix from
the DT properties was an acceptable change. If we do that, and reuse
the same names in the xen version (i.e., drop the "xen," prefix), we
could make this change a *lot* simpler.

>  struct param_info {
>         int verbose;
>         int found;
>         void *params;
>  };
>
> +static int __init fdt_find_xen_uefi_params(unsigned long node,
> +                                          const char *uname, int depth,
> +                                          void *data)
> +{
> +       struct param_info *info = data;
> +       const void *prop;
> +       void *dest;
> +       u64 val;
> +       int i, len;
> +
> +       if (xen_initial_domain() && (depth != 2 || strcmp(uname, "uefi") != 0))
> +               return 0;
> +
> +       for (i = 0; i < ARRAY_SIZE(xen_dt_params); i++) {
> +               prop = of_get_flat_dt_prop(node, xen_dt_params[i].propname,
> +                                          &len);
> +               if (!prop)
> +                       return 0;
> +               dest = info->params + xen_dt_params[i].offset;
> +               info->found++;
> +
> +               val = of_read_number(prop, len / sizeof(u32));
> +
> +               if (dt_params[i].size == sizeof(u32))
> +                       *(u32 *)dest = val;
> +               else
> +                       *(u64 *)dest = val;
> +
> +               if (info->verbose)
> +                       pr_info("  %s: 0x%0*llx\n", xen_dt_params[i].name,
> +                               xen_dt_params[i].size * 2, val);
> +       }
> +
> +       return 1;
> +}
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>                                        int depth, void *data)
>  {
> @@ -538,12 +587,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose)
>         info.found = 0;
>         info.params = params;
>
> -       ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
> -       if (!info.found)
> +       if (xen_initial_domain())
> +               ret = of_scan_flat_dt(fdt_find_xen_uefi_params, &info);
> +       else
> +               ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
> +       if (!info.found) {
>                 pr_info("UEFI not found.\n");
> -       else if (!ret)
> -               pr_err("Can't find '%s' in device tree!\n",
> -                      dt_params[info.found].name);
> +       } else if (!ret) {
> +               if (xen_initial_domain())
> +                       pr_err("Can't find '%s' in device tree!\n",
> +                              xen_dt_params[info.found].name);
> +               else
> +                       pr_err("Can't find '%s' in device tree!\n",
> +                              xen_dt_params[info.found].name);

Wrong array here

> +       }
>
>         return ret;
>  }
> --
> 2.1.0
>



More information about the linux-arm-kernel mailing list