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 X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65E87C433F5 for ; Sun, 12 Sep 2021 19:19:34 +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 C92B660EFE for ; Sun, 12 Sep 2021 19:19:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C92B660EFE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de 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 A9C16804E7; Sun, 12 Sep 2021 21:19:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="KKFOoKj8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA05E82039; Sun, 12 Sep 2021 21:19:29 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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 884C780082 for ; Sun, 12 Sep 2021 21:19:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631474364; bh=jQ6QOHD9cU1hyR8SDtAcCu+RTj/SbImlxkZI2pitieo=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=KKFOoKj8UGJHkuoGra962BxNfDgJ+S7vl2UROwI6BqglZ2454NPD1zxyUJoZXGyM+ brNHrJCt9Vvjm0rBBNA7ze3DeGgg9XnIrS0h0k8ZxErRjFcDAcTr2DY5nSa708wN1T UPFDHjHN2td3yywjZWb64BemM67cGy7uhZxBOmFo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.189] ([46.253.247.65]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MiacR-1mt2rc48ZT-00fkL4; Sun, 12 Sep 2021 21:19:24 +0200 Subject: Re: [PATCH 1/4] efi_loader: treat UEFI variable name as const To: Ilias Apalodimas Cc: u-boot@lists.denx.de, AKASHI Takahiro , Sughosh Ganu , Masahisa Kojima , Alexander Graf References: <20210911072832.16991-1-xypron.glpk@gmx.de> <20210911072832.16991-2-xypron.glpk@gmx.de> From: Heinrich Schuchardt Message-ID: <7e0cd3a0-846a-a158-2e22-d329b0f64ed8@gmx.de> Date: Sun, 12 Sep 2021 21:19:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:zq97eOzZwUvgjvPftAZPXNxL6O0JcCriLb813KhXOGr1IA55SfM vnef5OmbzuYVXOnbO8ldmueo2wjZ83ZYovBOMKs3UvRmpVKD849fbQQ+ENGdy1cuvqktB5M BixSGSx2vXpfuD4euycHJgGUu2yOApUJ8ThBbCvigUoeKflh26iQ/slXUTj8bI1bnSvGTkL TmNo17Fz3hlavAAA825JQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:cLiLS2fVh8Y=:3ZfhUBOIwcGpuoATFWbzjr xy8UlY1w55LVIQDIAVHD++Z+iBXZMteVoWDIjK2UrqqjrYHZHFAY3fc9kXAo3nIro/AbKpW4c Q7XQd00e2+yXDurUBwinBinVYJpIrUlWNXRuB4tzgAd5KKnmR2vnR6LVlbvnGQNkLEHKYbAaY ml68MNbLryGxsJI2HGJlEfsAcLR+aoLtKBTKrxRmbk3gjEorDfB/Nw/i4fJMAUe7vQ/SrxMbO ZYb4DY2f3nF7Zz2uOxmpnJ42jShacn+7vwmGiCmDMnoaOGx0456O65boq0bKFOc+hqEBjKXXc r77/robUNwstGabevTnnsY3w6BYJ113EOd0pUrtyJ2sEEBkKqQ/CWozbWExkew3QmLpRbJLz9 Qi8itdjOdnCJY/+gMRr3kX5+qLoA09WKanisRjL4yZxwlQ0oZgWQBv/pQgyFCZNCIpeC01238 DhAisZbzTJ0+1ADNc+cedeEFnOLaoN5BhFWEPUNDLIytcWw1mdoDBOUH+Whkv05nEEuwjY4Wd B7Q2MXD60MnR0+uq2zTEvO+W0GIuNbbLZz1tb53vYeLOFH8Hd0uN/hEJdep3rgmLVZAATv4Sr r2qmz1ZiIYgdak1fQQ5S3ivoEK8ptMkxP6PCQsyx3JxKrJBsV9480dm6GgJnnL66O70gnSBvU 0ujWmfygOOzKJg5GpBSnkh0+IM8Oqq+qcCxtobNon+hSrZKystsd60Sv7TOQt5d827uMHcUaZ dcc0RhYJv/ZqNe1SGQQ29mYjJWtJsN7RkuofMFy0ok6Qei/8RTMeeBSCWaHh2WgPWT1VOUhDM OWJYZtCqpZ5ONNlXkixXfZ1WZupCmXA2RdviwhSNujmkpzzaJrHhMSmHd5SJRiXFAnBHRGZQN xtGOATKfJsz9CHW6kYjeWbeN98q2mjQ1ewXpE/azABA8H1IkJaPXukMBGOGzfmuRDmKT58d3b 4D7mJnX9QeXhAg62v81HW80HGQgIYsDurdP6UwIvbhguRg7288LXS7FbeVnLkEjnhStR4dAVv 0RpbdQ0ZC2bsCjyzAiXevuU2HRkKYqXjYAQpbX/UpPJ0R5Qxnhdta/5zMyQ8VcTPVN2wfIZ1X dPBrZjr3Rz4q6I= 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 9/11/21 4:10 PM, Ilias Apalodimas wrote: > Hi Heinrich, > > On Sat, Sep 11, 2021 at 09:28:29AM +0200, Heinrich Schuchardt wrote: >> Adjust several internal functions to treat UEFI variable names as const= . > > It's obvious what the patch does, but is there a reason ? I think that's= a > better fit for the commit log. Thanks for reviewing. We all this functions with const strings like "PE". It does not make sense to convert to from (u16 *) to (const u16 *) somewhere in the code. Instead the changed functions should offer an easily usable interface. I will rework the commit message. Best regards Heinrich > > Cheers > /Ilias >> >> Signed-off-by: Heinrich Schuchardt >> --- >> 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 *si= ze); >> +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 *variabl= e_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 *vendo= r, >> + 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 401acf3d4f..beb224f66a 100644 >> --- a/lib/efi_loader/efi_tcg2.c >> +++ b/lib/efi_loader/efi_tcg2.c >> @@ -1359,7 +1359,7 @@ static efi_status_t efi_append_scrtm_version(stru= ct udevice *dev) >> * Return: status code >> */ >> static efi_status_t tcg2_measure_variable(struct udevice *dev, u32 pc= r_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_c= ommon.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 =3D 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 *n= ame, 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 *si= ze) >> +void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn= _t *size) >> { >> efi_status_t ret; >> void *buf =3D 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_e= ntry *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 *vendo= r, >> + 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_variabl= e.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 *vendo= r, >> u32 *attributes, efi_uintn_t *data_size, void *data, >> u64 *timep) >> { >> @@ -219,7 +219,8 @@ efi_get_next_variable_name_int(efi_uintn_t *variabl= e_name_size, >> return efi_get_next_variable_name_mem(variable_name_size, variable_n= ame, 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_var= iable_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 n= ame_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 n= ame_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 =3D EFI_SUCCESS; >> struct var_check_property var_property; >> -- >> 2.30.2 >>