On Wed, Jun 07, 2023 at 06:58:22PM +0200, Andrew Jones wrote: > On Tue, May 30, 2023 at 05:09:11PM +0100, Nikos Nikoleris wrote: > ... > > +static void* efi_get_var(efi_handle_t handle, struct efi_loaded_image_64 *image, efi_char16_t *var) > > +{ > > + efi_status_t status = EFI_SUCCESS; > > + void *val = NULL; > > + uint64_t val_size = 100; > > + efi_guid_t efi_var_guid = EFI_VAR_GUID; > > + > > + while (efi_grow_buffer(&status, &val, val_size)) > > + status = efi_rs_call(get_variable, var, &efi_var_guid, NULL, &val_size, val); > > + > > + return val; > > +} > > I made the following changes to the above function > > @@ lib/efi.c: static char *efi_convert_cmdline(struct efi_loaded_image_64 *image, i > + uint64_t val_size = 100; > + efi_guid_t efi_var_guid = EFI_VAR_GUID; > + > -+ while (efi_grow_buffer(&status, &val, val_size)) > ++ while (efi_grow_buffer(&status, &val, val_size + 1)) I just fixed this fix by changing the '+ 1' to '+ sizeof(efi_char16_t)' and then force pushed arm/queue. Thanks, drew > + status = efi_rs_call(get_variable, var, &efi_var_guid, NULL, &val_size, val); > + > ++ if (val) > ++ ((efi_char16_t *)val)[val_size / sizeof(efi_char16_t)] = L'\0'; > ++ > + return val; > +} > + > > Before ensuring the dtb pathname was nul-terminated efi_load_image() > was reading garbage and unable to find the dtb file. > > Thanks, > drew > > > > + > > +static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > > +{ > > + efi_char16_t var[] = ENV_VARNAME_DTBFILE; > > + efi_char16_t *val; > > + void *fdt = NULL; > > + int fdtsize; > > + > > + val = efi_get_var(handle, image, var); > > + if (val) > > + efi_load_image(handle, image, &fdt, &fdtsize, val); > > + > > + return fdt; > > +} > > + > > efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab) > > { > > int ret; > > @@ -211,6 +330,7 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab) > > } > > setup_args(cmdline_ptr); > > > > + efi_bootinfo.fdt = efi_get_fdt(handle, image); > > /* Set up efi_bootinfo */ > > efi_bootinfo.mem_map.map = ↦ > > efi_bootinfo.mem_map.map_size = &map_size; > > -- > > 2.25.1 > >