From nobody Thu May 2 13:05:30 2024 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+79244+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+79244+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1628835025; cv=none; d=zohomail.com; s=zohoarc; b=CvepiP/pWzVUSM/Eq8rt9LvLV0211ypADIhPDQMnfav9ZGvGUQSEdbDVXqrzg2BpXzHBlknYgyXzk0FKbQ0SaPpWy0xzr7eWGlXRS0zCN89kk9UC2scGu16Mg76XrB5Ug2RPe7/bWG1WkFFcqZ0gHwYmbXuiJI57HdYRBHLCVlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628835025; h=Content-Type: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=7CiC5lRwlF9Wkfm+ZpmiqCLed/z8GexJNy90Tf5yHsw=; b=PtZg2CSzHABdTCZXTQT2LXQvklZ3PtjUg0Lw447+AkFkz5EpsyT0S04H/cgTejbt17G4MqN94rWwHTDGz4/KUqIA0xzVM5/rE+VMma4bZfriRUauizis/CIQ/AC1NWsho1kjdbjYKRnOX/KQkKKiQ3z8XRjdKGacMhz5H6BXp7U= 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+79244+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1628835024919505.9328873275531; Thu, 12 Aug 2021 23:10:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NEIlYY1788612xLuu3MnqMLA; Thu, 12 Aug 2021 23:10:24 -0700 X-Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.33273.1628835018720586953 for ; Thu, 12 Aug 2021 23:10:23 -0700 X-Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Fri, 13 Aug 2021 14:10:03 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , , , , "'Kinney, Michael D'" Cc: "'Wang, Jian J'" , "'Zhang, Qi1'" , "'Kumar, Rahul1'" References: <20210730175517.2445-1-brbarkel@microsoft.com> <1696A3E2DE5C4DCB.1941@groups.io> <169A57BB10BEC566.13770@groups.io> <013f01d78fe3$cb33b270$619b1750$@byosoft.com.cn> In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbRVhURVJOQUxdIFtlZGsyLWRldmVsXSBbUEFUQ0ggdjEgMS8xXSBTZWN1cml0eVBrZy9MaWJyYXJ5OiBBZGQgVHBtMk52VW5kZWZpbmVTcGFjZVNwZWNpYWwgdG8gVHBtMkNvbW1hbmRMaWI=?= Date: Fri, 13 Aug 2021 14:10:04 +0800 Message-ID: <001901d79009$dc183b80$9448b280$@byosoft.com.cn> MIME-Version: 1.0 Thread-Index: AQKw0JBQkMjs/QxFtbsF8Gy1CafftAIpAp74AfH9d7QAtUSWqgGWjx0DAl9ljhMBakX6YQJA11zrAfHOyRipS1j1MA== 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,gaoliming@byosoft.com.cn X-Gm-Message-State: u70myP5sytJWqGjNswBvyYfIx1787277AA= Content-Type: multipart/related; boundary="----=_NextPart_000_001A_01D7904C.EA3FC140" Content-Language: zh-cn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1628835024; bh=WyYB4SJKBz5p8Nm8VOEAxnL6XzSlctU9SkxuSmll+/g=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=eBoAnZXev9oVXz90luivgmOtGFCuRtR0Zegs65yXJWWM19McytRf6NiFfGYQVJOfwnW 9vuilO47Hu6Zdqne0L1suXHpkgdoPqT/rmsGqKdOk4pHfrVleYb91BrzFMfcEqbWdFH+4 wD7XEVSO61VFPsx0/EyTJqy/SWK5AZfYXHA= X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1628835027589100002 ------=_NextPart_000_001A_01D7904C.EA3FC140 Content-Type: multipart/alternative; boundary="----=_NextPart_001_001B_01D7904C.EA3FC140" ------=_NextPart_001_001B_01D7904C.EA3FC140 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Jiewen: Yes. If the definition is to align the industry standard definition, I am = OK to add them into ECC exception.=20 =20 Thanks Liming =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io = =E4=BB=A3=E8=A1=A8 Yao, Jiewen =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B48=E6=9C=8813=E6=97=A5 10= :30 =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io; gaoliming@byosoft.com.cn= ; bret.barkelew@microsoft.com; bret@corthon.com; Kinney, Michael D =E6=8A=84=E9=80=81: Wang, Jian J ; Zhang, Qi1 ; Kumar, Rahul1 =E4=B8=BB=E9=A2=98: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/= Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib =20 Hi I have seen such exception in the industry standard file, such as=20 =20 https://github.com/tianocore/edk2/blob/master/MdePkg/Include/IndustryStanda= rd/Tpm20.h =20 #define TPM_CC_NV_UndefineSpaceSpecial (TPM_CC)(0x0000011F) #define TPM_CC_EvictControl (TPM_CC)(0x00000120) #define TPM_CC_HierarchyControl (TPM_CC)(0x00000121) #define TPM_CC_NV_UndefineSpace (TPM_CC)(0x00000122) #define TPM_CC_ChangeEPS (TPM_CC)(0x00000124) #define TPM_CC_ChangePPS (TPM_CC)(0x00000125) #define TPM_CC_Clear (TPM_CC)(0x00000126) #define TPM_CC_ClearControl (TPM_CC)(0x00000127) #define TPM_CC_ClockSet (TPM_CC)(0x00000128) #define TPM_CC_HierarchyChangeAuth (TPM_CC)(0x00000129) #define TPM_CC_NV_DefineSpace (TPM_CC)(0x0000012A) #define TPM_CC_PCR_Allocate (TPM_CC)(0x0000012B) #define TPM_CC_PCR_SetAuthPolicy (TPM_CC)(0x0000012C) #define TPM_CC_PP_Commands (TPM_CC)(0x0000012D) #define TPM_CC_SetPrimaryPolicy (TPM_CC)(0x0000012E) #define TPM_CC_FieldUpgradeStart (TPM_CC)(0x0000012F) #define TPM_CC_ClockRateAdjust (TPM_CC)(0x00000130) =20 https://github.com/tianocore/edk2/blob/master/MdePkg/Include/IndustryStanda= rd/Tpm12.h =20 #define TPM_ORD_ActivateIdentity ((TPM_COMMAND_CODE) 0x000= 0007A) #define TPM_ORD_AuthorizeMigrationKey ((TPM_COMMAND_CODE) 0x000= 0002B) #define TPM_ORD_CertifyKey ((TPM_COMMAND_CODE) 0x000= 00032) #define TPM_ORD_CertifyKey2 ((TPM_COMMAND_CODE) 0x000= 00033) #define TPM_ORD_CertifySelfTest ((TPM_COMMAND_CODE) 0x000= 00052) #define TPM_ORD_ChangeAuth ((TPM_COMMAND_CODE) 0x000= 0000C) #define TPM_ORD_ChangeAuthAsymFinish ((TPM_COMMAND_CODE) 0x000= 0000F) #define TPM_ORD_ChangeAuthAsymStart ((TPM_COMMAND_CODE) 0x000= 0000E) #define TPM_ORD_ChangeAuthOwner ((TPM_COMMAND_CODE) 0x000= 00010) =20 =20 I agree with Liming that if this is something completely defined by EDKII, = we should align with EDKII. =20 But if this is something copied from other standard, I prefer we keep them = as is and add those to exception list. That makes easy for the domain specific expert to review the code. =20 Can we submit patch to add those to ECC exception list? =20 Thank you Yao Jiewen =20 From: devel@edk2.groups.io > On Behalf Of gaoliming Sent: Friday, August 13, 2021 9:38 AM To: devel@edk2.groups.io ; bret.barkelew@micr= osoft.com ; Yao, Jiewen >; bret@corthon.com ; Kinney, Michael D > Cc: Wang, Jian J >; Z= hang, Qi1 >; Kumar, Rahul= 1 > Subject: =E5=9B=9E=E5=A4=8D: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] Securit= yPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib =20 Bret: I suggest to define new macro that follows EDKII style. This MACRO is only= used in CommandLib. Its impact should be small.=20 =20 Thanks Liming =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io > =E4=BB=A3=E8=A1= =A8 Bret Barkelew via groups.io =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B48=E6=9C=8813=E6=97=A5 8:= 24 =E6=94=B6=E4=BB=B6=E4=BA=BA: Yao, Jiewen >; devel@edk2.groups.io ; b= ret@corthon.com ; Kinney, Michael D > =E6=8A=84=E9=80=81: Wang, Jian J >; Zhang, Qi1 = >; Kumar, Rahul1 > =E4=B8=BB=E9=A2=98: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/= Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib =20 + @Kinney, Michael D =20 Mike, any thoughts on when =E2=80=9Csticking with the file convention=E2=80= =9D breaks ECC? Should I just ignore the rest of the file and pass ECC at a= ll costs? =20 - Bret=20 =20 From: Yao, Jiewen =20 Sent: Thursday, August 12, 2021 5:06 PM To: Bret Barkelew ; devel@edk2.groups.= io ; bret@corthon.com =20 Cc: Wang, Jian J ; Zhang, Qi1 ; Kumar, Rahul1 =20 Subject: RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Ad= d Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib =20 I don=E2=80=99t know the answer about ECC or PatchChecker. I just know we need pass CI to merge the patch. =20 Thank you Yao Jiewen =20 From: Bret Barkelew >=20 Sent: Friday, August 13, 2021 1:52 AM To: devel@edk2.groups.io ; bret@corthon.com <= mailto:bret@corthon.com>=20 Cc: Yao, Jiewen >; Wang= , Jian J >; Zhang, Qi= 1 >; Kumar, Rahul1 > Subject: RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Ad= d Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib =20 Thoughts? =20 - Bret=20 =20 From: devel@edk2.groups.io > on behalf of Bret Barkelew via groups.= io > Sent: Wednesday, August 11, 2021 12:37:52 PM To: devel@edk2.groups.io >; bret@corthon.com > Cc: Yao, Jiewen >; Jian= J Wang >; Qi Zhang <= qi1.zhang@intel.com >; Rahul Kumar > Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Ad= d Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib=20 =20 Thoughts? =20 - Bret=20 =20 From: devel@edk2.groups.io > on behalf of Bret Barkelew via groups.= io > Sent: Wednesday, August 4, 2021 9:32:32 AM To: devel@edk2.groups.io >; bret@corthon.com > Cc: Yao, Jiewen >; Jian= J Wang >; Qi Zhang <= qi1.zhang@intel.com >; Rahul Kumar > Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Ad= d Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib=20 =20 Poking this one. =20 1. It=E2=80=99s a easy review with small, obvious code change. 2. I need some answers on =E2=80=9Cwhen is it okay to violate ECC/PatchChec= k, if the new code matches the style of the existing code. Should I endeavo= r to pass the PatchCheck and ECCCheck with this patch only, and leave it in= conflict with the rest of the file? =20 Thanks! =20 - Bret=20 =20 From: Bret Barkelew via groups.io =20 Sent: Friday, July 30, 2021 11:08 AM To: devel@edk2.groups.io ; bret@corthon.com <= mailto:bret@corthon.com>=20 Cc: Yao, Jiewen ; Jian J Wang ; Qi Zhang ; Rahul Kumar =20 Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Ad= d Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib =20 Note, even though this keeps with the style of the rest of the file, it bre= aks ECC: SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib by co= rthon =C2=B7 Pull Request #1848 =C2=B7 tianocore/edk2 (github.com) =20 =20 PROGRESS - --Running SecurityPkg: EccCheck Test NO-TARGET --=20 ERROR -=20 ERROR -=20 ERROR - EFI coding style error=20 ERROR - *Error code: 8001=20 ERROR - *Only capital letters are allowed to be used for #define declaratio= ns=20 ERROR - *file: //home/vsts/work/1/s/SecurityPkg/Library/Tpm2CommandLib/Tpm2= NVStorage.c=20 ERROR - *Line number: 27=20 ERROR - *The #define name [RC_NV_UndefineSpaceSpecial_nvIndex] does no =20 Thoughts? =20 - Bret=20 =20 From: Bret Barkelew via groups.io =20 Sent: Friday, July 30, 2021 10:55 AM To: devel@edk2.groups.io =20 Cc: Yao, Jiewen ; Jian J Wang ; Qi Zhang ; Rahul Kumar =20 Subject: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tp= m2NvUndefineSpaceSpecial to Tpm2CommandLib =20 Used to provision and maintain certain HW-defined NV spaces. REF: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbu= gzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2994 &data=3D04%7C01%7CBret.Barkelew%40micro= soft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011d= b47%7C1%7C0%7C637632645397602953%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMD= AiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3Ds96M3Rv= xMOY831Vfr1nt%2Fz1h3cyb6jU9eFzvjKO7Dtc%3D&reserved=3D0 Signed-off-by: Bret Barkelew > Cc: Jiewen Yao > Cc: Jian J Wang > Cc: Qi Zhang > Cc: Rahul Kumar > --- SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c | 122 +++++++++++++++++= +++ SecurityPkg/Include/Library/Tpm2CommandLib.h | 22 ++++ 2 files changed, 144 insertions(+) diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c b/SecurityP= kg/Library/Tpm2CommandLib/Tpm2NVStorage.c index 87572de20164..7931fade9190 100644 --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c @@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define RC_NV_UndefineSpace_authHandle (TPM_RC_H + TPM_RC_1) #define RC_NV_UndefineSpace_nvIndex (TPM_RC_H + TPM_RC_2) =20 +#define RC_NV_UndefineSpaceSpecial_nvIndex (TPM_RC_H + TPM_RC_1) + #define RC_NV_Read_authHandle (TPM_RC_H + TPM_RC_1) #define RC_NV_Read_nvIndex (TPM_RC_H + TPM_RC_2) #define RC_NV_Read_size (TPM_RC_P + TPM_RC_1) @@ -74,6 +76,20 @@ typedef struct { TPMS_AUTH_RESPONSE AuthSession; } TPM2_NV_UNDEFINESPACE_RESPONSE; =20 +typedef struct { + TPM2_COMMAND_HEADER Header; + TPMI_RH_NV_INDEX NvIndex; + TPMI_RH_PLATFORM Platform; + UINT32 AuthSessionSize; + TPMS_AUTH_COMMAND AuthSession; +} TPM2_NV_UNDEFINESPACESPECIAL_COMMAND; + +typedef struct { + TPM2_RESPONSE_HEADER Header; + UINT32 AuthSessionSize; + TPMS_AUTH_RESPONSE AuthSession; +} TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE; + typedef struct { TPM2_COMMAND_HEADER Header; TPMI_RH_NV_AUTH AuthHandle; @@ -506,6 +522,112 @@ Done: return Status; } =20 +/** + This command removes an index from the TPM. + + @param[in] NvIndex The NV Index. + @param[in] IndexAuthSession Auth session context for the Index auth/= policy + @param[in] PlatAuthSession Auth session context for the Platform au= th/policy + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_NOT_FOUND The command was returned successfully, b= ut NvIndex is not found. + @retval EFI_UNSUPPORTED Selected NvIndex does not support deleti= on through this call. + @retval EFI_SECURITY_VIOLATION Deletion is not authorized by current po= licy session. + @retval EFI_INVALID_PARAMETER The command was unsuccessful. + @retval EFI_DEVICE_ERROR The command was unsuccessful. +**/ +EFI_STATUS +EFIAPI +Tpm2NvUndefineSpaceSpecial ( + IN TPMI_RH_NV_INDEX NvIndex, + IN TPMS_AUTH_COMMAND *IndexAuthSession OPTIONAL, + IN TPMS_AUTH_COMMAND *PlatAuthSession OPTIONAL + ) +{ + EFI_STATUS Status; + TPM2_NV_UNDEFINESPACESPECIAL_COMMAND SendBuffer; + TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE RecvBuffer; + UINT32 SendBufferSize; + UINT32 RecvBufferSize; + UINT8 *Buffer; + UINT32 IndexAuthSize, PlatAuthSize; + TPM_RC ResponseCode; + + // + // Construct command + // + SendBuffer.Header.tag =3D SwapBytes16(TPM_ST_SESSIONS); + SendBuffer.Header.commandCode =3D SwapBytes32(TPM_CC_NV_UndefineSpaceSpe= cial); + + SendBuffer.NvIndex =3D SwapBytes32 (NvIndex); + SendBuffer.Platform =3D SwapBytes32 (TPM_RH_PLATFORM); + + // + // Marshall the Auth Sessions for the two handles. + Buffer =3D (UINT8 *)&SendBuffer.AuthSession; + // IndexAuthSession + IndexAuthSize =3D CopyAuthSessionCommand (IndexAuthSession, Buffer); + Buffer +=3D IndexAuthSize; + // PlatAuthSession + PlatAuthSize =3D CopyAuthSessionCommand (PlatAuthSession, Buffer); + Buffer +=3D PlatAuthSize; + // AuthSessionSize + SendBuffer.AuthSessionSize =3D SwapBytes32(IndexAuthSize + PlatAuthSize)= ; + + // Update total command size. + SendBufferSize =3D (UINT32)(Buffer - (UINT8 *)&SendBuffer); + SendBuffer.Header.paramSize =3D SwapBytes32 (SendBufferSize); + + // + // send Tpm command + // + RecvBufferSize =3D sizeof (RecvBuffer); + Status =3D Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &Rec= vBufferSize, (UINT8 *)&RecvBuffer); + if (EFI_ERROR (Status)) { + goto Done; + } + + if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { + DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - RecvBufferSize Erro= r - %x\n", RecvBufferSize)); + Status =3D EFI_DEVICE_ERROR; + goto Done; + } + + ResponseCode =3D SwapBytes32(RecvBuffer.Header.responseCode); + if (ResponseCode !=3D TPM_RC_SUCCESS) { + DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - responseCode - %x\n= ", SwapBytes32(RecvBuffer.Header.responseCode))); + } + switch (ResponseCode) { + case TPM_RC_SUCCESS: + // return data + break; + case TPM_RC_ATTRIBUTES: + case TPM_RC_ATTRIBUTES + RC_NV_UndefineSpaceSpecial_nvIndex: + Status =3D EFI_UNSUPPORTED; + break; + case TPM_RC_NV_AUTHORIZATION: + Status =3D EFI_SECURITY_VIOLATION; + break; + case TPM_RC_HANDLE + RC_NV_UndefineSpaceSpecial_nvIndex: // TPM_RC_NV_DE= FINED: + Status =3D EFI_NOT_FOUND; + break; + case TPM_RC_VALUE + RC_NV_UndefineSpace_nvIndex: + Status =3D EFI_INVALID_PARAMETER; + break; + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + // + // Clear AuthSession Content + // + ZeroMem (&SendBuffer, sizeof(SendBuffer)); + ZeroMem (&RecvBuffer, sizeof(RecvBuffer)); + return Status; +} // Tpm2NvUndefineSpaceSpecial() + /** This command reads a value from an area in NV memory previously defined = by TPM2_NV_DefineSpace(). =20 diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Inc= lude/Library/Tpm2CommandLib.h index ee8eb622951c..8d7b4998d98d 100644 --- a/SecurityPkg/Include/Library/Tpm2CommandLib.h +++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h @@ -364,6 +364,28 @@ Tpm2NvUndefineSpace ( IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL ); =20 +/** + This command removes an index from the TPM. + + @param[in] NvIndex The NV Index. + @param[in] IndexAuthSession Auth session context for the Index auth/= policy + @param[in] PlatAuthSession Auth session context for the Platform au= th/policy + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_NOT_FOUND The command was returned successfully, b= ut NvIndex is not found. + @retval EFI_UNSUPPORTED Selected NvIndex does not support deleti= on through this call. + @retval EFI_SECURITY_VIOLATION Deletion is not authorized by current po= licy session. + @retval EFI_INVALID_PARAMETER The command was unsuccessful. + @retval EFI_DEVICE_ERROR The command was unsuccessful. +**/ +EFI_STATUS +EFIAPI +Tpm2NvUndefineSpaceSpecial ( + IN TPMI_RH_NV_INDEX NvIndex, + IN TPMS_AUTH_COMMAND *IndexAuthSession OPTIONAL, + IN TPMS_AUTH_COMMAND *PlatAuthSession OPTIONAL + ); + /** This command reads a value from an area in NV memory previously defined = by TPM2_NV_DefineSpace(). =20 --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#78450): https://nam06.safelinks.protection.outlook.com/= ?url=3Dhttps%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F78450 &data=3D04%7C01%7CBret.Barke= lew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91= ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjo= iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdat= a=3DCWxLwgp73z2XQEa%2FN77gsCwRF73xha0RZCKwcFTlrRE%3D&reserved=3D0 Mute This Topic: https://nam06.safelinks.protection.outlook.com/?url=3Dhttp= s%3A%2F%2Fgroups.io%2Fmt%2F84555713%2F1822150 &data=3D04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c6= 2047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6376= 32645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIi= LCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3DIWQ6E4yP0ECt3oYLYQa%2Bndd= GfcQEDMgfASlcxRuda%2BQ%3D&reserved=3D0 Group Owner: devel+owner@edk2.groups.io = =20 Unsubscribe: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A= %2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub &data=3D04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c= 62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637= 632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzI= iLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3Dqor4Y5FZEH8ch0AEmWDbe97F= IQk4V1qx7IURcTHzjAU%3D&reserved=3D0 [brbarkel@microsoft.com] -=3D-=3D-=3D-=3D-=3D-=3D =20 =20 =20 -=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 (#79244): https://edk2.groups.io/g/devel/message/79244 Mute This Topic: https://groups.io/mt/84857732/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- ------=_NextPart_001_001B_01D7904C.EA3FC140 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Jiewen:

= =C2=A0Yes. If the definition is to align the industry standard definition, = I am OK to add them into ECC exception.

 

Thanks

Liming

=E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io &l= t;devel@edk2.groups.io> =E4=BB=A3=E8=A1=A8 Yao, Jiewen
=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9= =B48=E6=9C=8813=E6=97= =A5 10:30
=E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io; gaolimin= g@byosoft.com.cn; bret.barkelew@microsoft.com; bret@corthon.com; Kinney, Mi= chael D <michael.d.kinney@intel.com>
=E6=8A=84=E9=80=81<= span lang=3DEN-US>:
Wang, Jian J <jian.j.w= ang@intel.com>; Zhang, Qi1 <qi1.zhang@intel.com>; Kumar, Rahul1 &l= t;rahul1.kumar@intel.com>
=E4=B8=BB=E9=A2=98: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1= /1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Hi<= o:p>

I have seen su= ch exception in the industry standard file, such as

<= p class=3DMsoNormal> 

https://github.com/t= ianocore/edk2/blob/master/MdePkg/Include/IndustryStandard/Tpm20.h<= /o:p>

 

#define TPM_CC_NV_Undefine= SpaceSpecial    (TPM_CC)(0x0000011F)

#define TPM_CC_EvictControl &nbs= p;             = (TPM_CC)(0x00000120)

#define TPM_CC_HierarchyControl      = ;     (TPM_CC)(0x00000121)

#define TPM_CC_NV_UndefineSpace  = ;         (TPM_CC)(0x00000122)=

#define TPM_CC_Cha= ngeEPS           &nb= sp;      (TPM_CC)(0x00000124)

#define TPM_CC_ChangePPS &nbs= p;            &= nbsp;   (TPM_CC)(0x00000125)

#define TPM_CC_Clear     =             &nb= sp;    (TPM_CC)(0x00000126)

#define TPM_CC_ClearControl   &= nbsp;           (TPM_CC)(= 0x00000127)

#d= efine TPM_CC_ClockSet         =           (TPM_CC)(0x00000128)=

#define TPM_C= C_HierarchyChangeAuth        (TPM_CC)(0x= 00000129)

#def= ine TPM_CC_NV_DefineSpace        &n= bsp;    (TPM_CC)(0x0000012A)

#define TPM_CC_PCR_Allocate  &nbs= p;            (TPM_C= C)(0x0000012B)

#define TPM_CC_PCR_SetAuthPolicy       =    (TPM_CC)(0x0000012C)

#define TPM_CC_PP_Commands     = ;           (TPM_CC)(0x00= 00012D)

#defin= e TPM_CC_SetPrimaryPolicy        &n= bsp;  (TPM_CC)(0x0000012E)

<= span lang=3DEN-US>#define TPM_CC_FieldUpgradeStart    &= nbsp;     (TPM_CC)(0x0000012F)

#define TPM_CC_ClockRateAdjust &n= bsp;          (TPM_CC)(0x00000= 130)

&nbs= p;

https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Industr= yStandard/Tpm12.h

 

#define TPM_ORD_ActivateIdentity       = ;           ((TPM_COMMAND= _CODE) 0x0000007A)

#define TPM_ORD_AuthorizeMigrationKey     &nb= sp;       ((TPM_COMMAND_CODE) 0x0000002B)

#define TPM_ORD_C= ertifyKey           =              ((= TPM_COMMAND_CODE) 0x00000032)

#define TPM_ORD_CertifyKey2     &n= bsp;            = ;     ((TPM_COMMAND_CODE) 0x00000033)=

#define TPM_ORD_CertifySelfTest=             &nb= sp;      ((TPM_COMMAND_CODE) 0x00000052)

#define TPM_ORD_ChangeA= uth            =             ((TPM_CO= MMAND_CODE) 0x0000000C)

#define TPM_ORD_ChangeAuthAsymFinish     = ;         ((TPM_COMMAND_CODE) 0x000= 0000F)

#define= TPM_ORD_ChangeAuthAsymStart        = ;       ((TPM_COMMAND_CODE) 0x0000000E)<= /o:p>

#define TPM_ORD_Cha= ngeAuthOwner          &nb= sp;        ((TPM_COMMAND_CODE) 0x0000001= 0)

 =

 <= /span>

I agree with Liming that = if this is something completely defined by EDKII, we should align with EDKI= I.

 =

But if this is som= ething copied from other standard, I prefer we keep them as is and add thos= e to exception list.

That makes easy for the domain specific expert to review the code.=

 

Can we submit patch = to add those to ECC exception list?

 

Thank you

Yao Jiewen

 

= From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of gaolimingSent: Friday, August 13, 2021 9:38 AM
To: devel@edk2.groups.io; bret.barkelew@microsoft.com; Yao, Jiewen <jiewen.yao@intel.com>; bret@corthon.com; Kinney, Michael D <michael.d.kinney@intel.com&= gt;
Cc: Wang, Jian J <jian.j.wang@intel.com>; Zhang, Qi1 <qi1.zhang@intel.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
Subject: =
=E5=9B=9E=E5=A4=8D: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg= /Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 <= /span>

Bret:

 I suggest to define new macro that follows EDKII style. This = MACRO is only used in CommandLib. Its impact should be small.

 

Thanks

Liming

=E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io <devel@edk2.groups.io> =E4=BB=A3=E8=A1=A8 <= span lang=3DEN-US style=3D'font-family:=E7=AD=89=E7=BA=BF'>Bret Barkelew vi= a groups.io
=E5= =8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B48=E6=9C=8813=E6=97=A5 8:24
=
=E6=94=B6=E4=BB=B6=E4=BA=BA: Yao, Jiewen <jiewen= .yao@intel.com>; devel@edk2.= groups.io; bret@corthon.com; Ki= nney, Michael D <michael.d= .kinney@intel.com>
=E6=8A=84=E9=80=81: Wang, Jian J <jian.j.wang@intel.com>; Zhang, Qi1 <qi1.zhang@intel.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
<= /span>=E4=B8=BB=E9=A2=98: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2= NvUndefineSpaceSpecial to Tpm2CommandLib

=

 

<= p class=3DMsoNormal>+ @Kinney, Michael D=

&nbs= p;

Mike, any though= ts on when =E2=80=9Csticking with the file convention=E2=80=9D breaks ECC? = Should I just ignore the rest of the file and pass ECC at all costs?

 

- Bret

 

From: Yao, Jiewen
Sent= : Thursday, August 12, 2021 5:06 PM
To: Bret Barkelew; devel@edk2.groups.io; bre= t@corthon.com
Cc: Wa= ng, Jian J; Zhang, Qi1; Kumar, Rahul1
Subject: = RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvU= ndefineSpaceSpecial to Tpm2CommandLib

 

I don=E2=80=99t know the answer about ECC or Patch= Checker.

I &nb= sp;just know we need pass CI to merge the patch.

 

Thank you

Yao Jiewen

 

From: B= ret Barkelew <Bret.Barkel= ew@microsoft.com>
Sent: Friday, August 13, 2021 1:52 AMTo: devel@edk2.groups.io; bret@corthon.com
Cc: = Yao, Jiewen <jiewen.yao@intel.co= m>; Wang, Jian J <jian.j= .wang@intel.com>; Zhang, Qi1 <qi1.zhang@intel.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
Subject: RE: [EX= TERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefine= SpaceSpecial to Tpm2CommandLib

 

Thoughts?

<= span lang=3DEN-US> 

- Bret

 

From: devel@edk2.grou= ps.io <devel@edk2.groups.io<= /a>> on behalf of Bret Barkelew via groups.io <bret.barkelew=3Dmicrosoft.com@groups.i= o>
Sent: Wednesday, August 11, 2021 12:37:52 PM
To:<= /b> devel@edk2.groups.io <devel@edk2.groups.io>; bret@corthon.com <bret@corthon.com>
Cc: Yao, Jiewen <jiewen.yao@intel.com>; Jian J Wan= g <jian.j.wang@intel.com>= ;; Qi Zhang <qi1.zhang@intel.com<= /a>>; Rahul Kumar <rahul1.k= umar@intel.com>
Subject: Re: [EXTERNAL] [edk2-devel] [PATC= H v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2Comman= dLib

 

Thoughts?

 

- Bret

 

=

From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Bret Barkelew via groups.= io <bret.bark= elew=3Dmicrosoft.com@groups.io>
Sent: Wednesday, August 4,= 2021 9:32:32 AM
To: deve= l@edk2.groups.io <devel@edk2= .groups.io>; bret@corthon.com <bret@corthon.com>
Cc= : Yao, Jiewen <jiewen.yao@in= tel.com>; Jian J Wang <j= ian.j.wang@intel.com>; Qi Zhang <qi1.zhang@intel.com>; Rahul Kumar <rahul1.kumar@intel.com>
Subject: Re: [E= XTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefin= eSpaceSpecial to Tpm2CommandLib

 <= /p>

Poking t= his one.

&nb= sp;

    It=E2=80=99s a easy review with small, obvious code = change.
  1. I need some answers = on =E2=80=9Cwhen is it okay to violate ECC/PatchCheck, if the new code matc= hes the style of the existing code. Should I endeavor to pass the PatchChec= k and ECCCheck with this patch only, and leave it in conflict with the rest= of the file?

 

Thanks!

=  

- Bre= t

 

Fr= om: Bret Barkelew via groups.io
Sent: Friday, J= uly 30, 2021 11:08 AM
To: devel@edk2.groups.io; bret@corthon= .com
Cc: Yao, Jiewen<= /a>; Jian J Wang; Qi Zhang; Rahul Kumar
Subject: Re: [EXTERNAL] [edk2-devel] [PAT= CH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2Comma= ndLib

=  

Note,= even though this keeps with the style of the rest of the file, it breaks E= CC:

Secur= ityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib by corthon= =C2=B7 Pull Request #1848 =C2=B7 tianocore/edk2 (github.com)

 

PROGRESS - --Running SecurityPkg: EccCheck Test NO-= TARGET --

ERROR -

ERROR -

ERROR - EFI coding style error

ERROR - *Error code: 8001 =

E= RROR - *Only capital letters are allowed to be used for #define declaration= s

= ERROR - *file: //home/vsts/work/1/s/SecurityPkg/Library/Tpm2CommandLib/Tpm2= NVStorage.c

ERROR - *Line number: 27

ERROR - *The #define name [RC_NV_UndefineS= paceSpecial_nvIndex] does no

 

Thoughts?

 

- Bret =

 

<= div style=3D'border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0= cm 0cm'>

From: Bret Barkelew= via groups.io
Sent: Friday, July 30, 2021 10:55 AM
To:= devel@edk2.groups.io
Cc:
Yao, Jiewen; Jian J Wang; Qi Zhang; Rahu= l Kumar
Subject: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] Secur= ityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib=

 

Used to provision and maintain certain HW-defined NV spaces.
<= br>REF: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3= A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2994&amp;data=3D04%= 7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C7= 2f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397602953%7CUnknown%7CTW= FpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3= D%7C1000&amp;sdata=3Ds96M3RvxMOY831Vfr1nt%2Fz1h3cyb6jU9eFzvjKO7Dtc%3D&a= mp;amp;reserved=3D0

Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
= Cc: Jiewen Yao <jiewen.yao@intel= .com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Qi Zhang <qi1.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
--- SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c | 122 +++++++++++= +++++++++
 SecurityPkg/Include/Library/Tpm2CommandLib.h  =      |  22 ++++
 2 files changed, 144 inse= rtions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStor= age.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
index 87572de= 20164..7931fade9190 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2= NVStorage.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
= @@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #de= fine RC_NV_UndefineSpace_authHandle      (TPM_RC_H= + TPM_RC_1)

 #define RC_NV_UndefineSpace_nvIndex  &n= bsp;      (TPM_RC_H + TPM_RC_2)

 
<= br>+#define RC_NV_UndefineSpaceSpecial_nvIndex  (TPM_RC_H + TPM_RC_1)<= br>
+

 #define RC_NV_Read_authHandle    =            (TPM_RC_H + TP= M_RC_1)

 #define RC_NV_Read_nvIndex    &nbs= p;             = (TPM_RC_H + TPM_RC_2)

 #define RC_NV_Read_size   = ;            &n= bsp;     (TPM_RC_P + TPM_RC_1)

@@ -74,6 +76,20 @= @ typedef struct {
   TPMS_AUTH_RESPONSE   &nbs= p;     AuthSession;

 } TPM2_NV_UNDEFINESPAC= E_RESPONSE;

 

+typedef struct {

+  TPM2_COMM= AND_HEADER       Header;

+  TPMI_= RH_NV_INDEX          NvIndex;<= br>
+  TPMI_RH_PLATFORM       &n= bsp;  Platform;

+  UINT32     &nb= sp;            =   AuthSessionSize;

+  TPMS_AUTH_COMMAND   &= nbsp;     AuthSession;

+} TPM2_NV_UNDEFINESPACES= PECIAL_COMMAND;

+

+typedef struct {

+  TPM2_RESPO= NSE_HEADER       Header;

+  UINT3= 2            &n= bsp;        AuthSessionSize;

+&nb= sp; TPMS_AUTH_RESPONSE         Auth= Session;

+} TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE;

+

&= nbsp;typedef struct {

   TPM2_COMMAND_HEADER  &n= bsp;    Header;

   TPMI_RH_NV_AUTH &nb= sp;         AuthHandle;

@@ -= 506,6 +522,112 @@ Done:
   return Status;

 }
 

+/**

+  This command removes an index from the = TPM.

+

+  @param[in]  NvIndex   &nbs= p;         The NV Index.

+&n= bsp; @param[in]  IndexAuthSession    Auth session conte= xt for the Index auth/policy

+  @param[in]  PlatAuthSessio= n     Auth session context for the Platform auth/policy=

+

+  @retval EFI_SUCCESS     &= nbsp;       Operation completed successfully.=

+  @retval EFI_NOT_FOUND      &n= bsp;    The command was returned successfully, but NvIndex i= s not found.

+  @retval EFI_UNSUPPORTED    =      Selected NvIndex does not support deletion through= this call.

+  @retval EFI_SECURITY_VIOLATION  Deletion is= not authorized by current policy session.

+  @retval EFI_INVAL= ID_PARAMETER   The command was unsuccessful.

+  @retv= al EFI_DEVICE_ERROR        The command w= as unsuccessful.

+**/

+EFI_STATUS

+EFIAPI

+Tpm2= NvUndefineSpaceSpecial (

+  IN      TP= MI_RH_NV_INDEX          NvInde= x,

+  IN      TPMS_AUTH_COMMAND &= nbsp;       *IndexAuthSession OPTIONAL,
+  IN      TPMS_AUTH_COMMAND  &nb= sp;      *PlatAuthSession OPTIONAL

+  = )

+{

+  EFI_STATUS      &n= bsp;            = ;           Status;
+  TPM2_NV_UNDEFINESPACESPECIAL_COMMAND    SendBuffer= ;

+  TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE   RecvBuff= er;

+  UINT32        &n= bsp;            = ;             S= endBufferSize;

+  UINT32      &nb= sp;            =             &nb= sp;  RecvBufferSize;

+  UINT8     = ;            &n= bsp;            = ;     *Buffer;

+  UINT32   &= nbsp;           &nbs= p;            &= nbsp;     IndexAuthSize, PlatAuthSize;

+  T= PM_RC           &nbs= p;            &= nbsp;         ResponseCode;

= +

+  //

+  // Construct command

+  //
+  SendBuffer.Header.tag =3D SwapBytes16(TPM_ST_SESSIONS);
+  SendBuffer.Header.commandCode =3D SwapBytes32(TPM_CC_NV_UndefineS= paceSpecial);

+

+  SendBuffer.NvIndex =3D SwapBytes32 (N= vIndex);

+  SendBuffer.Platform =3D SwapBytes32 (TPM_RH_PLATFOR= M);

+

+  //

+  // Marshall the Auth Sessions= for the two handles.

+  Buffer =3D (UINT8 *)&SendBuffer.Au= thSession;

+  // IndexAuthSession

+  IndexAuthSize = =3D CopyAuthSessionCommand (IndexAuthSession, Buffer);

+  Buffe= r +=3D IndexAuthSize;

+  // PlatAuthSession

+  Plat= AuthSize =3D CopyAuthSessionCommand (PlatAuthSession, Buffer);

+&nbs= p; Buffer +=3D PlatAuthSize;

+  // AuthSessionSize

+&nbs= p; SendBuffer.AuthSessionSize =3D SwapBytes32(IndexAuthSize + PlatAuthSize)= ;

+

+  // Update total command size.

+  Send= BufferSize =3D (UINT32)(Buffer - (UINT8 *)&SendBuffer);

+  = SendBuffer.Header.paramSize =3D SwapBytes32 (SendBufferSize);

+
<= br>+  //

+  // send Tpm command

+  //

+=   RecvBufferSize =3D sizeof (RecvBuffer);

+  Status =3D Tp= m2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferS= ize, (UINT8 *)&RecvBuffer);

+  if (EFI_ERROR (Status)) {
+    goto Done;

+  }

+

+ = ; if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {

+ &n= bsp;  DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - RecvBuff= erSize Error - %x\n", RecvBufferSize));

+    Sta= tus =3D EFI_DEVICE_ERROR;

+    goto Done;

+&nb= sp; }

+

+  ResponseCode =3D SwapBytes32(RecvBuffer.Heade= r.responseCode);

+  if (ResponseCode !=3D TPM_RC_SUCCESS) {
=
+    DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpeci= al - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)= ));

+  }

+  switch (ResponseCode) {

+  = case TPM_RC_SUCCESS:

+    // return data

+&nbs= p;   break;

+  case TPM_RC_ATTRIBUTES:

+ = case TPM_RC_ATTRIBUTES + RC_NV_UndefineSpaceSpecial_nvIndex:

+ = ;   Status =3D EFI_UNSUPPORTED;

+    break;=

+  case TPM_RC_NV_AUTHORIZATION:

+    St= atus =3D EFI_SECURITY_VIOLATION;

+    break;

+=   case TPM_RC_HANDLE + RC_NV_UndefineSpaceSpecial_nvIndex: // TPM_RC_N= V_DEFINED:

+    Status =3D EFI_NOT_FOUND;

+&nb= sp;   break;

+  case TPM_RC_VALUE + RC_NV_UndefineSpa= ce_nvIndex:

+    Status =3D EFI_INVALID_PARAMETER;
+    break;

+  default:

+  = ;  Status =3D EFI_DEVICE_ERROR;

+    break;
<= br>+  }

+

+Done:

+  //

+  // Cle= ar AuthSession Content

+  //

+  ZeroMem (&SendB= uffer, sizeof(SendBuffer));

+  ZeroMem (&RecvBuffer, sizeof= (RecvBuffer));

+  return Status;

