Skip to content

Commit bf67fad

Browse files
committed
efi: Use more granular check for availability for variable services
The UEFI spec rev 2.8 permits firmware implementations to support only a subset of EFI runtime services at OS runtime (i.e., after the call to ExitBootServices()), so let's take this into account in the drivers that rely specifically on the availability of the EFI variable services. Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent fe4db90 commit bf67fad

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

drivers/firmware/efi/efi-pstore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static struct pstore_info efi_pstore_info = {
356356

357357
static __init int efivars_pstore_init(void)
358358
{
359-
if (!efi_enabled(EFI_RUNTIME_SERVICES))
359+
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES))
360360
return 0;
361361

362362
if (!efivars_kobject())

drivers/firmware/efi/efi.c

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,13 @@ static int __init efisubsys_init(void)
328328
return -ENOMEM;
329329
}
330330

331-
error = generic_ops_register();
332-
if (error)
333-
goto err_put;
334-
335-
if (efi_enabled(EFI_RUNTIME_SERVICES))
331+
if (efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES)) {
336332
efivar_ssdt_load();
333+
error = generic_ops_register();
334+
if (error)
335+
goto err_put;
336+
platform_device_register_simple("efivars", 0, NULL, 0);
337+
}
337338

338339
error = sysfs_create_group(efi_kobj, &efi_subsys_attr_group);
339340
if (error) {
@@ -358,7 +359,8 @@ static int __init efisubsys_init(void)
358359
err_remove_group:
359360
sysfs_remove_group(efi_kobj, &efi_subsys_attr_group);
360361
err_unregister:
361-
generic_ops_unregister();
362+
if (efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES))
363+
generic_ops_unregister();
362364
err_put:
363365
kobject_put(efi_kobj);
364366
return error;
@@ -650,20 +652,6 @@ void __init efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
650652
vendor);
651653
}
652654

653-
#ifdef CONFIG_EFI_VARS_MODULE
654-
static int __init efi_load_efivars(void)
655-
{
656-
struct platform_device *pdev;
657-
658-
if (!efi_enabled(EFI_RUNTIME_SERVICES))
659-
return 0;
660-
661-
pdev = platform_device_register_simple("efivars", 0, NULL, 0);
662-
return PTR_ERR_OR_ZERO(pdev);
663-
}
664-
device_initcall(efi_load_efivars);
665-
#endif
666-
667655
static __initdata char memory_type_name[][20] = {
668656
"Reserved",
669657
"Loader Code",

drivers/firmware/efi/efivars.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ int efivars_sysfs_init(void)
664664
struct kobject *parent_kobj = efivars_kobject();
665665
int error = 0;
666666

667-
if (!efi_enabled(EFI_RUNTIME_SERVICES))
667+
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES))
668668
return -ENODEV;
669669

670670
/* No efivars has been registered yet */

fs/efivarfs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static struct file_system_type efivarfs_type = {
252252

253253
static __init int efivarfs_init(void)
254254
{
255-
if (!efi_enabled(EFI_RUNTIME_SERVICES))
255+
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES))
256256
return -ENODEV;
257257

258258
if (!efivars_kobject())

0 commit comments

Comments
 (0)