IntelTdx.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /** @file
  2. Initialize Intel TDX support.
  3. Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiPei.h>
  7. #include <Library/BaseLib.h>
  8. #include <Library/DebugLib.h>
  9. #include <Library/HobLib.h>
  10. #include <Library/BaseMemoryLib.h>
  11. #include <Library/MemoryAllocationLib.h>
  12. #include <IndustryStandard/Tdx.h>
  13. #include <IndustryStandard/QemuFwCfg.h>
  14. #include <Library/QemuFwCfgLib.h>
  15. #include <Library/PeiServicesLib.h>
  16. #include <Library/TdxLib.h>
  17. #include <Library/TdxHelperLib.h>
  18. #include <Library/PlatformInitLib.h>
  19. #include <WorkArea.h>
  20. #include <ConfidentialComputingGuestAttr.h>
  21. #include "Platform.h"
  22. /**
  23. This Function checks if TDX is available, if present then it sets
  24. the dynamic PCDs for Tdx guest.
  25. **/
  26. VOID
  27. IntelTdxInitialize (
  28. VOID
  29. )
  30. {
  31. #ifdef MDE_CPU_X64
  32. RETURN_STATUS PcdStatus;
  33. if (!TdIsEnabled ()) {
  34. return;
  35. }
  36. TdxHelperBuildGuidHobForTdxMeasurement ();
  37. PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrIntelTdx);
  38. ASSERT_RETURN_ERROR (PcdStatus);
  39. PcdStatus = PcdSet64S (PcdTdxSharedBitMask, TdSharedPageMask ());
  40. ASSERT_RETURN_ERROR (PcdStatus);
  41. PcdStatus = PcdSetBoolS (PcdSetNxForStack, TRUE);
  42. ASSERT_RETURN_ERROR (PcdStatus);
  43. #endif
  44. }