From nobody Tue Feb 10 08:27:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+92350+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92350+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1660200851; cv=none; d=zohomail.com; s=zohoarc; b=OMGY+YOf/FEqpL6xftGDYEmPfLheuNluye0Hr797l+Xc7xL9N2aJjV7gIMERurhX/csSShRLS0r+QJvks2MdhTJMP3dKStUbbtwQyT8CpjbM5ArybVeeCGqtwBvoIZ5LT2CjGLKxvF9SvemjmbL+YVVKQ05LkZpxFHgA3a3dOsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660200851; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Sll7KoRRPLK2FUfDNNj5PsEeDWcqflpn0cHT0Ty6sFg=; b=Jb0OXfsB26x0xDBtzUqEvCZ4WsSrBQ3mdnm8k9dQs+F0B8qyyMG5HJ2Urap3sZ4f8tsKqa7Q/N+5mvFwEwtUkMvyGgDvvo+b+BuBbhu+VdODc4UDHcFdJIlS6G7lSSY8mVLr/JIomiLQrDjjlKg4s06CmkARK33SZrAFM1V2w8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92350+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1660200851880302.2924807710888; Wed, 10 Aug 2022 23:54:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id LyOXYY1788612xjCn04sR3e5; Wed, 10 Aug 2022 23:54:11 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.3579.1660200849685231102 for ; Wed, 10 Aug 2022 23:54:10 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10435"; a="377565733" X-IronPort-AV: E=Sophos;i="5.93,228,1654585200"; d="scan'208";a="377565733" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2022 23:54:09 -0700 X-IronPort-AV: E=Sophos;i="5.93,228,1654585200"; d="scan'208";a="673586261" X-Received: from moisespe-mobl.amr.corp.intel.com (HELO jvang-mobl.amr.corp.intel.com) ([10.212.171.64]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2022 23:54:09 -0700 From: "Judah Vang" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Nishant C Mistry Subject: [edk2-devel] [PATCH v4 06/28] MdeModulePkg: Add Null ProtectedVariable Library Date: Wed, 10 Aug 2022 23:53:15 -0700 Message-Id: <20220811065337.2068-7-judah.vang@intel.com> In-Reply-To: <20220811065337.2068-1-judah.vang@intel.com> References: <20220811065337.2068-1-judah.vang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,judah.vang@intel.com X-Gm-Message-State: l8E4qVl1ny1czEziROyP38i6x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1660200851; bh=zPYIQ797+iiCg1JP6oizRqSGlcS6t2T+qyS+qznaFLE=; h=Cc:Date:From:Reply-To:Subject:To; b=SfXHBGpazCQmaXQmZBykUBx+fh4BJt+tuw6DFC3kJLNq9hKv577caKWbuSfqibF913p +6bdf2i+sG2JKGpfo1Xi8EQZAkqJUBg6Lh0a4nVwbufsgjG3wz3s//dNSXi+60LiKsfMI +Y5f0eLFzet8eDgXoE3dwJNNJ9baMNuj7bg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1660200853795100022 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2594 V4: Applied code review comments - removed APIs that are not being used. V1: Add Null versions of the ProtectedVariable Library. This will be the default libraries for platforms that do not support ProtectedVariable. Cc: Jian J Wang Cc: Liming Gao Cc: Nishant C Mistry Signed-off-by: Jian J Wang Signed-off-by: Nishant C Mistry Signed-off-by: Judah Vang Reviewed-by: Jian J Wang --- MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf= | 34 ++ MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariable.c = | 336 ++++++++++++++++++++ 2 files changed, 370 insertions(+) diff --git a/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariabl= eLibNull.inf b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVaria= bleLibNull.inf new file mode 100644 index 000000000000..6a17191c4e1e --- /dev/null +++ b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNul= l.inf @@ -0,0 +1,34 @@ +## @file +# Provides null version of protected variable services. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010029 + BASE_NAME =3D ProtectedVariableLibNull + FILE_GUID =3D 352C6A1B-403A-4E37-8517-FAA50BC45251 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 0.1 + LIBRARY_CLASS =3D ProtectedVariableLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + ProtectedVariable.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + diff --git a/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariabl= e.c b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariable.c new file mode 100644 index 000000000000..074559f84f52 --- /dev/null +++ b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariable.c @@ -0,0 +1,336 @@ +/** @file + NULL version of ProtectedVariableLib used to disable protected variable = services. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include +#include + +/** + + Initialization for protected varibale services. + + @param[in] ContextIn Pointer to variable service context needed by + protected variable. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibInitialize ( + IN PROTECTED_VARIABLE_CONTEXT_IN *ContextIn + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Prepare for variable update. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibWriteInit ( + VOID + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Update a variable with protection provided by this library. + + @param[in,out] CurrVariable Variable to be updated. It's NULL if + adding a new variable. + @param[in] CurrVariableInDel In-delete-transiion copy of updating= variable. + @param[in,out] NewVariable Buffer of new variable data. + Buffer of "MetaDataHmacVar" and new + variable (encrypted). + @param[in,out] NewVariableSize Size of NewVariable. + Size of (encrypted) NewVariable and + "MetaDataHmacVar". + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibUpdate ( + IN OUT VARIABLE_HEADER *CurrVariable, + IN VARIABLE_HEADER *CurrVariableInDel, + IN OUT VARIABLE_HEADER *NewVariable, + IN OUT UINTN *NewVariableSize + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Finalize a variable updating after it's written to NV variable storage + successfully. + + @param[in] NewVariable Buffer of new variables and MetaDataHm= acVar. + @param[in] VariableSize Size of buffer pointed by NewVariable. + @param[in] StoreIndex New index of the variable in store. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibWriteFinal ( + IN VARIABLE_HEADER *NewVariable, + IN UINTN VariableSize, + IN UINT64 StoreIndex + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Retrieve plain data, if encrypted, of given variable. + + @param[in] Variable Pointer to header of a Variable. + @param[in,out] Data Pointer to plain data of the given va= riable. + @param[in,out] DataSize Size of data returned or data buffer = needed. + @param[in] AuthFlag Auth-variable indicator. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibGetData ( + IN VARIABLE_HEADER *Variable, + IN OUT VOID *Data, + IN OUT UINT32 *DataSize, + IN BOOLEAN AuthFlag + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Get the specified protected variable. + + @param[in] VariableName Pointer to variable name. + @param[in] VariableGuid Pointer to vairable GUID. + @param[out] Attributes Pointer to attributes. + @param[in,out] DataSize Pointer to data size. + @param[out] Data Pointer to data. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibGet ( + IN CONST CHAR16 *VariableName, + IN CONST EFI_GUID *VariableGuid, + OUT UINT32 *Attributes, + IN OUT UINTN *DataSize, + OUT VOID *Data OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Find the protected variable. + + @param[in,out] VarInfo Pointer to structure containing variable= information. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibFind ( + IN OUT PROTECTED_VARIABLE_INFO *VarInfo + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Find next protected variable. + + @param[in,out] VariableNameSize Pointer to size of variable name. + @param[in,out] VariableName Pointer to variable name. + @param[in,out] VariableGuid Pointer to vairable GUID. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibFindNext ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VariableGuid + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Find next protected variable stub. + + @param[in,out] VarInfo Pointer to structure containing variable= information. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibFindNextEx ( + IN OUT PROTECTED_VARIABLE_INFO *VarInfo + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Get protected variable by information. + + @param[in,out] VarInfo Pointer to structure containing variable= information. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibGetByInfo ( + IN OUT PROTECTED_VARIABLE_INFO *VarInfo + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Get protected variable by name. + + @param[in] VariableName Pointer to variable name. + @param[in] VariableGuid Pointer to vairable GUID. + @param[out] Attributes Pointer to attributes. + @param[in,out] DataSize Pointer to data size. + @param[out] Data Pointer to data. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibGetByName ( + IN CONST CHAR16 *VariableName, + IN CONST EFI_GUID *VariableGuid, + OUT UINT32 *Attributes, + IN OUT UINTN *DataSize, + OUT VOID *Data OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Get protected variable by name. + + @param[in] Variable Pointer to variable name. + @param[in,out] Data Pointer to variable data. + @param[in,out] DataSize Pointer to data size. + @param[in] AuthFlag Authenticate flag. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibGetByBuffer ( + IN VARIABLE_HEADER *Variable, + IN OUT VOID *Data, + IN OUT UINT32 *DataSize, + IN BOOLEAN AuthFlag + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Refresh variable information changed by variable service. + + @param[in] Variable Pointer to buffer of the updated variable. + @param[in] VariableSize Size of variable pointed by Variable. + @param[in] StoreIndex New index of the variable in store. + @param[in] RefreshData Flag to indicate if the variable has been u= pdated. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibRefresh ( + IN VARIABLE_HEADER *Variable, + IN UINTN VariableSize, + IN UINT64 StoreIndex, + IN BOOLEAN RefreshData + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Get sorted protected variable list. + + @param[in,out] Buffer Pointer to buffer. + @param[in,out] NumElements Pointer to number of elements. + + @retval EFI_UNSUPPORTED Unsupported to process protected varia= ble. + +**/ +EFI_STATUS +EFIAPI +ProtectedVariableLibGetSortedList ( + IN OUT EFI_PHYSICAL_ADDRESS **Buffer, + IN OUT UINTN *NumElements + ) +{ + return EFI_UNSUPPORTED; +} + +/** + + Determine if the variable is the HMAC variable. + + @param[in] VariableName Pointer to variable name. + + @return FALSE Variable is not HMAC variable + +**/ +BOOLEAN +ProtectedVariableLibIsHmac ( + IN CHAR16 *VariableName + ) +{ + return FALSE; +} --=20 2.35.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92350): https://edk2.groups.io/g/devel/message/92350 Mute This Topic: https://groups.io/mt/92953531/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-