+} // Tpm2NvUndefineSpa= ceSpecial()

+

 /**

   This command read= s a value from an area in NV memory previously defined by TPM2_NV_DefineSpa= ce().

 

diff --git a/SecurityPkg/Include/Library/Tpm2Com= mandLib.h b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index ee8eb6229= 51c..8d7b4998d98d 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLi= b.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -364,6 +364= ,28 @@ Tpm2NvUndefineSpace (
   IN    &nbs= p; TPMS_AUTH_COMMAND         *AuthS= ession OPTIONAL

   );

 

+/**

+&n= bsp; This command removes an index from the TPM.

+

+  @p= aram[in]  NvIndex         = ;    The NV Index.

+  @param[in]  IndexAuth= Session    Auth session context for the Index auth/policy
+  @param[in]  PlatAuthSession     Auth = session context for the Platform auth/policy

+

+  @retva= l EFI_SUCCESS          &n= bsp;  Operation completed successfully.

+  @retval EFI_NOT= _FOUND           The comm= and was returned successfully, but NvIndex is not found.

+  @re= tval EFI_UNSUPPORTED         Select= ed NvIndex does not support deletion through this call.

+  @ret= val EFI_SECURITY_VIOLATION  Deletion is not authorized by current poli= cy session.

+  @retval EFI_INVALID_PARAMETER   The co= mmand was unsuccessful.

+  @retval EFI_DEVICE_ERROR  =       The command was unsuccessful.

+**/
+EFI_STATUS

+EFIAPI

+Tpm2NvUndefineSpaceSpecial (
+  IN      TPMI_RH_NV_INDEX   = ;       NvIndex,

+  IN  = ;    TPMS_AUTH_COMMAND      &n= bsp;  *IndexAuthSession OPTIONAL,

+  IN   &= nbsp;  TPMS_AUTH_COMMAND       &nbs= p; *PlatAuthSession OPTIONAL

+  );

+

 /**
   This command reads a value from an area in NV memory prev= iously defined by TPM2_NV_DefineSpace().

 

--
2.31.1= .windows.1



-=3D-=3D-=3D-=3D-=3D-=3D
Groups.io Links: You = receive all messages sent to this group.
View/Reply Online (#78450): http= s://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fedk2.groups= .io%2Fg%2Fdevel%2Fmessage%2F78450&amp;data=3D04%7C01%7CBret.Barkelew%40= microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7c= d011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL= jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata= =3DCWxLwgp73z2XQEa%2FN77gsCwRF73xha0RZCKwcFTlrRE%3D&amp;reserved=3D0
Mute This Topic:
https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%= 2F%2Fgroups.io%2Fmt%2F84555713%2F1822150&amp;data=3D04%7C01%7CBret.Bark= elew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af9= 1ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIj= oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp= ;sdata=3DIWQ6E4yP0ECt3oYLYQa%2BnddGfcQEDMgfASlcxRuda%2BQ%3D&amp;reserve= d=3D0
Group Owner: dev= el+owner@edk2.groups.io
Unsubscribe: https://nam06.safelinks.protection.o= utlook.com/?url=3Dhttps%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&amp;= data=3D04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953= 833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUn= known%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ= XVCI6Mn0%3D%7C1000&amp;sdata=3Dqor4Y5FZEH8ch0AEmWDbe97FIQk4V1qx7IURcTHz= jAU%3D&amp;reserved=3D0 [brbarkel@microsoft.com]
-=3D-=3D-=3D-= =3D-=3D-=3D

=  

=  

 

_._,_._,_

G= roups.io Links:

You receive all messages sent to this group.

Vi= ew/Reply Online (#79244) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [importer@patchew.org]
_._,_._,_=20 ------=_NextPart_001_001B_01D7904C.EA3FC140-- ------=_NextPart_000_001A_01D7904C.EA3FC140 Content-Type: image/png; name="image002.png" Content-Transfer-Encoding: base64 Content-ID: iVBORw0KGgoAAAANSUhEUgAAArYAAAADCAYAAABmm0wDAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAS dAAAEnQB3mYfeAAAABl0RVh0U29mdHdhcmUATWljcm9zb2Z0IE9mZmljZX/tNXEAAABrSURBVGhD 7dCxEUAwAIXhhJQsbAgr2cDp0jgbKCgU3Alr5O57E/zvS9O8lq7rQ4wxGAECBAgQIECAAIFaBVIo 5TnPY2yb9qr1hG4CBAgQIECAAAEC6Se4920Zcs4vDgIECBAgQIAAAQK1CnxV+BKJo+GYJAAAAABJ RU5ErkJggg== ------=_NextPart_000_001A_01D7904C.EA3FC140--