diff mbox series

[2/6] efi/arm: a helper to parse secure boot param in fdt params

Message ID 20200904072905.25332-3-clin@suse.com (mailing list archive)
State New, archived
Headers show
Series add ima_arch support for ARM64 | expand

Commit Message

Chester Lin Sept. 4, 2020, 7:29 a.m. UTC
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(+)
diff mbox series

Patch

diff --git a/drivers/firmware/efi/fdtparams.c b/drivers/firmware/efi/fdtparams.c
index bb042ab7c2be..d58ec4119bcf 100644
--- a/drivers/firmware/efi/fdtparams.c
+++ b/drivers/firmware/efi/fdtparams.c
@@ -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;
+}
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 73db1ae04cef..315126b2f5e9 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -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;