-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
efi: Get and store the secure boot status
Get the firmware's secure-boot status in the kernel boot wrapper and stash it somewhere that the main kernel image can find. The efi_get_secureboot() function is extracted from the ARM stub and (a) generalised so that it can be called from x86 and (b) made to use efi_call_runtime() so that it can be run in mixed-mode. For x86, it is stored in boot_params and can be overridden by the boot loader or kexec. This allows secure-boot mode to be passed on to a new kernel. Suggested-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Matt Fleming <matt@codeblueprint.co.uk> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/1486380166-31868-5-git-send-email-ard.biesheuvel@linaro.org [ Small readability edits. ] Signed-off-by: Ingo Molnar <mingo@kernel.org>
- Loading branch information
David Howells
authored and
Ingo Molnar
committed
Feb 7, 2017
1 parent
e58910c
commit de8cb45
Showing
8 changed files
with
88 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Secure boot handling. | ||
* | ||
* Copyright (C) 2013,2014 Linaro Limited | ||
* Roy Franz <roy.franz@linaro.org | ||
* Copyright (C) 2013 Red Hat, Inc. | ||
* Mark Salter <msalter@redhat.com> | ||
* | ||
* This file is part of the Linux kernel, and is made available under the | ||
* terms of the GNU General Public License version 2. | ||
*/ | ||
#include <linux/efi.h> | ||
#include <asm/efi.h> | ||
|
||
/* BIOS variables */ | ||
static const efi_guid_t efi_variable_guid = EFI_GLOBAL_VARIABLE_GUID; | ||
static const efi_char16_t const efi_SecureBoot_name[] = { | ||
'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 | ||
}; | ||
static const efi_char16_t const efi_SetupMode_name[] = { | ||
'S', 'e', 't', 'u', 'p', 'M', 'o', 'd', 'e', 0 | ||
}; | ||
|
||
#define get_efi_var(name, vendor, ...) \ | ||
efi_call_runtime(get_variable, \ | ||
(efi_char16_t *)(name), (efi_guid_t *)(vendor), \ | ||
__VA_ARGS__); | ||
|
||
/* | ||
* Determine whether we're in secure boot mode. | ||
*/ | ||
enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table_arg) | ||
{ | ||
u8 secboot, setupmode; | ||
unsigned long size; | ||
efi_status_t status; | ||
|
||
size = sizeof(secboot); | ||
status = get_efi_var(efi_SecureBoot_name, &efi_variable_guid, | ||
NULL, &size, &secboot); | ||
if (status != EFI_SUCCESS) | ||
goto out_efi_err; | ||
|
||
size = sizeof(setupmode); | ||
status = get_efi_var(efi_SetupMode_name, &efi_variable_guid, | ||
NULL, &size, &setupmode); | ||
if (status != EFI_SUCCESS) | ||
goto out_efi_err; | ||
|
||
if (secboot == 0 || setupmode == 1) | ||
return efi_secureboot_mode_disabled; | ||
|
||
pr_efi(sys_table_arg, "UEFI Secure Boot is enabled.\n"); | ||
return efi_secureboot_mode_enabled; | ||
|
||
out_efi_err: | ||
pr_efi_err(sys_table_arg, "Could not determine UEFI Secure Boot status.\n"); | ||
if (status == EFI_NOT_FOUND) | ||
return efi_secureboot_mode_disabled; | ||
return efi_secureboot_mode_unknown; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters