VirtualBox

Ignore:
Timestamp:
Mar 31, 2025 11:31:09 AM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168237
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Sec/SecMain.c

    r105670 r108794  
    3030#include <Library/TdxHelperLib.h>
    3131#include <Library/CcProbeLib.h>
     32#include <Register/Intel/ArchitecturalMsr.h>
     33#include <Register/Intel/Cpuid.h>
    3234#include "AmdSev.h"
    3335
     
    744746}
    745747
     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//
     753STATIC
     754VOID
     755SecMtrrSetup (
     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
    746788VOID
    747789EFIAPI
     
    942984  InitializeApicTimer (0, MAX_UINT32, TRUE, 5);
    943985  DisableApicTimerInterrupt ();
     986
     987  //
     988  // Initialize MTRR
     989  //
     990  SecMtrrSetup ();
    944991
    945992  //
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette