VirtualBox

Ignore:
Timestamp:
Aug 14, 2024 1:16:30 PM (6 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
164367
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

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

Legend:

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

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

    r99404 r105670  
    99
    1010#include <Library/BaseLib.h>
     11#include <Library/CpuLib.h>
     12#include <Library/CpuPageTableLib.h>
    1113#include <Library/DebugLib.h>
     14#include <Library/LocalApicLib.h>
    1215#include <Library/MemEncryptSevLib.h>
    1316#include <Library/BaseMemoryLib.h>
     
    302305  }
    303306}
     307
     308/**
     309  Map known MMIO regions unencrypted if SEV-ES is active.
     310
     311  During early booting, page table entries default to having the encryption bit
     312  set for SEV-ES/SEV-SNP guests. In cases where there is MMIO to an address, the
     313  encryption bit should be cleared. Clear it here for any known MMIO accesses
     314  during SEC, which is currently just the APIC base address.
     315
     316**/
     317VOID
     318SecMapApicBaseUnencrypted (
     319  VOID
     320  )
     321{
     322  PHYSICAL_ADDRESS    Cr3;
     323  UINT64              ApicAddress;
     324  VOID                *Buffer;
     325  UINTN               BufferSize;
     326  IA32_MAP_ATTRIBUTE  MapAttribute;
     327  IA32_MAP_ATTRIBUTE  MapMask;
     328  RETURN_STATUS       Status;
     329
     330  if (!SevEsIsEnabled ()) {
     331    return;
     332  }
     333
     334  ApicAddress = (UINT64)GetLocalApicBaseAddress ();
     335  Buffer      = (VOID *)(UINTN)FixedPcdGet32 (PcdOvmfSecApicPageTableBase);
     336  Cr3         = AsmReadCr3 ();
     337
     338  MapAttribute.Uint64         = ApicAddress;
     339  MapAttribute.Bits.Present   = 1;
     340  MapAttribute.Bits.ReadWrite = 1;
     341  MapMask.Uint64              = MAX_UINT64;
     342  BufferSize                  = SIZE_4KB;
     343
     344  Status = PageTableMap (
     345             (UINTN *)&Cr3,
     346             Paging4Level,
     347             Buffer,
     348             &BufferSize,
     349             ApicAddress,
     350             SIZE_4KB,
     351             &MapAttribute,
     352             &MapMask,
     353             NULL
     354             );
     355  if (RETURN_ERROR (Status)) {
     356    DEBUG ((DEBUG_ERROR, "Failed to map APIC MMIO region as unencrypted: %d\n", Status));
     357    ASSERT (FALSE);
     358  }
     359
     360  CpuFlushTlb ();
     361}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Sec/AmdSev.h

    r99404 r105670  
    9292  );
    9393
     94/**
     95  Map MMIO regions unencrypted if SEV-ES is active.
     96
     97  During early booting, page table entries default to having the encryption bit
     98  set for SEV-ES/SEV-SNP guests. In cases where there is MMIO to an address, the
     99  encryption bit should be cleared. Clear it here for any known MMIO accesses
     100  during SEC, which is currently just the APIC base address.
     101
     102**/
     103VOID
     104SecMapApicBaseUnencrypted (
     105  VOID
     106  );
     107
    94108#endif
  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Sec/SecMain.c

    r101291 r105670  
    1212#include <PiPei.h>
    1313
    14 #include <Library/PeimEntryPoint.h>
    1514#include <Library/BaseLib.h>
    1615#include <Library/DebugLib.h>
     
    845844  }
    846845
    847   ProcessLibraryConstructorList (NULL, NULL);
     846  ProcessLibraryConstructorList ();
    848847
    849848  if (!SevEsIsEnabled ()) {
     
    940939  // enabled.
    941940  //
     941  SecMapApicBaseUnencrypted ();
    942942  InitializeApicTimer (0, MAX_UINT32, TRUE, 5);
    943943  DisableApicTimerInterrupt ();
  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Sec/SecMain.inf

    r101291 r105670  
    99
    1010[Defines]
    11   INF_VERSION                    = 0x00010005
     11  INF_VERSION                    = 1.30
    1212  BASE_NAME                      = SecMain
    1313  FILE_GUID                      = df1ccef6-f301-4a63-9661-fc6030dcc880
     
    5656  CpuExceptionHandlerLib
    5757  CcProbeLib
     58  CpuPageTableLib
    5859
    5960[Ppis]
     
    8485  gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize
    8586  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
     87  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecApicPageTableBase
     88  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecApicPageTableSize
    8689
    8790[FeaturePcd]
Note: See TracChangeset for help on using the changeset viewer.

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