Re: [edk2] [Patch 2/2] SecurityPkg: Tpm2DeviceLib: Enable CapCRBIdleBypass support
Hi Gary: It is caused by code merge. Tks for notification. We have fixed it. From: Gary Lin [mailto:g...@suse.com] Sent: Wednesday, June 27, 2018 4:19 PM To: Zhang, Chao B Cc: edk2-devel@lists.01.org; Yao, Jiewen ; Long, Qin Subject: Re: [edk2] [Patch 2/2] SecurityPkg: Tpm2DeviceLib: Enable CapCRBIdleBypass support On Mon, Jun 25, 2018 at 12:44:21PM +0800, Zhang, Chao B wrote: > Directly transition from CMD completion to CMD Ready state if device > supports IdleByPass > > Cc: Long Qin mailto:qin.l...@intel.com>> > Cc: Yao Jiewen mailto:jiewen@intel.com>> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Chao Zhang > mailto:chao.b.zh...@intel.com>> > Signed-off-by: Zhang, Chao B > mailto:chao.b.zh...@intel.com>> > --- > .../Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c | 19 + > .../Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf| 1 + > .../Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c| 19 + > .../Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf | 3 +- > SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c| 98 > +++--- > SecurityPkg/SecurityPkg.dec| 10 +++ > SecurityPkg/SecurityPkg.uni| 10 ++- > 7 files changed, 146 insertions(+), 14 deletions(-) > > diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > index 3feb64df7e..e6fe563b40 100644 > --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > @@ -29,10 +29,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > TPM2_PTP_INTERFACE_TYPE > Tpm2GetPtpInterface ( >IN VOID *Register >); > > +/** > + Return PTP CRB interface IdleByPass state. > + > + @param[in] RegisterPointer to PTP register. > + > + @return PTP CRB interface IdleByPass state. > +**/ > +UINT8 > +Tpm2GetIdleByPass ( > + IN VOID *Register > + ); > + > /** >This service enables the sending of commands to the TPM2. > >@param[in] InputParameterBlockSize Size of the TPM2 input parameter > block. >@param[in] InputParameterBlock Pointer to the TPM2 input > parameter block. > @@ -138,15 +150,22 @@ EFIAPI > Tpm2DeviceLibConstructor ( >VOID >) > { >TPM2_PTP_INTERFACE_TYPE PtpInterface; > + UINT8IdleByPass; > >// >// Cache current active TpmInterfaceType only when needed >// >if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) { > PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 > (PcdTpmBaseAddress)); > PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface); >} > + > + if (PcdGet8(PcdActiveTpmInterfaceType) == PtpInterfaceCrb && > PcdGet8(PcdCRBIdleByPass) == 0xFF) { I got a build error with PtpInterfaceCrb: SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c: In function ‘Tpm2DeviceLibConstructor’: SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c:165:45: error: ‘PtpInterfaceCrb’ undeclared (first use in this function); did you mean ‘PtpInterface’? if (PcdGet8(PcdActiveTpmInterfaceType) == PtpInterfaceCrb && PcdGet8(PcdCRBIdleByPass) == 0xFF) { ^~~ PtpInterface I assume you mean Tpm2PtpInterfaceCrb? Cheers, Gary Lin > +IdleByPass = Tpm2GetIdleByPass((VOID *) (UINTN) PcdGet64 > (PcdTpmBaseAddress)); > +PcdSet8S(PcdCRBIdleByPass, IdleByPass); > + } > + >return EFI_SUCCESS; > } > diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > index 634bbae847..2e54a78cc0 100644 > --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > @@ -53,5 +53,6 @@ >PcdLib > > [Pcd] >gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress## CONSUMES >gEfiSecurityPkgTokenSpaceGuid.PcdActiveTpmInterfaceType## PRODUCES > + gEfiSecurityPkgTokenSpaceGuid.PcdCRBIdleByPass ## PRODUCES > \ No newline at end of file > diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > index 01f78bf0be..edcdb72a79 100644 > --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > @@ -32,10 +32,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS O
Re: [edk2] [Patch 2/2] SecurityPkg: Tpm2DeviceLib: Enable CapCRBIdleBypass support
On Mon, Jun 25, 2018 at 12:44:21PM +0800, Zhang, Chao B wrote: > Directly transition from CMD completion to CMD Ready state if device > supports IdleByPass > > Cc: Long Qin > Cc: Yao Jiewen > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Chao Zhang > Signed-off-by: Zhang, Chao B > --- > .../Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c | 19 + > .../Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf| 1 + > .../Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c| 19 + > .../Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf | 3 +- > SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c| 98 > +++--- > SecurityPkg/SecurityPkg.dec| 10 +++ > SecurityPkg/SecurityPkg.uni| 10 ++- > 7 files changed, 146 insertions(+), 14 deletions(-) > > diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > index 3feb64df7e..e6fe563b40 100644 > --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c > @@ -29,10 +29,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > TPM2_PTP_INTERFACE_TYPE > Tpm2GetPtpInterface ( >IN VOID *Register >); > > +/** > + Return PTP CRB interface IdleByPass state. > + > + @param[in] RegisterPointer to PTP register. > + > + @return PTP CRB interface IdleByPass state. > +**/ > +UINT8 > +Tpm2GetIdleByPass ( > + IN VOID *Register > + ); > + > /** >This service enables the sending of commands to the TPM2. > >@param[in] InputParameterBlockSize Size of the TPM2 input parameter > block. >@param[in] InputParameterBlock Pointer to the TPM2 input > parameter block. > @@ -138,15 +150,22 @@ EFIAPI > Tpm2DeviceLibConstructor ( >VOID >) > { >TPM2_PTP_INTERFACE_TYPE PtpInterface; > + UINT8IdleByPass; > >// >// Cache current active TpmInterfaceType only when needed >// >if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) { > PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 > (PcdTpmBaseAddress)); > PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface); >} > + > + if (PcdGet8(PcdActiveTpmInterfaceType) == PtpInterfaceCrb && > PcdGet8(PcdCRBIdleByPass) == 0xFF) { I got a build error with PtpInterfaceCrb: SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c: In function ‘Tpm2DeviceLibConstructor’: SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c:165:45: error: ‘PtpInterfaceCrb’ undeclared (first use in this function); did you mean ‘PtpInterface’? if (PcdGet8(PcdActiveTpmInterfaceType) == PtpInterfaceCrb && PcdGet8(PcdCRBIdleByPass) == 0xFF) { ^~~ PtpInterface I assume you mean Tpm2PtpInterfaceCrb? Cheers, Gary Lin > +IdleByPass = Tpm2GetIdleByPass((VOID *) (UINTN) PcdGet64 > (PcdTpmBaseAddress)); > +PcdSet8S(PcdCRBIdleByPass, IdleByPass); > + } > + >return EFI_SUCCESS; > } > diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > index 634bbae847..2e54a78cc0 100644 > --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf > @@ -53,5 +53,6 @@ >PcdLib > > [Pcd] >gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress## CONSUMES >gEfiSecurityPkgTokenSpaceGuid.PcdActiveTpmInterfaceType## PRODUCES > + gEfiSecurityPkgTokenSpaceGuid.PcdCRBIdleByPass ## PRODUCES > \ No newline at end of file > diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > index 01f78bf0be..edcdb72a79 100644 > --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c > @@ -32,10 +32,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > TPM2_PTP_INTERFACE_TYPE > Tpm2GetPtpInterface ( >IN VOID *Register >); > > +/** > + Return PTP CRB interface IdleByPass state. > + > + @param[in] RegisterPointer to PTP register. > + > + @return PTP CRB interface IdleByPass state. > +**/ > +UINT8 > +Tpm2GetIdleByPass ( > + IN VOID *Register > + ); > + > /** >Dump PTP register information. > >@param[in] RegisterPointer to PTP register. > **/ > @@ -95,10 +107,11 @@ Tpm2InstanceLibDTpmConstructor ( >VOID >) > { >EFI_STATUS Status; >TPM2_PTP_INTERFACE_TYPE PtpInterface; > + UINT8IdleByPass; > >Status = Tpm2RegisterTpm2DeviceLib (); >if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) { >
[edk2] [Patch 2/2] SecurityPkg: Tpm2DeviceLib: Enable CapCRBIdleBypass support
Directly transition from CMD completion to CMD Ready state if device supports IdleByPass Cc: Long Qin Cc: Yao Jiewen Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chao Zhang Signed-off-by: Zhang, Chao B --- .../Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c | 19 + .../Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf| 1 + .../Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c| 19 + .../Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf | 3 +- SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c| 98 +++--- SecurityPkg/SecurityPkg.dec| 10 +++ SecurityPkg/SecurityPkg.uni| 10 ++- 7 files changed, 146 insertions(+), 14 deletions(-) diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c index 3feb64df7e..e6fe563b40 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c @@ -29,10 +29,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. TPM2_PTP_INTERFACE_TYPE Tpm2GetPtpInterface ( IN VOID *Register ); +/** + Return PTP CRB interface IdleByPass state. + + @param[in] RegisterPointer to PTP register. + + @return PTP CRB interface IdleByPass state. +**/ +UINT8 +Tpm2GetIdleByPass ( + IN VOID *Register + ); + /** This service enables the sending of commands to the TPM2. @param[in] InputParameterBlockSize Size of the TPM2 input parameter block. @param[in] InputParameterBlock Pointer to the TPM2 input parameter block. @@ -138,15 +150,22 @@ EFIAPI Tpm2DeviceLibConstructor ( VOID ) { TPM2_PTP_INTERFACE_TYPE PtpInterface; + UINT8IdleByPass; // // Cache current active TpmInterfaceType only when needed // if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) { PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface); } + + if (PcdGet8(PcdActiveTpmInterfaceType) == PtpInterfaceCrb && PcdGet8(PcdCRBIdleByPass) == 0xFF) { +IdleByPass = Tpm2GetIdleByPass((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); +PcdSet8S(PcdCRBIdleByPass, IdleByPass); + } + return EFI_SUCCESS; } diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf index 634bbae847..2e54a78cc0 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf @@ -53,5 +53,6 @@ PcdLib [Pcd] gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdActiveTpmInterfaceType## PRODUCES + gEfiSecurityPkgTokenSpaceGuid.PcdCRBIdleByPass ## PRODUCES \ No newline at end of file diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c index 01f78bf0be..edcdb72a79 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c @@ -32,10 +32,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. TPM2_PTP_INTERFACE_TYPE Tpm2GetPtpInterface ( IN VOID *Register ); +/** + Return PTP CRB interface IdleByPass state. + + @param[in] RegisterPointer to PTP register. + + @return PTP CRB interface IdleByPass state. +**/ +UINT8 +Tpm2GetIdleByPass ( + IN VOID *Register + ); + /** Dump PTP register information. @param[in] RegisterPointer to PTP register. **/ @@ -95,10 +107,11 @@ Tpm2InstanceLibDTpmConstructor ( VOID ) { EFI_STATUS Status; TPM2_PTP_INTERFACE_TYPE PtpInterface; + UINT8IdleByPass; Status = Tpm2RegisterTpm2DeviceLib (); if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) { // // Unsupported means platform policy does not need this instance enabled. @@ -109,10 +122,16 @@ Tpm2InstanceLibDTpmConstructor ( // if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) { PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface); } + + if (PcdGet8(PcdActiveTpmInterfaceType) == PtpInterfaceCrb && PcdGet8(PcdCRBIdleByPass) == 0xFF) { +IdleByPass = Tpm2GetIdleByPass((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); +PcdSet8S(PcdCRBIdleByPass, IdleByPass); + } + DumpPtpInfo ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); } return EFI_SUCCESS; } return Status; diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf index