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 C3468C433EF for ; Wed, 6 Oct 2021 06:28:10 +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 321F0611AE for ; Wed, 6 Oct 2021 06:28:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 321F0611AE 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 7F13783155; Wed, 6 Oct 2021 08:28:07 +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="zn9usMWP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 837F382EA6; Wed, 6 Oct 2021 08:28:04 +0200 (CEST) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (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 C214282051 for ; Wed, 6 Oct 2021 08:27:59 +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-x433.google.com with SMTP id t2so5308897wrb.8 for ; Tue, 05 Oct 2021 23:27:59 -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=SE4/AUVCobiGIahwF13exKOOCcHjwBjSpL6IbIuJ4iY=; b=zn9usMWPt9FUY04bg1g71VOVmzz7QVmBJEJFnpNKMlz8LggA9BLxiqco48eku47nxz FIzBzDv0wiqUfoN7n/6SiCpcU7GAWm7hEjeWooYPpXgJMyNeWxPRnvD3NWhqHzjDcIUz 7OtJsFI37v8H7fmSIAgeUy3EloNyhXZA5y7XeWJjk3WBeCBFH8tzVprITXl1l1WaB8uq oMiHc6pXDe2Ogoj3IGy0DtYco3Slgq67ys+8DNbGWKbg9C80uNnhoL+2a2ukv/Cvx/iu 854/lBvTEUqKchCpkASUExPWfRssSja4MPCLVX3MKdqgPkpGmy0wlnB8z9aS1hje3iMQ cl+w== 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=SE4/AUVCobiGIahwF13exKOOCcHjwBjSpL6IbIuJ4iY=; b=cgiNZ+KH1mHFDbnXpC7zmLgM2BgGZVUgjVuKuhSOPuJYJ+DwxUiqBbOS2XeF3a8NzD fMmtHZZXglWCqqSiTKkkYs8rcNdLWgqjLujQU/RGF2d0dMt9YAW+8w/ms3Zw3gLAQzQe y/vE6PdAIGaa8h0lUojxDVvaMfxc3OigkOUSPdoYYC8GJyGZSC1yAbAFp1v1B19AMF4S GhHmgGxT/nZiELP5rfyjl6L1jI3tDdBYkmtK+VG/sbncUFKxvkaB38t2c9f3qjb1ecxa AS2kH42Mbaw4KWKvb4jQAKeV8Ul9zIiMkbvqw/FBTgo59QutQdmhtN3dLddl8LQidfTu 6HQw== X-Gm-Message-State: AOAM530VF5zCQB7MhL2qWeYV7BNQ1skJ7XUsxhtuVP9yimw2VzrHHHUv t7Y9vcSqTiiwOXrEItmY3QRFUA== X-Google-Smtp-Source: ABdhPJzzrLt4VcoGA04rGhhhZyrHplv4jysL/MzoHZLFKJton06gdJweI/xWDWTRiQP2Ha373+tPAQ== X-Received: by 2002:adf:a292:: with SMTP id s18mr7852529wra.42.1633501679199; Tue, 05 Oct 2021 23:27:59 -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 u1sm20167518wrn.66.2021.10.05.23.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 23:27:58 -0700 (PDT) Date: Wed, 6 Oct 2021 09:27:56 +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 1/4] efi_loader: treat UEFI variable name as const Message-ID: References: <20211003092320.4671-1-heinrich.schuchardt@canonical.com> <20211003092320.4671-2-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211003092320.4671-2-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:17AM +0200, Heinrich Schuchardt wrote: > UEFI variable names are typically constants and hence should be defined as > const. Unfortunately some of our API functions do not define the parameters > for UEFI variable names as const. This requires unnecessary conversions. > > Adjust parameters of several internal functions to tre UEFI variable names > as const. > > Signed-off-by: Heinrich Schuchardt > --- > v3: > no change > v2: > adjust commit message > --- > include/efi_loader.h | 2 +- > include/efi_variable.h | 16 ++++++++++------ > lib/efi_loader/efi_tcg2.c | 2 +- > lib/efi_loader/efi_var_common.c | 5 +++-- > lib/efi_loader/efi_var_mem.c | 7 ++++--- > lib/efi_loader/efi_variable.c | 9 +++++---- > lib/efi_loader/efi_variable_tee.c | 16 ++++++++++------ > 7 files changed, 34 insertions(+), 23 deletions(-) > > diff --git a/include/efi_loader.h b/include/efi_loader.h > index c440962fe5..125052d002 100644 > --- a/include/efi_loader.h > +++ b/include/efi_loader.h > @@ -816,7 +816,7 @@ efi_status_t EFIAPI efi_query_variable_info( > u64 *remaining_variable_storage_size, > u64 *maximum_variable_size); > > -void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size); > +void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size); > > /* > * See section 3.1.3 in the v2.7 UEFI spec for more details on > diff --git a/include/efi_variable.h b/include/efi_variable.h > index 0440d356bc..8f666b2309 100644 > --- a/include/efi_variable.h > +++ b/include/efi_variable.h > @@ -32,7 +32,8 @@ enum efi_auth_var_type { > * @timep: authentication time (seconds since start of epoch) > * Return: status code > */ > -efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, > +efi_status_t efi_get_variable_int(const u16 *variable_name, > + const efi_guid_t *vendor, > u32 *attributes, efi_uintn_t *data_size, > void *data, u64 *timep); > > @@ -47,7 +48,8 @@ efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, > * @ro_check: check the read only read only bit in attributes > * Return: status code > */ > -efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor, > +efi_status_t efi_set_variable_int(const u16 *variable_name, > + const efi_guid_t *vendor, > u32 attributes, efi_uintn_t data_size, > const void *data, bool ro_check); > > @@ -224,7 +226,7 @@ void efi_var_mem_del(struct efi_var_entry *var); > * @time: time of authentication (as seconds since start of epoch) > * Result: status code > */ > -efi_status_t efi_var_mem_ins(u16 *variable_name, > +efi_status_t efi_var_mem_ins(const u16 *variable_name, > const efi_guid_t *vendor, u32 attributes, > const efi_uintn_t size1, const void *data1, > const efi_uintn_t size2, const void *data2, > @@ -251,7 +253,8 @@ efi_status_t efi_init_secure_state(void); > * @guid: guid of UEFI variable > * Return: identifier for authentication related variables > */ > -enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid); > +enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, > + const efi_guid_t *guid); > > /** > * efi_get_next_variable_name_mem() - Runtime common code across efi variable > @@ -280,8 +283,9 @@ efi_get_next_variable_name_mem(efi_uintn_t *variable_name_size, u16 *variable_na > * Return: status code > */ > efi_status_t __efi_runtime > -efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes, > - efi_uintn_t *data_size, void *data, u64 *timep); > +efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor, > + u32 *attributes, efi_uintn_t *data_size, void *data, > + u64 *timep); > > /** > * efi_get_variable_runtime() - runtime implementation of GetVariable() > diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c > index d3b8f93f14..ed1506012b 100644 > --- a/lib/efi_loader/efi_tcg2.c > +++ b/lib/efi_loader/efi_tcg2.c > @@ -1365,7 +1365,7 @@ static efi_status_t efi_append_scrtm_version(struct udevice *dev) > * Return: status code > */ > static efi_status_t tcg2_measure_variable(struct udevice *dev, u32 pcr_index, > - u32 event_type, u16 *var_name, > + u32 event_type, const u16 *var_name, > const efi_guid_t *guid, > efi_uintn_t data_size, u8 *data) > { > diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c > index a00bbf1620..e179932124 100644 > --- a/lib/efi_loader/efi_var_common.c > +++ b/lib/efi_loader/efi_var_common.c > @@ -374,7 +374,8 @@ bool efi_secure_boot_enabled(void) > return efi_secure_boot; > } > > -enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid) > +enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, > + const efi_guid_t *guid) > { > for (size_t i = 0; i < ARRAY_SIZE(name_type); ++i) { > if (!u16_strcmp(name, name_type[i].name) && > @@ -393,7 +394,7 @@ enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid) > * > * Return: buffer with variable data or NULL > */ > -void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size) > +void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size) > { > efi_status_t ret; > void *buf = NULL; > diff --git a/lib/efi_loader/efi_var_mem.c b/lib/efi_loader/efi_var_mem.c > index 3d335a8274..13909b1d26 100644 > --- a/lib/efi_loader/efi_var_mem.c > +++ b/lib/efi_loader/efi_var_mem.c > @@ -134,7 +134,7 @@ void __efi_runtime efi_var_mem_del(struct efi_var_entry *var) > } > > efi_status_t __efi_runtime efi_var_mem_ins( > - u16 *variable_name, > + const u16 *variable_name, > const efi_guid_t *vendor, u32 attributes, > const efi_uintn_t size1, const void *data1, > const efi_uintn_t size2, const void *data2, > @@ -274,8 +274,9 @@ efi_status_t efi_var_mem_init(void) > } > > efi_status_t __efi_runtime > -efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes, > - efi_uintn_t *data_size, void *data, u64 *timep) > +efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor, > + u32 *attributes, efi_uintn_t *data_size, void *data, > + u64 *timep) > { > efi_uintn_t old_size; > struct efi_var_entry *var; > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > index fa2b6bc7a8..5adc7f821a 100644 > --- a/lib/efi_loader/efi_variable.c > +++ b/lib/efi_loader/efi_variable.c > @@ -45,7 +45,7 @@ > * > * Return: status code > */ > -static efi_status_t efi_variable_authenticate(u16 *variable, > +static efi_status_t efi_variable_authenticate(const u16 *variable, > const efi_guid_t *vendor, > efi_uintn_t *data_size, > const void **data, u32 given_attr, > @@ -194,7 +194,7 @@ err: > return ret; > } > #else > -static efi_status_t efi_variable_authenticate(u16 *variable, > +static efi_status_t efi_variable_authenticate(const u16 *variable, > const efi_guid_t *vendor, > efi_uintn_t *data_size, > const void **data, u32 given_attr, > @@ -205,7 +205,7 @@ static efi_status_t efi_variable_authenticate(u16 *variable, > #endif /* CONFIG_EFI_SECURE_BOOT */ > > efi_status_t __efi_runtime > -efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, > +efi_get_variable_int(const u16 *variable_name, const efi_guid_t *vendor, > u32 *attributes, efi_uintn_t *data_size, void *data, > u64 *timep) > { > @@ -219,7 +219,8 @@ efi_get_next_variable_name_int(efi_uintn_t *variable_name_size, > return efi_get_next_variable_name_mem(variable_name_size, variable_name, vendor); > } > > -efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor, > +efi_status_t efi_set_variable_int(const u16 *variable_name, > + const efi_guid_t *vendor, > u32 attributes, efi_uintn_t data_size, > const void *data, bool ro_check) > { > diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c > index 51920bcb51..281f886124 100644 > --- a/lib/efi_loader/efi_variable_tee.c > +++ b/lib/efi_loader/efi_variable_tee.c > @@ -284,7 +284,8 @@ out: > * StMM can store internal attributes and properties for variables, i.e enabling > * R/O variables > */ > -static efi_status_t set_property_int(u16 *variable_name, efi_uintn_t name_size, > +static efi_status_t set_property_int(const u16 *variable_name, > + efi_uintn_t name_size, > const efi_guid_t *vendor, > struct var_check_property *var_property) > { > @@ -317,7 +318,8 @@ out: > return ret; > } > > -static efi_status_t get_property_int(u16 *variable_name, efi_uintn_t name_size, > +static efi_status_t get_property_int(const u16 *variable_name, > + efi_uintn_t name_size, > const efi_guid_t *vendor, > struct var_check_property *var_property) > { > @@ -361,7 +363,8 @@ out: > return ret; > } > > -efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, > +efi_status_t efi_get_variable_int(const u16 *variable_name, > + const efi_guid_t *vendor, > u32 *attributes, efi_uintn_t *data_size, > void *data, u64 *timep) > { > @@ -502,9 +505,10 @@ out: > return ret; > } > > -efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor, > - u32 attributes, efi_uintn_t data_size, > - const void *data, bool ro_check) > +efi_status_t efi_set_variable_int(const u16 *variable_name, > + const efi_guid_t *vendor, u32 attributes, > + efi_uintn_t data_size, const void *data, > + bool ro_check) > { > efi_status_t ret, alt_ret = EFI_SUCCESS; > struct var_check_property var_property; > -- > 2.32.0 > Reviewed-by: Ilias Apalodimas