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