From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 324ACC433F5 for ; Sun, 3 Oct 2021 09:24:04 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AB7261B44 for ; Sun, 3 Oct 2021 09:24:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5AB7261B44 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4C35283310; Sun, 3 Oct 2021 11:23:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="iY+a05Sh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A2528311B; Sun, 3 Oct 2021 11:23:35 +0200 (CEST) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3D79F829FC for ; Sun, 3 Oct 2021 11:23:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.fritz.box (ip-88-152-144-157.hsi03.unitymediagroup.de [88.152.144.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 05BEF41A6B; Sun, 3 Oct 2021 09:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1633253005; bh=TOJTOVubDt3w9ngU/zrbjVd1HdHM+BLyxkdfWunFU5U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iY+a05Sh1UI78UP4ytN3BYUo4jGgMhYi7m2BqPq8Lvo+1zowAEQmXzKL9UPPIGzmm AEQByvONjNsr+VW0VnTbC8zfYA1UoI9v8MqwsCgaQgMYNg8iT2uO8OiIR3sEyh3Md+ xQ4mv+Gp+m/qfR1kt71Cm23vX2PMcArRheMDGUJAPgwCt9iBa9q3Ri7KQe1M8uCeY5 qlrb5aYYBJx98XOR9D9B21TTbNuL7KMMjJZu3xlLAoT5iqKcZOnaqMhTq551T+1t8x FPtt/DEAHu/ySDKfgWjPwVw7AGm0Pf0MU7kXsxFHi1wqlXQixcnZfJ4cr04jRX7oKt xvaF4BmTb8PcQ== From: Heinrich Schuchardt To: u-boot@lists.denx.de Cc: Alexander Graf , Ilias Apalodimas , Masahisa Kojima , AKASHI Takahiro , Sughosh Ganu , Heinrich Schuchardt Subject: [PATCH v3 2/4] efi_loader: function to get GUID for variable name Date: Sun, 3 Oct 2021 11:23:18 +0200 Message-Id: <20211003092320.4671-3-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211003092320.4671-1-heinrich.schuchardt@canonical.com> References: <20211003092320.4671-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean In multiple places we need the default GUID matching a variable name. The patch provides a library function. For secure boot related variables like 'PK', 'KEK', 'db' a lookup table is used. For all other variable names EFI_GLOBAL_VARIABLE is returned. Signed-off-by: Heinrich Schuchardt --- v3: no change v2: adjust function documentation --- include/efi_variable.h | 11 +++++++++++ lib/efi_loader/efi_var_common.c | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/include/efi_variable.h b/include/efi_variable.h index 8f666b2309..74909e8ec6 100644 --- a/include/efi_variable.h +++ b/include/efi_variable.h @@ -256,6 +256,17 @@ efi_status_t efi_init_secure_state(void); enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, const efi_guid_t *guid); +/** + * efi_auth_var_get_guid() - get the predefined GUID for a variable name + * + * For secure boot related variables a lookup table is used to determine + * the GUID. For all other variables EFI_GLOBAL_VARIABLE is returned. + * + * @name: name of UEFI variable + * Return: guid of UEFI variable + */ +const efi_guid_t *efi_auth_var_get_guid(const u16 *name); + /** * efi_get_next_variable_name_mem() - Runtime common code across efi variable * implementations for GetNextVariable() diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index e179932124..3cbb7c96c2 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -385,6 +385,15 @@ enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, return EFI_AUTH_VAR_NONE; } +const efi_guid_t *efi_auth_var_get_guid(const u16 *name) +{ + for (size_t i = 0; i < ARRAY_SIZE(name_type); ++i) { + if (!u16_strcmp(name, name_type[i].name)) + return name_type[i].guid; + } + return &efi_global_variable_guid; +} + /** * efi_get_var() - read value of an EFI variable * -- 2.32.0