linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chester Lin <clin@suse.com>
To: ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org,
	zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, corbet@lwn.net,
	mark.rutland@arm.com, vincenzo.frascino@arm.com,
	samitolvanen@google.com, masahiroy@kernel.org, mingo@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org,
	jlee@suse.com, clin@suse.com
Subject: [PATCH 2/6] efi/arm: a helper to parse secure boot param in fdt params
Date: Fri,  4 Sep 2020 15:29:01 +0800	[thread overview]
Message-ID: <20200904072905.25332-3-clin@suse.com> (raw)
In-Reply-To: <20200904072905.25332-1-clin@suse.com>

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 --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;
-- 
2.26.1


  parent reply	other threads:[~2020-09-04  7:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04  7:28 [PATCH 0/6] add ima_arch support for ARM64 Chester Lin
2020-09-04  7:29 ` [PATCH 1/6] efistub: pass uefi secureboot flag via fdt params Chester Lin
2020-09-11 15:01   ` Ard Biesheuvel
2020-09-14  8:05     ` Chester Lin
2020-10-05  2:20       ` Chester Lin
2020-10-12  8:20         ` Ard Biesheuvel
2020-09-04  7:29 ` Chester Lin [this message]
2020-09-04  7:29 ` [PATCH 3/6] efi: add secure boot flag Chester Lin
2020-09-04  7:29 ` [PATCH 4/6] efi/arm: check secure boot status in efi init Chester Lin
2020-09-04  7:29 ` [PATCH 5/6] arm64/ima: add ima arch support Chester Lin
2020-09-04 11:47   ` Mimi Zohar
2020-09-04  7:29 ` [PATCH 6/6] docs/arm: add the description of uefi-secure-boot param Chester Lin

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=20200904072905.25332-3-clin@suse.com \
    --to=clin@suse.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=jlee@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=masahiroy@kernel.org \
    --cc=mingo@kernel.org \
    --cc=samitolvanen@google.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    --cc=zohar@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).