Changeset 108794 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Sec/SecMain.c
- Timestamp:
- Mar 31, 2025 11:31:09 AM (2 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168237
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-164365 /vendor/edk2/current 103735-103757,103769-103776,129194-168232
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Sec/SecMain.c
r105670 r108794 30 30 #include <Library/TdxHelperLib.h> 31 31 #include <Library/CcProbeLib.h> 32 #include <Register/Intel/ArchitecturalMsr.h> 33 #include <Register/Intel/Cpuid.h> 32 34 #include "AmdSev.h" 33 35 … … 744 746 } 745 747 748 // 749 // Enable MTRR early, set default type to write back. 750 // Needed to make sure caching is enabled, 751 // without this lzma decompress can be very slow. 752 // 753 STATIC 754 VOID 755 SecMtrrSetup ( 756 VOID 757 ) 758 { 759 CPUID_VERSION_INFO_EDX Edx; 760 MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; 761 762 AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32); 763 if (!Edx.Bits.MTRR) { 764 return; 765 } 766 767 #if defined (TDX_GUEST_SUPPORTED) 768 if (CcProbe () == CcGuestTypeIntelTdx) { 769 // 770 // According to TDX Spec, the default MTRR type is enforced to WB 771 // and CR0.CD is enforced to 0. 772 // The TD guest has to disable MTRR otherwise it tries to 773 // program MTRRs to disable caching. CR0.CD=1 results in the 774 // unexpected #VE. 775 // 776 DEBUG ((DEBUG_INFO, "%a: Skip TD-Guest\n", __func__)); 777 return; 778 } 779 780 #endif 781 782 DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); 783 DefType.Bits.Type = MSR_IA32_MTRR_CACHE_WRITE_BACK; 784 DefType.Bits.E = 1; /* enable */ 785 AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); 786 } 787 746 788 VOID 747 789 EFIAPI … … 942 984 InitializeApicTimer (0, MAX_UINT32, TRUE, 5); 943 985 DisableApicTimerInterrupt (); 986 987 // 988 // Initialize MTRR 989 // 990 SecMtrrSetup (); 944 991 945 992 //
Note:
See TracChangeset
for help on using the changeset viewer.