Re: [PATCH v2] x86/boot: Use EFI setup data if provided

From: Junichi Nomura
Date: Thu Mar 28 2019 - 23:35:37 EST


On 3/29/19 8:11 AM, bhe@xxxxxxxxxx wrote:
> On 03/28/19 at 07:43am, Junichi Nomura wrote:
>> /* Search EFI system tables for RSDP. */
>> -static acpi_physical_address efi_get_rsdp_addr(void)
>> +static acpi_physical_address __efi_get_rsdp_addr(unsigned long config_tables, unsigned int nr_tables, int size, bool efi_64)
>
> Here parameter 'size' and 'efi_64' seems a little duplicated on
> functionality. Only passing efi_64 can deduce the size? Personal
> opinion.

Yes. But I'm not sure which is preferred.

The current code is:

__efi_get_rsdp_addr() {
for (i = 0; i < nr_tables; i++) {
config_tables += size;
if (efi_64) {
efi_config_table_64_t *tbl = (efi_config_table_64_t *)config_tables;
// get guid and table
} else {
efi_config_table_32_t *tbl = (efi_config_table_32_t *)config_tables;
// get guid and table
}
// check guid and return table if it's valid
}
}

If we remove "size" parameter, that will become:

__efi_get_rsdp_addr() {
for (i = 0; i < nr_tables; i++) {
if (efi_64) {
efi_config_table_64_t *tbl;
config_tables += sizeof(efi_config_table_64_t);
tbl = (efi_config_table_64_t *)config_tables;
// get guid and table
} else {
efi_config_table_32_t *tbl;
config_tables += sizeof(efi_config_table_32_t);
tbl = (efi_config_table_32_t *)config_tables;
// get guid and table
}
// check guid and return table if it's valid
}
}

Or we could create 2 functions, __efi_get_rsdp_addr32() and __efi_get_rsdp_addr64(),
and let efi_get_rsdp_addr() to choose which one to use based on signature.

> It might be worth adding code comments here to tell why we only care
> about 64bit kexec booting?

I think so. I'll add a comment.

--
Jun'ichi Nomura, NEC Corporation / NEC Solution Innovators, Ltd.