@@ -124,3 +124,26 @@ u64 __init efi_get_fdt_params(struct efi_memory_map_data *mm)
pr_info("UEFI not found.\n");
return 0;
}
+
+bool __init efi_secureboot_enabled_in_fdt(void)
+{
+ const void *fdt = initial_boot_params;
+ int node;
+ u32 secboot;
+
+
+ node = fdt_path_offset(fdt, "/chosen");
+
+ if (node < 0) {
+ pr_err("chosen node not found.\n");
+ return false;
+ }
+
+ if (!efi_get_fdt_prop(fdt, node, "linux,uefi-secure-boot",
+ "SECURE BOOT", &secboot, sizeof(secboot))) {
+ if (secboot)
+ return true;
+ }
+
+ return false;
+}
@@ -663,6 +663,7 @@ extern int efi_mem_reserve_persistent(phys_addr_t addr, u64 size);
extern void efi_initialize_iomem_resources(struct resource *code_resource,
struct resource *data_resource, struct resource *bss_resource);
extern u64 efi_get_fdt_params(struct efi_memory_map_data *data);
+extern bool __init efi_secureboot_enabled_in_fdt(void);
extern struct kobject *efi_kobj;
extern int efi_reboot_quirk_mode;
Add a helper to query the UEFI secureboot param from the chosen node in FDT. Signed-off-by: Chester Lin <clin@suse.com> --- drivers/firmware/efi/fdtparams.c | 23 +++++++++++++++++++++++ include/linux/efi.h | 1 + 2 files changed, 24 insertions(+)