From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 8/8] efi: add veriable to report secure boot support and status
Date: Mon, 27 Feb 2017 11:19:30 +0100 [thread overview]
Message-ID: <1488190770-4034-8-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1488190770-4034-1-git-send-email-plagnioj@jcrosoft.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/efi/efi-device.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index db8b25147..6ed7f12b3 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -354,11 +354,41 @@ static void efi_businfo(struct device_d *dev)
}
}
+static int efi_is_secure_boot(void)
+{
+ uint8_t *val;
+ int ret = 0;
+
+ val = efi_get_variable("SecureBoot", &efi_global_variable_guid, NULL);
+ if (!IS_ERR(val)) {
+ ret = *val;
+ free(val);
+ }
+
+ return ret != 1;
+}
+
+static int efi_is_setup_mode(void)
+{
+ uint8_t *val;
+ int ret = 0;
+
+ val = efi_get_variable("SetupMode", &efi_global_variable_guid, NULL);
+ if (!IS_ERR(val)) {
+ ret = *val;
+ free(val);
+ }
+
+ return ret != 1;
+}
+
static int efi_init_devices(void)
{
char *fw_vendor = NULL;
u16 sys_major = efi_sys_table->hdr.revision >> 16;
u16 sys_minor = efi_sys_table->hdr.revision & 0xffff;
+ int secure_boot = efi_is_secure_boot();
+ int setup_mode = efi_is_setup_mode();
fw_vendor = strdup_wchar_to_char((const wchar_t *)efi_sys_table->fw_vendor);
@@ -374,6 +404,9 @@ static int efi_init_devices(void)
dev_add_param_int_ro(efi_bus.dev, "major", sys_major, "%u");
dev_add_param_int_ro(efi_bus.dev, "minor", sys_minor, "%u");
dev_add_param_int_ro(efi_bus.dev, "fw_revision", efi_sys_table->fw_revision, "%u");
+ dev_add_param_int_ro(efi_bus.dev, "secure_boot", secure_boot, "%d");
+ dev_add_param_int_ro(efi_bus.dev, "secure_mode",
+ secure_boot & setup_mode, "%u");
efi_bus.dev->info = efi_businfo;
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2017-02-27 10:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 10:14 [PATCH 0/8] add generic EFI timer Jean-Christophe PLAGNIOL-VILLARD
2017-02-27 10:19 ` [PATCH 1/8] efi: add prototype and definition for creating and closing event Jean-Christophe PLAGNIOL-VILLARD
2017-02-27 10:19 ` [PATCH 2/8] efi: add prototype and definition for setting timer Jean-Christophe PLAGNIOL-VILLARD
2017-02-27 10:19 ` [PATCH 3/8] efi: move LoaderTimeInitUSec and LoaderDevicePartUUID to postcore initcall Jean-Christophe PLAGNIOL-VILLARD
2017-02-27 10:19 ` [PATCH 4/8] efi: move x86 clocksource init at core initcall level Jean-Christophe PLAGNIOL-VILLARD
2017-02-27 10:19 ` [PATCH 5/8] clocksource: allow to have multiple device from clock source Jean-Christophe PLAGNIOL-VILLARD
2017-02-28 7:09 ` Sascha Hauer
2017-03-01 15:52 ` Jean-Christophe PLAGNIOL-VILLARD
2017-03-02 7:36 ` Sascha Hauer
2017-02-27 10:19 ` [PATCH 6/8] efi: move x86 clocksource to device/driver Jean-Christophe PLAGNIOL-VILLARD
2017-02-27 10:19 ` [PATCH 7/8] efi: clocksoure: use event for timer Jean-Christophe PLAGNIOL-VILLARD
2017-03-13 10:30 ` Michael Olbrich
2017-03-13 10:52 ` Jean-Christophe PLAGNIOL-VILLARD
2017-03-13 13:16 ` [PATCH] fixup! efi: clocksoure: add EFI event timer Michael Olbrich
2017-03-13 15:55 ` Jean-Christophe PLAGNIOL-VILLARD
2017-03-14 7:16 ` Sascha Hauer
2017-02-27 10:19 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
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=1488190770-4034-8-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/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