From: Nikos Nikoleris <nikos.nikoleris@arm.com>
To: Andrew Jones <andrew.jones@linux.dev>
Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, pbonzini@redhat.com,
alexandru.elisei@arm.com, ricarkol@google.com,
shahuang@redhat.com
Subject: Re: [kvm-unit-tests PATCH v6 19/32] lib/efi: Add support for reading an FDT
Date: Thu, 8 Jun 2023 10:48:43 +0100 [thread overview]
Message-ID: <cfff1069-3668-1c8d-e842-c4c19632447c@arm.com> (raw)
In-Reply-To: <20230608-315a460eea93647e2514114c@orel>
On 08/06/2023 07:55, Andrew Jones wrote:
> 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
>
Thanks Drew, I missed this.
Thanks,
Nikos
>> + 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
>>>
next prev parent reply other threads:[~2023-06-08 9:48 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 16:08 [kvm-unit-tests PATCH v6 00/32] EFI and ACPI support for arm64 Nikos Nikoleris
2023-05-30 16:08 ` [kvm-unit-tests PATCH v6 01/32] lib: Move acpi header and implementation to lib Nikos Nikoleris
2023-05-30 16:08 ` [kvm-unit-tests PATCH v6 02/32] x86: Move x86_64-specific EFI CFLAGS to x86_64 Makefile Nikos Nikoleris
2023-05-30 16:08 ` [kvm-unit-tests PATCH v6 03/32] lib: Apply Lindent to acpi.{c,h} Nikos Nikoleris
2023-05-30 16:08 ` [kvm-unit-tests PATCH v6 04/32] lib: Fix style for acpi.{c,h} Nikos Nikoleris
2023-05-30 16:08 ` [kvm-unit-tests PATCH v6 05/32] lib/acpi: Convert table names to Linux style Nikos Nikoleris
2023-05-30 16:08 ` [kvm-unit-tests PATCH v6 06/32] x86: Avoid references to fields of ACPI tables Nikos Nikoleris
2023-05-30 16:08 ` [kvm-unit-tests PATCH v6 07/32] lib/acpi: Ensure all struct definition for ACPI tables are packed Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 08/32] lib/acpi: Add support for the XSDT table Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 09/32] lib/acpi: Extend the definition of the FADT table Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 10/32] devicetree: Check that fdt is not NULL in dt_available() Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 11/32] arm64: Add support for setting up the PSCI conduit through ACPI Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 12/32] arm64: Add support for discovering the UART " Nikos Nikoleris
2023-06-08 17:18 ` Nadav Amit
2023-06-08 17:24 ` Nadav Amit
2023-06-09 7:21 ` Andrew Jones
2023-06-09 14:06 ` Nikos Nikoleris
2023-06-09 14:31 ` Andrew Jones
2023-06-10 1:13 ` Nadav Amit
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 13/32] arm64: Add support for timer initialization " Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 14/32] arm64: Add support for cpu " Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 15/32] arm64: Add support for gic " Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 16/32] lib/printf: Support for precision modifier in printf Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 17/32] lib/printf: Add support for printing wide strings Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 18/32] lib/efi: Add support for getting the cmdline Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 19/32] lib/efi: Add support for reading an FDT Nikos Nikoleris
2023-06-07 16:58 ` Andrew Jones
2023-06-08 6:55 ` Andrew Jones
2023-06-08 9:48 ` Nikos Nikoleris [this message]
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 20/32] arm/arm64: Rename etext to _etext Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 21/32] lib: Avoid ms_abi for calls related to EFI on arm64 Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 22/32] arm64: Add a new type of memory type flag MR_F_RESERVED Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 23/32] arm64: Add a setup sequence for systems that boot through EFI Nikos Nikoleris
2023-06-10 1:17 ` Nadav Amit
2023-06-12 7:54 ` Andrew Jones
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 24/32] arm64: Copy code from GNU-EFI Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 25/32] arm64: Change GNU-EFI imported code to use defined types Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 26/32] arm64: Use code from the gnu-efi when booting with EFI Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 27/32] lib: Avoid external dependency in libelf Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 28/32] arm64: Add support for efi in Makefile Nikos Nikoleris
2023-06-08 20:41 ` Nadav Amit
2023-06-09 7:36 ` Andrew Jones
2023-06-09 17:14 ` Nadav Amit
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 29/32] lib: arm: Print test exit status Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 30/32] arm64: debug: Make inline assembly symbols global Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 31/32] arm64: Add an efi/run script Nikos Nikoleris
2023-05-30 16:09 ` [kvm-unit-tests PATCH v6 32/32] arm64: Use the provided fdt when booting through EFI Nikos Nikoleris
2023-06-07 18:52 ` [kvm-unit-tests PATCH v6 00/32] EFI and ACPI support for arm64 Andrew Jones
2023-06-08 7:01 ` Andrew Jones
2023-06-10 8:32 ` Nadav Amit
2023-06-12 7:52 ` Andrew Jones
2023-06-12 9:52 ` Nikos Nikoleris
2023-06-12 10:41 ` Andrew Jones
2023-06-12 10:43 ` Nikos Nikoleris
2023-06-12 15:59 ` Nadav Amit
2023-06-12 21:53 ` Nikos Nikoleris
2023-06-13 11:21 ` Andrew Jones
2023-06-13 12:54 ` Nadav Amit
2023-07-01 12:18 ` Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cfff1069-3668-1c8d-e842-c4c19632447c@arm.com \
--to=nikos.nikoleris@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=andrew.jones@linux.dev \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=pbonzini@redhat.com \
--cc=ricarkol@google.com \
--cc=shahuang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox