From patchwork Fri May 31 00:39:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 800684 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 835A84A35; Fri, 31 May 2024 00:41:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717116103; cv=fail; b=gBSEfUDnqMobS937OLXn7cL5yG34u19NsJSZtzNjyzS6eogQ+0NLUBOGi4QdA+sKQbYYZigUrYZhbOKrdf3mo+jUAuXoABZ4+B3p/2EHGX8ZW5YRXW17KruFskPEwDY3qIlzaEg9CMWlfhK/caHilt43Mr4fMDlef2XP2KOguK4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717116103; c=relaxed/simple; bh=DlvA/E2nmcmS5xGecWd8k1c8IFxOI4w3YHhOPOyp6WE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Tq0fHIImZeBqZTqcN7LsU4Y4YdoPpbHJPwuuxygQTFwoSHfHup6GoV7OcHKEMGv4lPZTxYpf13ywHh1vQ6cleI6jjahQMRo013dJXpxfJ56yJlPj1PDls5bcHFdI7VgHzd0Yt3NIfq46Qx3DrWC5eJ873obIFM8xsUHmFrBLnjs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44UFOGVq001930; Fri, 31 May 2024 00:40:06 GMT DKIM-Signature: =?utf-8?q?v=3D1=3B_a=3Drsa-sha256=3B_c=3Drelaxed/relaxed=3B_?= =?utf-8?q?d=3Doracle=2Ecom=3B_h=3Dcc=3Acontent-transfer-encoding=3Acontent-?= =?utf-8?q?type=3Adate=3Afrom=3Ain-reply-to=3Amessage-id=3Amime-version=3Are?= =?utf-8?q?ferences=3Asubject=3Ato=3B_s=3Dcorp-2023-11-20=3B_bh=3D0Om8nLy28U?= =?utf-8?q?yHmr6YMUm1fRB69CMsmRI0/fB6KqLCaic=3D=3B_b=3DOJJ4anwAYGbrdWHPYDsYu?= =?utf-8?q?Ex3xRL+Dqq+E4ogJVJKMV8MYa+LUt6vTi7mn0wnvFwdXkyR_cGAtLAobqNHqv8Tls?= =?utf-8?q?4Qq1ltbx0QL6QtLA0H36TRw7Dvz87ILmuFJdrxJh/D9B9GIDLSn_x3xE7XO7Q7oIg?= =?utf-8?q?UMZbzkGzYwbvP1DYpMBlSOYPkVgqrp+yOMnnJJYPkZAh9sMm/wnhaFZ_Me2fNGHCj?= =?utf-8?q?CUQ9XBQ3Ah96uZ+icw6IHg+f86KVGYo78aksCfm8MxTTzuPHqbNYqJt7Oin_X+Shk?= =?utf-8?q?IAcHBCXhArOYrgE1aaOEXHOLyFAVSxUb2HenYx8+vqF76+qp/UTUu7DWVNM5QnZ_j?= =?utf-8?q?Q=3D=3D_?= Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3yb8fcj64c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 31 May 2024 00:40:05 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44UMfwEu026627; Fri, 31 May 2024 00:40:04 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3yc5098hkr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 31 May 2024 00:40:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VX6+1+darxCn3+pXXPgbubExsqLOaDSpPGmYsyWuzqpkF01lUu4c+tmPhEAqcjSaeHlRJLL7iiF7Ie+S7osUxMJew6pP6poQqoFta4e73DO7vf6WBihl8SlTBxEYeRM9Iq61O48gvcir1BYAKA7/qKTDvufo1hQ/7wrNJUwdUiXkH3VGxfHX7NHUiuCn/70+n+pbULGhgCR0SVJAT5w41jV0XYicAByFVZEqtxDBWFPw6PnE8UjJ7n6v1cCohaJH7AAPsng+C2Q82/gnAFpazWkWDXi1f8Z3BzA0SLWIDK5OsVBSyeg2iWkyExE5vV2Y4QwCC/YMwWg9qL+XfRlVyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0Om8nLy28UyHmr6YMUm1fRB69CMsmRI0/fB6KqLCaic=; b=cN+r76Y+TZIqoLw50ZxL7XB1H1r1H1XzvJcGERPdNhxPDMJkRcwLJ2AdmaEzGIe4wImsjS6Dy3xwBwoeMtsJ8AtoRhTKnm9Z/8bGWomt4txItZmURL2soY3JNmgTi+pTdD1UrcSv3Yv4iZR7E4Gy/ChzqCRnOKy+kkp+YxJHeZcplZEkMk/AVfZXJb3m5yuqMaHkuvd6kMhU6I4TMWnHEueZZw9/rIVZj1OHNLlfgC3AZUJprMtoFCfPtNzfTPrUArQZXtYBeU+d8YdgMKbg4YtGUOt2IKuhQ2T2DYsnpqEwZ9XtSj9s8DHJMQPFu2EkNLlq9VzALAfkywpCwF9HPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0Om8nLy28UyHmr6YMUm1fRB69CMsmRI0/fB6KqLCaic=; b=rxOboEIf31ULuq45xJkEVvFK7RQibleWHf7BF42YXnR0lk1hfkSeCcoG+Qfs/AC+Tko8mha6SZ1n/AlAsw9l0Si046eK9VD4s0jvd+CxAzQ0MsKqEprg+BErT/T9Y0fwrAahpTTgXbGICx2JRrpPPkqRNjIAoemkcjPowiWT0qo= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by BY5PR10MB4274.namprd10.prod.outlook.com (2603:10b6:a03:206::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22; Fri, 31 May 2024 00:39:59 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::5527:ab55:d1e7:9c9a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::5527:ab55:d1e7:9c9a%4]) with mapi id 15.20.7633.018; Fri, 31 May 2024 00:39:58 +0000 From: Eric Snowberg To: linux-security-module@vger.kernel.org Cc: dhowells@redhat.com, dwmw2@infradead.org, herbert@gondor.apana.org.au, davem@davemloft.net, ardb@kernel.org, jarkko@kernel.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com, roberto.sassu@huawei.com, dmitry.kasatkin@gmail.com, mic@digikod.net, casey@schaufler-ca.com, stefanb@linux.ibm.com, eric.snowberg@oracle.com, ebiggers@kernel.org, rdunlap@infradead.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org Subject: [RFC PATCH v2 3/8] efi: Make clavis boot param persist across kexec Date: Thu, 30 May 2024 18:39:40 -0600 Message-ID: <20240531003945.44594-4-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240531003945.44594-1-eric.snowberg@oracle.com> References: <20240531003945.44594-1-eric.snowberg@oracle.com> X-ClientProxiedBy: BYAPR06CA0031.namprd06.prod.outlook.com (2603:10b6:a03:d4::44) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4150:EE_|BY5PR10MB4274:EE_ X-MS-Office365-Filtering-Correlation-Id: d971ca9c-1119-4c3c-9bc2-08dc810a3328 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015|7416005; X-Microsoft-Antispam-Message-Info: dmWN0vGyisNCJVymIIPz0zYXDbZswqs81YhfvTx6IUdmLMiv1JtJOElECedlbzSLCoTbKdkTXVsV6JVOpKWuyp6ubWYgquhsgjVBQ4oIwGBSFsmX71K0EzTQ8dpxmybxvQMFHt/30/DcG5kmT1hahyLnZCNlbX9ZxZUDyQKkXLCjLAKKE/Y+LbOgbg2oPJJKEr1M0tF8r8OvYIxpQUvMVzk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/Yw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4150.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(366007)(1800799015)(7416005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ClYOcwfDqEXVuYRPg6wxYRrikJrX+BoCPDpUH8NbJvYh39bv7s2ysDr7MzuoiUoZO29sWe0o//OacLSvwhME1NX3KIUfS2dXXNhHiNFR93KJxq84OMx1Vb9D/wtAutEIGIIlrkUdKEyu2LIDxzLvt43DY1mhGsZvwe22BtcTdThu/2ToaV23Mr/ALbZf4uFoPs6eq6pcrcyIFsALoNfFe1HUvJRtjlsR9HQowCqbJ8Cr8byGKOzfQ4JJgzBeyoUhNZjoiT3WZqCBWnqOlbh1IwQvOjWhV+KlQIQTWAr5axmKym+ywViD0qC4imiIz9b1mzunRWdLqfyP/BnwqRVOBEwo46EaUfrNyeKv08hR3zynL0EqYI+evmgUmHmHsrVGTmNshZr9Z/0yWKANMP3ZF2VZuQ37HG9bUGJWW5xnKvWtIVOGaJYYpYEImifASggoHeKShN8ffNbTkvQOzYwDPcUpZ86BHN486NVb4ZX/YX0h+00hD6eJVJZ164Zygu032wCDBeYsUtKWGodQSo98O3hgmr7J/FQq/wgE3l82fuZqdIbdWuyuRj9/ERaC7sEXxGKbUhQHj2Tl0RCE1B40EZKNmW6qiQkwK8JYCbHJTvyIdClLgWR9A19wDCPjiaHQ58W2P3sgYm50YHF4DYk5kAYpA5hdZeoX8HaXjxcFGqD61JC878QlA3+dkxhGDfDpJOwVttM0Qbr3SXM9KJqo6cr+VQMBQps4xinfODTYPh6TByxno8eEvT/61aV1ACXrjfOYPS8CokFxAMajwAg3uFf8Gm9yfHH9uvoPE5egIfb6/JsUvkQYb13ZOw/d2x6sL6nfGHgYux84ja+hlW7TAagcok8vjS+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GtnUbogw61D/dVbtIsa4ZnGNJlp8HIErCGFPFKjmwuqqN2KnesWOcdKaXcBMJ+bkcso0r+BxqJK32R/KQjfAbW1/kvSDaxfrQQyNwH2FbmFQI3A2+QXEyvDsfHA7fEFKbyJo3A5YgLuuz3ahtQbHVSGcJ0Lc+hsYE5KrJzQZECQCdI6eoCgjOqh89G7kvS5c4ee3M7tim0gTiogWs+bfA7cNw3oaGFe2b6fD+4NPCZjrA+fJIuS7dliTMtsbv5Ny78FAettCGMNE1reTqfer4z77vFCrw3mN3h0P+lWAkO7z6H9s1p00GAMhhmbv6smzS6JbBJlcEbLKszP6ETFcmG7Km7kWZxLwMml2+LeE8SLyNg6uWiUCfBp2xEs8O09D5o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d971ca9c-1119-4c3c-9bc2-08dc810a3328 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 00:39:58.9067 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ngGIFn8Cla4W2CsOpeVg417VbbEyIvxH+oST3NZGNbr02l3aC7qvH5vuDP9DhsxFvD6wh7eZMBb4XjGs6IYkzjyu9SqXKN/eGDS1OzTe1lY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4274 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-30_21,2024-05-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405310002 X-Proofpoint-GUID: bJzAoP1C6DrSybsYNatkBz4vE_yfYIJx X-Proofpoint-ORIG-GUID: bJzAoP1C6DrSybsYNatkBz4vE_yfYIJx Add the ability for the clavis boot param to persist across kexec. This is done by creating a RT variable before ExitBootServices is called. The new variable is called Clavis with a new GUID 193ccef6-348b-4f1f-a81b-0ea4b899dbf2. This variable does not have NVRAM set, signifying it was created during the Boot Services phase. This variable will persist across a kexec, however it will not persist across a power on reset. This same type of functionality is currently used within EFI shim to mirror MOK variables into the kernel. It is being used here so the clavis boot param can not be changed via kexec. If a different clavis boot param is used, the one stored in the RT variable will be used instead. Enforcement of which boot param to use will be done in a follow on patch. Signed-off-by: Eric Snowberg --- drivers/firmware/efi/Kconfig | 12 +++++++ drivers/firmware/efi/libstub/Makefile | 1 + drivers/firmware/efi/libstub/clavis.c | 33 +++++++++++++++++++ .../firmware/efi/libstub/efi-stub-helper.c | 2 ++ drivers/firmware/efi/libstub/efi-stub.c | 2 ++ drivers/firmware/efi/libstub/efistub.h | 8 +++++ drivers/firmware/efi/libstub/x86-stub.c | 2 ++ include/linux/efi.h | 1 + 8 files changed, 61 insertions(+) create mode 100644 drivers/firmware/efi/libstub/clavis.c diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 72f2537d90ca..8dcb5326d05d 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -186,6 +186,18 @@ config RESET_ATTACK_MITIGATION have been evicted, since otherwise it will trigger even on clean reboots. +config EARLY_CLAVIS + bool "Early clavis" + depends on EFI_STUB + help + Allow the clavis boot param to persist across kexec. This will create a + variable called Clavis with a 193ccef6-348b-4f1f-a81b-0ea4b899dbf2 GUID. + This variable does not have NVRAM set, signifying it was created during + the Boot Services phase. This variable will persist across a kexec, + however it will not persist across a power on reset. During kexec, if + a different clavis boot param is used, the one stored in the RT variable + will be used instead. + config EFI_RCI2_TABLE bool "EFI Runtime Configuration Interface Table Version 2 Support" depends on X86 || COMPILE_TEST diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index 06f0428a723c..4ceb055fc01c 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -74,6 +74,7 @@ $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o \ screen_info.o efi-stub-entry.o +lib-$(CONFIG_EARLY_CLAVIS) += clavis.o lib-$(CONFIG_ARM) += arm32-stub.o lib-$(CONFIG_ARM64) += kaslr.o arm64.o arm64-stub.o smbios.o lib-$(CONFIG_X86) += x86-stub.o diff --git a/drivers/firmware/efi/libstub/clavis.c b/drivers/firmware/efi/libstub/clavis.c new file mode 100644 index 000000000000..3a715e87a13a --- /dev/null +++ b/drivers/firmware/efi/libstub/clavis.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include "efistub.h" + +#define MAX_PARAM_LENGTH 64 +static const efi_char16_t clavis_param_name[] = L"Clavis"; +static const efi_guid_t clavis_guid = LINUX_EFI_CLAVIS_GUID; +static unsigned char param_data[MAX_PARAM_LENGTH]; +static size_t param_len; + +void efi_parse_clavis(char *option) +{ + if (!option) + return; + + param_len = strnlen(option, MAX_PARAM_LENGTH); + memcpy(param_data, option, param_len); +} + +void efi_setup_clavis(void) +{ + efi_status_t error; + + if (param_len) { + error = set_efi_var(clavis_param_name, &clavis_guid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + param_len, ¶m_data); + } + + if (error) + efi_err("Failed to set Clavis\n"); +} diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index de659f6a815f..3c45eaec325d 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -100,6 +100,8 @@ efi_status_t efi_parse_options(char const *cmdline) } else if (!strcmp(param, "video") && val && strstarts(val, "efifb:")) { efi_parse_option_graphics(val + strlen("efifb:")); + } else if (!strcmp(param, "clavis") && val) { + efi_parse_clavis(val); } } efi_bs_call(free_pool, buf); diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c index 958a680e0660..c15cd0d9e71f 100644 --- a/drivers/firmware/efi/libstub/efi-stub.c +++ b/drivers/firmware/efi/libstub/efi-stub.c @@ -183,6 +183,8 @@ efi_status_t efi_stub_common(efi_handle_t handle, install_memreserve_table(); + efi_setup_clavis(); + status = efi_boot_kernel(handle, image, image_addr, cmdline_ptr); free_screen_info(si); diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 27abb4ce0291..e43c4fb5aa97 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -1142,6 +1142,14 @@ static inline void efi_enable_reset_attack_mitigation(void) { } #endif +#ifdef CONFIG_EARLY_CLAVIS +void efi_parse_clavis(char *option); +void efi_setup_clavis(void); +#else +static inline void efi_parse_clavis(char *option) { } +static inline void efi_setup_clavis(void) { } +#endif + void efi_retrieve_eventlog(void); struct screen_info *alloc_screen_info(void); diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 1983fd3bf392..9457fc531cb4 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -975,6 +975,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle, setup_unaccepted_memory(); + efi_setup_clavis(); + status = exit_boot(boot_params, handle); if (status != EFI_SUCCESS) { efi_err("exit_boot() failed!\n"); diff --git a/include/linux/efi.h b/include/linux/efi.h index 418e555459da..6887d4712c77 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -422,6 +422,7 @@ void efi_native_runtime_setup(void); #define LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID EFI_GUID(0xd5d1de3c, 0x105c, 0x44f9, 0x9e, 0xa9, 0xbc, 0xef, 0x98, 0x12, 0x00, 0x31) #define RISCV_EFI_BOOT_PROTOCOL_GUID EFI_GUID(0xccd15fec, 0x6f73, 0x4eec, 0x83, 0x95, 0x3e, 0x69, 0xe4, 0xb9, 0x40, 0xbf) +#define LINUX_EFI_CLAVIS_GUID EFI_GUID(0x193ccef6, 0x348b, 0x4f1f, 0xa8, 0x1b, 0x0e, 0xa4, 0xb8, 0x99, 0xdb, 0xf2) /* * This GUID may be installed onto the kernel image's handle as a NULL protocol