| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Secure boot handling. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Roy Franz <roy.franz@linaro.org |
|---|
| 6 | 7 | * Copyright (C) 2013 Red Hat, Inc. |
|---|
| 7 | 8 | * Mark Salter <msalter@redhat.com> |
|---|
| 8 | | - * |
|---|
| 9 | | - * This file is part of the Linux kernel, and is made available under the |
|---|
| 10 | | - * terms of the GNU General Public License version 2. |
|---|
| 11 | 9 | */ |
|---|
| 12 | 10 | #include <linux/efi.h> |
|---|
| 13 | 11 | #include <asm/efi.h> |
|---|
| .. | .. |
|---|
| 21 | 19 | |
|---|
| 22 | 20 | /* SHIM variables */ |
|---|
| 23 | 21 | static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID; |
|---|
| 24 | | -static const efi_char16_t shim_MokSBState_name[] = L"MokSBState"; |
|---|
| 25 | | - |
|---|
| 26 | | -#define get_efi_var(name, vendor, ...) \ |
|---|
| 27 | | - efi_call_runtime(get_variable, \ |
|---|
| 28 | | - (efi_char16_t *)(name), (efi_guid_t *)(vendor), \ |
|---|
| 29 | | - __VA_ARGS__); |
|---|
| 22 | +static const efi_char16_t shim_MokSBState_name[] = L"MokSBStateRT"; |
|---|
| 30 | 23 | |
|---|
| 31 | 24 | /* |
|---|
| 32 | 25 | * Determine whether we're in secure boot mode. |
|---|
| .. | .. |
|---|
| 34 | 27 | * Please keep the logic in sync with |
|---|
| 35 | 28 | * arch/x86/xen/efi.c:xen_efi_get_secureboot(). |
|---|
| 36 | 29 | */ |
|---|
| 37 | | -enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table_arg) |
|---|
| 30 | +enum efi_secureboot_mode efi_get_secureboot(void) |
|---|
| 38 | 31 | { |
|---|
| 39 | 32 | u32 attr; |
|---|
| 40 | 33 | u8 secboot, setupmode, moksbstate; |
|---|
| .. | .. |
|---|
| 60 | 53 | |
|---|
| 61 | 54 | /* |
|---|
| 62 | 55 | * See if a user has put the shim into insecure mode. If so, and if the |
|---|
| 63 | | - * variable doesn't have the runtime attribute set, we might as well |
|---|
| 64 | | - * honor that. |
|---|
| 56 | + * variable doesn't have the non-volatile attribute set, we might as |
|---|
| 57 | + * well honor that. |
|---|
| 65 | 58 | */ |
|---|
| 66 | 59 | size = sizeof(moksbstate); |
|---|
| 67 | 60 | status = get_efi_var(shim_MokSBState_name, &shim_guid, |
|---|
| .. | .. |
|---|
| 70 | 63 | /* If it fails, we don't care why. Default to secure */ |
|---|
| 71 | 64 | if (status != EFI_SUCCESS) |
|---|
| 72 | 65 | goto secure_boot_enabled; |
|---|
| 73 | | - if (!(attr & EFI_VARIABLE_RUNTIME_ACCESS) && moksbstate == 1) |
|---|
| 66 | + if (!(attr & EFI_VARIABLE_NON_VOLATILE) && moksbstate == 1) |
|---|
| 74 | 67 | return efi_secureboot_mode_disabled; |
|---|
| 75 | 68 | |
|---|
| 76 | 69 | secure_boot_enabled: |
|---|
| 77 | | - pr_efi(sys_table_arg, "UEFI Secure Boot is enabled.\n"); |
|---|
| 70 | + efi_info("UEFI Secure Boot is enabled.\n"); |
|---|
| 78 | 71 | return efi_secureboot_mode_enabled; |
|---|
| 79 | 72 | |
|---|
| 80 | 73 | out_efi_err: |
|---|
| 81 | | - pr_efi_err(sys_table_arg, "Could not determine UEFI Secure Boot status.\n"); |
|---|
| 74 | + efi_err("Could not determine UEFI Secure Boot status.\n"); |
|---|
| 82 | 75 | return efi_secureboot_mode_unknown; |
|---|
| 83 | 76 | } |
|---|