From 0e8927d5eb6fe3a5048da751f4460b6de3ef852c Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Fri, 1 Nov 2024 13:10:07 +0300 Subject: [PATCH] SecurityPkg: Added SecurityPkg to CI. --- .github/workflows/build_common.yml | 54 +++++++++++++++++++ STATUS.md | 2 +- SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c | 37 ++++++------- 3 files changed, 74 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build_common.yml b/.github/workflows/build_common.yml index 99b827b300..23b1cc29f3 100644 --- a/.github/workflows/build_common.yml +++ b/.github/workflows/build_common.yml @@ -135,6 +135,15 @@ jobs: SKIP_TESTS: 1 SKIP_PACKAGE: 1 + - name: Build SecurityPkg + if: always() + run: ./efibuild.sh + env: + SELFPKG: SecurityPkg + ARCHS: IA32,X64 + SKIP_TESTS: 1 + SKIP_PACKAGE: 1 + build-windows: name: Windows VS2019 runs-on: windows-latest @@ -249,6 +258,15 @@ jobs: SKIP_TESTS: 1 SKIP_PACKAGE: 1 + - name: Build SecurityPkg + if: always() + run: ./efibuild.sh + env: + SELFPKG: SecurityPkg + ARCHS: IA32,X64 + SKIP_TESTS: 1 + SKIP_PACKAGE: 1 + build-linux-clangpdb: name: Linux CLANGPDB runs-on: ubuntu-22.04 @@ -373,6 +391,18 @@ jobs: SKIP_TESTS: 1 SKIP_PACKAGE: 1 + - name: Build SecurityPkg + if: always() + run: docker compose run build-package + env: + SELFPKG: SecurityPkg + SELFPKG_DIR: SecurityPkg + TOOLCHAINS: CLANGPDB + ARCHS: IA32,X64 + TARGETS: RELEASE,DEBUG,NOOPT + SKIP_TESTS: 1 + SKIP_PACKAGE: 1 + build-linux-clangdwarf: name: Linux CLANGDWARF runs-on: ubuntu-22.04 @@ -497,6 +527,18 @@ jobs: SKIP_TESTS: 1 SKIP_PACKAGE: 1 + - name: Build SecurityPkg + if: always() + run: docker compose run build-package + env: + SELFPKG: SecurityPkg + SELFPKG_DIR: SecurityPkg + TOOLCHAINS: CLANGDWARF + ARCHS: IA32,X64 + TARGETS: RELEASE,DEBUG,NOOPT + SKIP_TESTS: 1 + SKIP_PACKAGE: 1 + build-linux-gcc5: name: Linux GCC runs-on: ubuntu-22.04 @@ -620,3 +662,15 @@ jobs: TARGETS: RELEASE,DEBUG,NOOPT SKIP_TESTS: 1 SKIP_PACKAGE: 1 + + - name: Build SecurityPkg + if: always() + run: docker compose run build-package + env: + SELFPKG: SecurityPkg + SELFPKG_DIR: SecurityPkg + TOOLCHAINS: GCC + ARCHS: IA32,X64 + TARGETS: RELEASE,DEBUG,NOOPT + SKIP_TESTS: 1 + SKIP_PACKAGE: 1 diff --git a/STATUS.md b/STATUS.md index 77589f54ca..c55c07dd37 100644 --- a/STATUS.md +++ b/STATUS.md @@ -61,7 +61,7 @@ | $${\color{lightblue}RedfishPkg/}$$ | | RedfishPkg.dsc | IA32 X64 ARM AARCH64 RISCV64 | DEBUG RELEASE NOOPT | ❓ | ❌ | | $${\color{lightblue}SecurityPkg/}$$ | -| SecurityPkg.dsc | IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64 | DEBUG RELEASE NOOPT | ❓ | ❌ | +| SecurityPkg.dsc | IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64 | DEBUG RELEASE NOOPT | GCC CLANGDWARF CLANGPDB VS2019 XCODE5 | ❌ | | Test/SecurityPkgHostTest.dsc | IA32 X64 | NOOPT | ❓ | ❌ | | $${\color{lightblue}ShellPkg/}$$ | | ShellPkg.dsc | IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64 | DEBUG RELEASE NOOPT | ❓ | ❌ | diff --git a/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c index 91101ccd1f..6c82dac66b 100644 --- a/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c +++ b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c @@ -59,10 +59,10 @@ Tpm2GetAlgoFromHashMask ( @retval EFI_SUCCESS Hash sequence start and HandleHandle returned. @retval EFI_OUT_OF_RESOURCES No enough resource to start hash. **/ -BOOLEAN +EFI_STATUS EFIAPI HashStart ( - OUT VOID **HashHandle + OUT HASH_HANDLE *HashHandle ) { TPMI_DH_OBJECT SequenceHandle; @@ -72,12 +72,13 @@ HashStart ( AlgoId = Tpm2GetAlgoFromHashMask (); Status = Tpm2HashSequenceStart (AlgoId, &SequenceHandle); - if (!EFI_ERROR (Status)) { - *HashHandle = (VOID *)(UINTN)SequenceHandle; - return TRUE; + if (EFI_ERROR (Status)) { + return Status; } - return FALSE; + *HashHandle = (HASH_HANDLE)SequenceHandle; + + return EFI_SUCCESS; } /** @@ -89,11 +90,11 @@ HashStart ( @retval EFI_SUCCESS Hash sequence updated. **/ -BOOLEAN +EFI_STATUS EFIAPI HashUpdate ( - IN VOID *HashHandle, - IN CONST VOID *DataToHash, + IN HASH_HANDLE HashHandle, + IN VOID *DataToHash, IN UINTN DataToHashLen ) { @@ -108,9 +109,9 @@ HashUpdate ( CopyMem (HashBuffer.buffer, Buffer, sizeof (HashBuffer.buffer)); Buffer += sizeof (HashBuffer.buffer); - Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)(UINTN)HashHandle, &HashBuffer); + Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)HashHandle, &HashBuffer); if (EFI_ERROR (Status)) { - return FALSE; + return Status; } } @@ -119,12 +120,12 @@ HashUpdate ( // HashBuffer.size = (UINT16)HashLen; CopyMem (HashBuffer.buffer, Buffer, (UINTN)HashLen); - Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)(UINTN)HashHandle, &HashBuffer); + Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)HashHandle, &HashBuffer); if (EFI_ERROR (Status)) { - return FALSE; + return Status; } - return TRUE; + return EFI_SUCCESS; } /** @@ -141,7 +142,7 @@ HashUpdate ( EFI_STATUS EFIAPI HashCompleteAndExtend ( - IN VOID *HashHandle, + IN HASH_HANDLE HashHandle, IN TPMI_DH_PCR PcrIndex, IN VOID *DataToHash, IN UINTN DataToHashLen, @@ -163,7 +164,7 @@ HashCompleteAndExtend ( CopyMem (HashBuffer.buffer, Buffer, sizeof (HashBuffer.buffer)); Buffer += sizeof (HashBuffer.buffer); - Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)(UINTN)HashHandle, &HashBuffer); + Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)HashHandle, &HashBuffer); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } @@ -181,13 +182,13 @@ HashCompleteAndExtend ( if (AlgoId == TPM_ALG_NULL) { Status = Tpm2EventSequenceComplete ( PcrIndex, - (TPMI_DH_OBJECT)(UINTN)HashHandle, + (TPMI_DH_OBJECT)HashHandle, &HashBuffer, DigestList ); } else { Status = Tpm2SequenceComplete ( - (TPMI_DH_OBJECT)(UINTN)HashHandle, + (TPMI_DH_OBJECT)HashHandle, &HashBuffer, &Result );