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 E5EB9C433F5 for ; Wed, 6 Oct 2021 06:25:36 +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 C0AAF611AE for ; Wed, 6 Oct 2021 06:25:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C0AAF611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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 2150881918; Wed, 6 Oct 2021 08:25:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="swXC/r/T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 73D5B82F00; Wed, 6 Oct 2021 08:25:30 +0200 (CEST) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E72CD82EA5 for ; Wed, 6 Oct 2021 08:25:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wr1-x42f.google.com with SMTP id e12so5312635wra.4 for ; Tue, 05 Oct 2021 23:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CKZf6VaXCUH0y6UfqyEonWUa7F7Qhw4myD2USvZnvo0=; b=swXC/r/TNn1zo6c1b22UHh1sxroxY/RwkrIe0Q802Waw9Zvz73xDhZwi1Ct0nacowb gc5K31vmiNd7AF6Ft5MrVWzdFyI+XofZl+pd1gFX4hXWzQozMe3EHAWuQFKlHvj5mJcD LvEkzXgI5L7D8pObMRsdz4e39gYIiBdHgAm5mqo6yAsVLxQbnc8qTclfgNMSjvYbyzB5 IHHcORsADmeHrGfFc02hdDVYadbAIN5G9cCRYUtLJ1+WXlrw8H6GA4kT1j3CZ9oEBq6C HLMxN0FZKS73RHCqIouxlUTkZEgt6yCELXpqxzg7P5Jc2Tlw1WckX4Uj44AxLSHq2R12 oggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CKZf6VaXCUH0y6UfqyEonWUa7F7Qhw4myD2USvZnvo0=; b=zRmhPKoIAo7zijUsvfPBhhFvgo0NFpK5wnHjKod52uvQ0QHbkqjCATfyGt+Oz5zwJy +v7QQvEPhwR01kNWg9FEBmu02k14oIFUezp33hBB39Ea18IN92DEHEOkRMmJ1aK047xr x/v1cwrs8C/WuViNgNp2zD0bt8Ksas4hsr0nhXLUmMdopA2QtFedqRlk78q+amu4XQP4 +QL0YRvIudhkytiNu5+MmE8FTFIiJt8WcIqo7iJ98YjhqIi0gwMdvVzuDuDJd6lD1C25 x4iPTC7ID1/iMFf5JQHbO1Kqrzr3MqxyGU5IIOXP+tXwSy0flpIMeKW3QWaGtb2bmUpp TqKA== X-Gm-Message-State: AOAM5302tt9LlJarsGcMOt3TBcqSkG+kdv7sFCh62vypt+X+S/p+UNYA 2dInUhL8hTwFLRas/SJ66WbVaQ== X-Google-Smtp-Source: ABdhPJwneQ7rEZ21TIvBrPUJru8zzWO+1jd2JDcW4vVyZDs0IqgGO4zzkRTyTcwxFSrlRt1IwDaRdA== X-Received: by 2002:a5d:6481:: with SMTP id o1mr27227273wri.140.1633501526468; Tue, 05 Oct 2021 23:25:26 -0700 (PDT) Received: from apalos.home (ppp-94-66-220-209.home.otenet.gr. [94.66.220.209]) by smtp.gmail.com with ESMTPSA id k22sm20163502wrd.59.2021.10.05.23.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 23:25:26 -0700 (PDT) Date: Wed, 6 Oct 2021 09:25:23 +0300 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, Alexander Graf , Masahisa Kojima , AKASHI Takahiro , Sughosh Ganu Subject: Re: [PATCH v3 2/4] efi_loader: function to get GUID for variable name Message-ID: References: <20211003092320.4671-1-heinrich.schuchardt@canonical.com> <20211003092320.4671-3-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211003092320.4671-3-heinrich.schuchardt@canonical.com> 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 On Sun, Oct 03, 2021 at 11:23:18AM +0200, Heinrich Schuchardt wrote: > 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 > Reviewed-by: Ilias Apalodimas