MdeModulePkg/Core/Dxe: Integrate CPU Architectural producer

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3223

In the current design, memory protection is not available till CpuDxe
is loaded. To resolve this, introduce CpuArchLib to move the
CPU Architectural initialization to DxeCore.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
This commit is contained in:
Mikhail Krichanov 2023-06-26 11:45:07 +03:00
parent 1ecb175538
commit e26eb0f9c1
79 changed files with 680 additions and 298 deletions

View File

@ -57,6 +57,7 @@
PeCoffLib2|MdePkg/Library/BasePeCoffLib2/BasePeCoffLib2.inf
UefiImageLib|MdePkg/Library/BaseUefiImageLib/BaseUefiImageLibPeCoff.inf
UefiImageExtraActionLib|MdePkg/Library/BaseUefiImageExtraActionLibNull/BaseUefiImageExtraActionLibNull.inf
CpuArchLib|ArmPkg/Library/CpuArchLib/CpuArchLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
@ -119,8 +120,8 @@
ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf
ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf
ArmPkg/Library/CpuArchLib/CpuArchLib.inf
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
ArmPkg/Drivers/CpuPei/CpuPei.inf
ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
ArmPkg/Drivers/ArmGic/ArmGicLib.inf

View File

@ -1,6 +1,6 @@
#/** @file
#
# DXE CPU driver
# This library installs CPU Architecture Protocol
#
# Copyright (c) 2009, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
@ -11,12 +11,11 @@
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ArmCpuDxe
FILE_GUID = B8D9777E-D72A-451F-9BDB-BAFB52A68415
MODULE_TYPE = DXE_DRIVER
BASE_NAME = CpuArchLib
FILE_GUID = 47EE96CC-33FA-482B-8AD6-DD8C21AA3752
MODULE_TYPE = DXE_CORE
VERSION_STRING = 1.0
ENTRY_POINT = CpuDxeInitialize
LIBRARY_CLASS = CpuArchLib
[Sources.Common]
CpuDxe.c
@ -49,7 +48,6 @@
DxeServicesTableLib
HobLib
MemoryAllocationLib
UefiDriverEntryPoint
UefiLib
[Protocols]

View File

@ -301,9 +301,8 @@ RemapUnusedMemoryNx (
}
EFI_STATUS
CpuDxeInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
InitializeCpu (
VOID
)
{
EFI_STATUS Status;
@ -360,3 +359,14 @@ CpuDxeInitialize (
return Status;
}
/**
Initialize Multi-processor support.
**/
VOID
InitializeMpSupport (
VOID
)
{
}

View File

@ -230,6 +230,7 @@
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
CpuArchLib|ArmPkg/Library/CpuArchLib/CpuArchLib.inf
[LibraryClasses.common.DXE_DRIVER]
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf

View File

@ -234,6 +234,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
<LibraryClasses>
@ -243,7 +246,6 @@
#
# Architectural Protocols
#
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>

View File

@ -112,7 +112,6 @@ READ_LOCK_STATUS = TRUE
#
# PI DXE Drivers producing Architectural Protocols (EFI Services)
#
INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

View File

@ -265,6 +265,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
<LibraryClasses>
@ -274,7 +277,6 @@
#
# Architectural Protocols
#
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>

View File

@ -127,7 +127,6 @@ READ_LOCK_STATUS = TRUE
#
# PI DXE Drivers producing Architectural Protocols (EFI Services)
#
INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

View File

@ -374,6 +374,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
<LibraryClasses>
@ -383,7 +386,6 @@
#
# Architectural Protocols
#
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>

View File

@ -47,7 +47,6 @@ READ_LOCK_STATUS = TRUE
#
# PI DXE Drivers producing Architectural Protocols (EFI Services)
#
INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

View File

@ -282,6 +282,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
<LibraryClasses>
@ -291,7 +294,6 @@
#
# Architectural Protocols
#
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>

View File

@ -167,6 +167,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
<LibraryClasses>
@ -176,7 +179,6 @@
#
# Architectural Protocols
#
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

View File

@ -144,7 +144,6 @@ READ_LOCK_STATUS = TRUE
#
# PI DXE Drivers producing Architectural Protocols (EFI Services)
#
INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

View File

@ -453,7 +453,7 @@ CoreDispatcher (
DEBUG ((DEBUG_INFO, "Loading driver %g\n", &DriverEntry->FileName));
Status = CoreLoadImage (
FALSE,
gDxeCoreImageHandle,
gImageHandle,
DriverEntry->FvFileDevicePath,
NULL,
0,

View File

@ -84,6 +84,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DxeServicesLib.h>
#include <Library/DebugAgentLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/CpuArchLib.h>
//
// attributes for reserved memory before it is promoted to system memory
@ -231,14 +232,14 @@ typedef struct {
//
// DXE Core Global Variables
//
extern EFI_SYSTEM_TABLE *gDxeCoreST;
extern EFI_RUNTIME_SERVICES *gDxeCoreRT;
extern EFI_DXE_SERVICES *gDxeCoreDS;
extern EFI_HANDLE gDxeCoreImageHandle;
extern EFI_SYSTEM_TABLE *gST;
extern EFI_RUNTIME_SERVICES *gRT;
extern EFI_DXE_SERVICES *gDS;
extern EFI_HANDLE gImageHandle;
extern BOOLEAN gMemoryMapTerminated;
extern BOOLEAN gMemoryMapTerminated;
extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress;
extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress;
extern EFI_RUNTIME_ARCH_PROTOCOL *gRuntime;
extern EFI_CPU_ARCH_PROTOCOL *gCpu;
@ -250,20 +251,21 @@ extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2;
extern EFI_BDS_ARCH_PROTOCOL *gBds;
extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2;
extern EFI_TPL gEfiCurrentTpl;
extern EFI_TPL gEfiCurrentTpl;
extern EFI_GUID *gDxeCoreFileName;
extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
extern EFI_GUID *gDxeCoreFileName;
extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1];
extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1];
extern BOOLEAN gDispatcherRunning;
extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;
extern BOOLEAN gDispatcherRunning;
extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;
extern BOOLEAN gMemoryAttributesTableForwardCfi;
extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable;
extern BOOLEAN gLoadFixedAddressCodeMemoryReady;
extern LOADED_IMAGE_PRIVATE_DATA * mCurrentImage;
//
// Service Initialization Functions
//

View File

@ -71,6 +71,7 @@
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseMemoryLib
@ -93,6 +94,7 @@
DebugAgentLib
CpuExceptionHandlerLib
PcdLib
CpuArchLib
[Guids]
gEfiEventMemoryMapChangeGuid ## PRODUCES ## Event

View File

@ -120,28 +120,6 @@ EFI_DXE_SERVICES mDxeServices = {
(EFI_SET_MEMORY_SPACE_CAPABILITIES)CoreSetMemorySpaceCapabilities, // SetMemorySpaceCapabilities
};
EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {
{
EFI_SYSTEM_TABLE_SIGNATURE, // Signature
EFI_SYSTEM_TABLE_REVISION, // Revision
sizeof (EFI_SYSTEM_TABLE), // HeaderSize
0, // CRC32
0 // Reserved
},
NULL, // FirmwareVendor
0, // FirmwareRevision
NULL, // ConsoleInHandle
NULL, // ConIn
NULL, // ConsoleOutHandle
NULL, // ConOut
NULL, // StandardErrorHandle
NULL, // StdErr
NULL, // RuntimeServices
&mBootServices, // BootServices
0, // NumberOfConfigurationTableEntries
NULL // ConfigurationTable
};
EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {
{
EFI_RUNTIME_SERVICES_SIGNATURE, // Signature
@ -166,6 +144,28 @@ EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {
(EFI_QUERY_VARIABLE_INFO)CoreEfiNotAvailableYetArg4 // QueryVariableInfo
};
EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {
{
EFI_SYSTEM_TABLE_SIGNATURE, // Signature
EFI_SYSTEM_TABLE_REVISION, // Revision
sizeof (EFI_SYSTEM_TABLE), // HeaderSize
0, // CRC32
0 // Reserved
},
NULL, // FirmwareVendor
0, // FirmwareRevision
NULL, // ConsoleInHandle
NULL, // ConIn
NULL, // ConsoleOutHandle
NULL, // ConOut
NULL, // StandardErrorHandle
NULL, // StdErr
&mEfiRuntimeServicesTableTemplate, // RuntimeServices
&mBootServices, // BootServices
0, // NumberOfConfigurationTableEntries
NULL // ConfigurationTable
};
EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {
INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),
INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),
@ -190,18 +190,19 @@ EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;
// DXE Core Global Variables for the EFI System Table, Boot Services Table,
// DXE Services Table, and Runtime Services Table
//
EFI_DXE_SERVICES *gDxeCoreDS = &mDxeServices;
EFI_SYSTEM_TABLE *gDxeCoreST = NULL;
EFI_DXE_SERVICES *gDS = &mDxeServices;
EFI_BOOT_SERVICES *gBS = &mBootServices;
EFI_SYSTEM_TABLE *gST = &mEfiSystemTableTemplate;
//
// For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory
// but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it
// For debug initialize gRT to template. gRT must be allocated from RT memory
// but gRT is used for ASSERT () and DEBUG () type macros so lets give it
// a value that will not cause debug infrastructure to crash early on.
//
EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;
EFI_HANDLE gDxeCoreImageHandle = NULL;
EFI_RUNTIME_SERVICES *gRT = &mEfiRuntimeServicesTableTemplate;
EFI_HANDLE gImageHandle = NULL;
BOOLEAN gMemoryMapTerminated = FALSE;
BOOLEAN gMemoryMapTerminated = FALSE;
//
// EFI Decompress Protocol
@ -243,18 +244,6 @@ DxeMain (
EFI_VECTOR_HANDOFF_INFO *VectorInfoList;
EFI_VECTOR_HANDOFF_INFO *VectorInfo;
//
// Setup the default exception handlers
//
VectorInfoList = NULL;
GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);
if (GuidHob != NULL) {
VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *)(GET_GUID_HOB_DATA (GuidHob));
}
Status = InitializeCpuExceptionHandlers (VectorInfoList);
ASSERT_EFI_ERROR (Status);
//
// Setup Stack Guard
//
@ -277,13 +266,19 @@ DxeMain (
// Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
// Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
//
gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);
ASSERT (gDxeCoreST != NULL);
gST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);
ASSERT (gST != NULL);
gDxeCoreRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);
ASSERT (gDxeCoreRT != NULL);
gRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);
ASSERT (gRT != NULL);
gDxeCoreST->RuntimeServices = gDxeCoreRT;
gST->RuntimeServices = gRT;
//
// Install the DXE Services Table into the EFI System Tables's Configuration Table
//
Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDS);
ASSERT_EFI_ERROR (Status);
//
// Start the Image Services.
@ -299,13 +294,44 @@ DxeMain (
Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);
ASSERT_EFI_ERROR (Status);
//
// Initialize the Event Services
//
Status = CoreInitializeEventServices ();
ASSERT_EFI_ERROR (Status);
//
// Register for the GUIDs of the Architectural Protocols, so the rest of the
// EFI Boot Services and EFI Runtime Services tables can be filled in.
// Also register for the GUIDs of optional protocols.
//
CoreNotifyOnProtocolInstallation ();
//
// Initialize CPU Architectural Protocol
//
InitializeCpu ();
MemoryProfileInstallProtocol ();
CoreInitializeMemoryAttributesTable ();
CoreInitializeMemoryProtection ();
ProtectUefiImage (mCurrentImage, &ImageContext);
//
// Call constructor for all libraries
//
ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);
ProcessLibraryConstructorList (gImageHandle, gST);
PERF_CROSSMODULE_END ("PEI");
PERF_CROSSMODULE_BEGIN ("DXE");
//
// Initialize Multi-processor support
//
InitializeMpSupport ();
//
// Log MemoryBaseAddress and MemoryLength again (from
// CoreInitializeMemoryServices()), now that library constructors have
@ -325,12 +351,6 @@ DxeMain (
//
UefiImageLoaderRelocateImageExtraAction (&ImageContext);
//
// Install the DXE Services Table into the EFI System Tables's Configuration Table
//
Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);
ASSERT_EFI_ERROR (Status);
//
// Install the HOB List into the EFI System Tables's Configuration Table
//
@ -370,7 +390,7 @@ DxeMain (
CoreNewDebugImageInfoEntry (
EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
gDxeCoreLoadedImage,
gDxeCoreImageHandle,
gImageHandle,
&ImageContext
);
@ -434,21 +454,11 @@ DxeMain (
DEBUG_CODE_END ();
//
// Initialize the Event Services
//
Status = CoreInitializeEventServices ();
ASSERT_EFI_ERROR (Status);
MemoryProfileInstallProtocol ();
CoreInitializeMemoryAttributesTable ();
CoreInitializeMemoryProtection ();
//
// Get persisted vector hand-off info from GUIDeed HOB again due to HobStart may be updated,
// and install configuration table
//
VectorInfoList = NULL;
GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);
if (GuidHob != NULL) {
VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *)(GET_GUID_HOB_DATA (GuidHob));
@ -488,26 +498,19 @@ DxeMain (
);
ASSERT_EFI_ERROR (Status);
//
// Register for the GUIDs of the Architectural Protocols, so the rest of the
// EFI Boot Services and EFI Runtime Services tables can be filled in.
// Also register for the GUIDs of optional protocols.
//
CoreNotifyOnProtocolInstallation ();
//
// Produce Firmware Volume Protocols, one for each FV in the HOB list.
//
Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST);
Status = FwVolBlockDriverInit (gImageHandle, gST);
ASSERT_EFI_ERROR (Status);
Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST);
Status = FwVolDriverInit (gImageHandle, gST);
ASSERT_EFI_ERROR (Status);
//
// Produce the Section Extraction Protocol
//
Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST);
Status = InitializeSectionExtraction (gImageHandle, gST);
ASSERT_EFI_ERROR (Status);
//
@ -806,18 +809,18 @@ CoreExitBootServices (
//
// Clear the non-runtime values of the EFI System Table
//
gDxeCoreST->BootServices = NULL;
gDxeCoreST->ConIn = NULL;
gDxeCoreST->ConsoleInHandle = NULL;
gDxeCoreST->ConOut = NULL;
gDxeCoreST->ConsoleOutHandle = NULL;
gDxeCoreST->StdErr = NULL;
gDxeCoreST->StandardErrorHandle = NULL;
gST->BootServices = NULL;
gST->ConIn = NULL;
gST->ConsoleInHandle = NULL;
gST->ConOut = NULL;
gST->ConsoleOutHandle = NULL;
gST->StdErr = NULL;
gST->StandardErrorHandle = NULL;
//
// Recompute the 32-bit CRC of the EFI System Table
//
CalculateEfiHdrCrc (&gDxeCoreST->Hdr);
CalculateEfiHdrCrc (&gST->Hdr);
//
// Zero out the Boot Service Table

View File

@ -194,10 +194,10 @@ GenericProtocolNotify (
//
// It's over kill to do them all every time, but it saves a lot of code.
//
CalculateEfiHdrCrc (&gDxeCoreRT->Hdr);
CalculateEfiHdrCrc (&gRT->Hdr);
CalculateEfiHdrCrc (&gBS->Hdr);
CalculateEfiHdrCrc (&gDxeCoreST->Hdr);
CalculateEfiHdrCrc (&gDxeCoreDS->Hdr);
CalculateEfiHdrCrc (&gST->Hdr);
CalculateEfiHdrCrc (&gDS->Hdr);
}
/**

View File

@ -1483,7 +1483,7 @@ CoreAddMemorySpace (
EFI_PAGE_SHIFT,
PageLength,
&PageBaseAddress,
gDxeCoreImageHandle,
gImageHandle,
NULL
);
@ -1502,7 +1502,7 @@ CoreAddMemorySpace (
EFI_PAGE_SHIFT,
EFI_PAGE_SIZE,
&PageBaseAddress,
gDxeCoreImageHandle,
gImageHandle,
NULL
);
@ -2661,7 +2661,7 @@ CoreInitializeGcdServices (
0,
MemoryLength,
&MemoryBaseAddress,
gDxeCoreImageHandle,
gImageHandle,
NULL
);
}
@ -2682,7 +2682,7 @@ CoreInitializeGcdServices (
0,
MemoryHob->AllocDescriptor.MemoryLength,
&BaseAddress,
gDxeCoreImageHandle,
gImageHandle,
NULL
);
if (!EFI_ERROR (Status) &&
@ -2708,7 +2708,7 @@ CoreInitializeGcdServices (
0,
FirmwareVolumeHob->Length,
&BaseAddress,
gDxeCoreImageHandle,
gImageHandle,
NULL
);
}
@ -2756,7 +2756,7 @@ CoreInitializeGcdServices (
0,
Length,
&BaseAddress,
gDxeCoreImageHandle,
gImageHandle,
NULL
);
}
@ -2798,7 +2798,7 @@ CoreInitializeGcdServices (
0,
Length,
&BaseAddress,
gDxeCoreImageHandle,
gImageHandle,
NULL
);
}

View File

@ -928,7 +928,7 @@ CoreHandleProtocol (
UserHandle,
Protocol,
Interface,
gDxeCoreImageHandle,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
);

View File

@ -251,7 +251,7 @@ CoreInitializeImageServices (
Image->ImageBasePage = DxeCoreImageBaseAddress;
Image->NumberOfPages = (UINTN)(EFI_SIZE_TO_PAGES ((UINTN)(DxeCoreImageLength)));
Image->Tpl = gEfiCurrentTpl;
Image->Info.SystemTable = gDxeCoreST;
Image->Info.SystemTable = gST;
Image->Info.ImageBase = (VOID *)(UINTN)DxeCoreImageBaseAddress;
Image->Info.ImageSize = DxeCoreImageLength;
@ -271,7 +271,7 @@ CoreInitializeImageServices (
//
// Fill in DXE globals
//
gDxeCoreImageHandle = Image->Handle;
gImageHandle = Image->Handle;
gDxeCoreLoadedImage = &Image->Info;
//
@ -298,8 +298,6 @@ CoreInitializeImageServices (
InitializeListHead (&mAvailableEmulators);
ProtectUefiImage (Image, ImageContext);
return Status;
}
@ -1285,7 +1283,7 @@ CoreLoadImageCommon (
// Initialize the fields for an internal driver
//
Image->Signature = LOADED_IMAGE_PRIVATE_DATA_SIGNATURE;
Image->Info.SystemTable = gDxeCoreST;
Image->Info.SystemTable = gST;
Image->Info.DeviceHandle = DeviceHandle;
Image->Info.Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
Image->Info.FilePath = DuplicateDevicePath (FilePath);

View File

@ -419,7 +419,7 @@ PromoteMemoryResource (
}
Entry->Capabilities |= EFI_MEMORY_TESTED;
Entry->ImageHandle = gDxeCoreImageHandle;
Entry->ImageHandle = gImageHandle;
Entry->DeviceHandle = NULL;
//

View File

@ -119,7 +119,7 @@ CoreInitializeDebugImageInfoTable (
// Initialize EFI_SYSTEM_TABLE_POINTER structure
//
mDebugTable->Signature = EFI_SYSTEM_TABLE_SIGNATURE;
mDebugTable->EfiSystemTableBase = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreST;
mDebugTable->EfiSystemTableBase = (EFI_PHYSICAL_ADDRESS)(UINTN)gST;
mDebugTable->Crc32 = 0;
//

View File

@ -45,18 +45,18 @@ CoreInstallConfigurationTable (
return EFI_INVALID_PARAMETER;
}
EfiConfigurationTable = gDxeCoreST->ConfigurationTable;
EfiConfigurationTable = gST->ConfigurationTable;
//
// Search all the table for an entry that matches Guid
//
for (Index = 0; Index < gDxeCoreST->NumberOfTableEntries; Index++) {
if (CompareGuid (Guid, &(gDxeCoreST->ConfigurationTable[Index].VendorGuid))) {
for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
if (CompareGuid (Guid, &(gST->ConfigurationTable[Index].VendorGuid))) {
break;
}
}
if (Index < gDxeCoreST->NumberOfTableEntries) {
if (Index < gST->NumberOfTableEntries) {
//
// A match was found, so this is either a modify or a delete operation
//
@ -65,7 +65,7 @@ CoreInstallConfigurationTable (
// If Table is not NULL, then this is a modify operation.
// Modify the table entry and return.
//
gDxeCoreST->ConfigurationTable[Index].VendorTable = Table;
gST->ConfigurationTable[Index].VendorTable = Table;
//
// Signal Configuration Table change
@ -78,15 +78,15 @@ CoreInstallConfigurationTable (
//
// A match was found and Table is NULL, so this is a delete operation.
//
gDxeCoreST->NumberOfTableEntries--;
gST->NumberOfTableEntries--;
//
// Copy over deleted entry
//
CopyMem (
&(EfiConfigurationTable[Index]),
&(gDxeCoreST->ConfigurationTable[Index + 1]),
(gDxeCoreST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
&(gST->ConfigurationTable[Index + 1]),
(gST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
);
} else {
//
@ -101,7 +101,7 @@ CoreInstallConfigurationTable (
}
//
// Assume that Index == gDxeCoreST->NumberOfTableEntries
// Assume that Index == gST->NumberOfTableEntries
//
if ((Index * sizeof (EFI_CONFIGURATION_TABLE)) >= mSystemTableAllocateSize) {
//
@ -116,30 +116,30 @@ CoreInstallConfigurationTable (
return EFI_OUT_OF_RESOURCES;
}
if (gDxeCoreST->ConfigurationTable != NULL) {
if (gST->ConfigurationTable != NULL) {
//
// Copy the old table to the new table.
//
CopyMem (
EfiConfigurationTable,
gDxeCoreST->ConfigurationTable,
gST->ConfigurationTable,
Index * sizeof (EFI_CONFIGURATION_TABLE)
);
//
// Record the old table pointer.
//
OldTable = gDxeCoreST->ConfigurationTable;
OldTable = gST->ConfigurationTable;
//
// As the CoreInstallConfigurationTable() may be re-entered by CoreFreePool()
// in its calling stack, updating System table to the new table pointer must
// be done before calling CoreFreePool() to free the old table.
// It can make sure the gDxeCoreST->ConfigurationTable point to the new table
// It can make sure the gST->ConfigurationTable point to the new table
// and avoid the errors of use-after-free to the old table by the reenter of
// CoreInstallConfigurationTable() in CoreFreePool()'s calling stack.
//
gDxeCoreST->ConfigurationTable = EfiConfigurationTable;
gST->ConfigurationTable = EfiConfigurationTable;
//
// Free the old table after updating System Table to the new table pointer.
@ -149,7 +149,7 @@ CoreInstallConfigurationTable (
//
// Update System Table
//
gDxeCoreST->ConfigurationTable = EfiConfigurationTable;
gST->ConfigurationTable = EfiConfigurationTable;
}
}
@ -162,13 +162,13 @@ CoreInstallConfigurationTable (
//
// This is an add operation, so increment the number of table entries
//
gDxeCoreST->NumberOfTableEntries++;
gST->NumberOfTableEntries++;
}
//
// Fix up the CRC-32 in the EFI System Table
//
CalculateEfiHdrCrc (&gDxeCoreST->Hdr);
CalculateEfiHdrCrc (&gST->Hdr);
//
// Signal Configuration Table change

View File

@ -0,0 +1,48 @@
/** @file
Dummy instance of DXE Services Table Library for DxeCore.
Relies on and sanity-checks that DxeCore provides the variables itself.
Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiDxe.h>
#include <Guid/DxeServices.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
/**
The constructor function sanity-checks the variables set by DxeCore.
It will always return EFI_SUCCESS.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
DxeServicesTableLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_DXE_SERVICES *DS;
//
// ASSERT that DxeCore provides the services correctly and in time
//
DEBUG_CODE_BEGIN ();
Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &DS);
ASSERT_EFI_ERROR (Status);
ASSERT (gDS == DS);
DEBUG_CODE_END ();
ASSERT (gDS != NULL);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,40 @@
## @file
# Dummy instance of DXE Services Table Library for DxeCore.
#
# Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeCoreDxeServicesTableLib
MODULE_UNI_FILE = DxeCoreDxeServicesTableLib.uni
FILE_GUID = 898fc74c-b07c-4b68-bdd3-365c9ce26a9d
MODULE_TYPE = DXE_CORE
VERSION_STRING = 1.0
LIBRARY_CLASS = DxeServicesTableLib|DXE_CORE
CONSTRUCTOR = DxeServicesTableLibConstructor
#
# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64
#
[Sources]
DxeCoreDxeServicesTableLib.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
UefiLib
DebugLib
[Guids]
gEfiDxeServicesTableGuid ## CONSUMES ## SystemTable

View File

@ -0,0 +1,13 @@
// /** @file
// Dummy instance of DXE Services Table Library for DxeCore.
//
// Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "Dummy instance for DxeCore"
#string STR_MODULE_DESCRIPTION #language en-US "DXE Services Table Library retrieves a pointer to the DXE Services Table from the Configuration Table in the EFI System Table."

View File

@ -0,0 +1,44 @@
/** @file
Dummy instance of UEFI Boot Services Table Library for DxeCore.
Relies on and sanity-checks that DxeCore provides the variables itself.
Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
/**
The constructor function sanity-checks the variables set by DxeCore.
It will always return EFI_SUCCESS.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
UefiBootServicesTableLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
// ASSERT that DxeCore provides the services correctly and in time
//
ASSERT (gImageHandle == ImageHandle);
ASSERT (gImageHandle != NULL);
ASSERT (gST == SystemTable);
ASSERT (gST != NULL);
ASSERT (gBS == gST->BootServices);
ASSERT (gBS != NULL);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,34 @@
## @file
# Dummy instance of UEFI Boot Services Table Library for DxeCore.
#
# Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeCoreUefiBootServicesTableLib
MODULE_UNI_FILE = DxeCoreUefiBootServicesTableLib.uni
FILE_GUID = 67ecd0d0-5e42-4933-baee-cb129e4f4c55
MODULE_TYPE = DXE_CORE
VERSION_STRING = 1.0
LIBRARY_CLASS = UefiBootServicesTableLib|DXE_CORE
CONSTRUCTOR = UefiBootServicesTableLibConstructor
#
# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64
#
[Sources]
DxeCoreUefiBootServicesTableLib.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
DebugLib

View File

@ -0,0 +1,13 @@
// /** @file
// Dummy instance of UEFI Boot Services Table Library for DxeCore.
//
// Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "Dummy instance of UEFI Boot Services Table Library for DxeCore"
#string STR_MODULE_DESCRIPTION #language en-US "Dummy instance of UEFI Boot Services Table Library for DxeCore."

View File

@ -0,0 +1,39 @@
/** @file
Dummy instance of UEFI Runtime Services Table Library for DxeCore.
Relies on and sanity-checks that DxeCore provides the variables itself.
Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Uefi.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/DebugLib.h>
/**
The constructor function sanity-checks the variables set by DxeCore.
It will always return EFI_SUCCESS.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
UefiRuntimeServicesTableLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
// ASSERT that DxeCore provides the services correctly and in time
//
ASSERT (gRT == SystemTable->RuntimeServices);
ASSERT (gRT != NULL);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,35 @@
## @file
# Dummy instance of UEFI Runtime Services Table Library for DxeCore.
#
# Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeCoreUefiRuntimeServicesTableLib
MODULE_UNI_FILE = DxeCoreUefiRuntimeServicesTableLib.uni
FILE_GUID = 59a35203-341d-46b6-96f6-ec69e035b02e
MODULE_TYPE = DXE_CORE
VERSION_STRING = 1.0
LIBRARY_CLASS = UefiRuntimeServicesTableLib|DXE_CORE
CONSTRUCTOR = UefiRuntimeServicesTableLibConstructor
#
# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64
#
[Sources]
DxeCoreUefiRuntimeServicesTableLib.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
DebugLib

View File

@ -0,0 +1,13 @@
// /** @file
// Dummy instance of UEFI Runtime Services Table Library for DxeCore.
//
// Copyright (c) 2021, Marvin Häuser. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "Dummy instance of UEFI Runtime Services Table Library for DxeCore"
#string STR_MODULE_DESCRIPTION #language en-US "Dummy instance of UEFI Runtime Services Table Library for DxeCore."

View File

@ -125,6 +125,22 @@
HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
CpuArchLib|UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
[LibraryClasses.IA32.DXE_CORE]
CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
[LibraryClasses.X64.DXE_CORE]
CcExitLib|OvmfPkg/Library/CcExitLib/CcExitLib.inf
[LibraryClasses.common.DXE_DRIVER]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
@ -346,6 +362,9 @@
MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf
MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
@ -527,4 +546,3 @@
MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
[BuildOptions]

View File

@ -55,6 +55,9 @@ typedef struct {
BOOLEAN QemuFwCfgChecked;
BOOLEAN QemuFwCfgSupported;
BOOLEAN QemuFwCfgDmaSupported;
UINT64 PteMemoryEncryptionAddressOrMask;
UINT64 GhcbBase;
} EFI_HOB_PLATFORM_INFO;
#pragma pack()

View File

@ -254,6 +254,8 @@
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
CpuArchLib|UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@ -576,6 +578,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
@ -598,29 +603,6 @@
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf {
<LibraryClasses>
#
# Directly use DxeMpInitLib. It depends on DxeMpInitLibMpDepLib which
# checks the Protocol of gEfiMpInitLibMpDepProtocolGuid.
#
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
NULL|OvmfPkg/Library/MpInitLibDepLib/DxeMpInitLibMpDepLib.inf
}
UefiCpuPkg/CpuDxe/CpuDxe.inf {
<Defines>
FILE_GUID = $(UP_CPU_DXE_GUID)
<LibraryClasses>
#
# Directly use MpInitLibUp. It depends on DxeMpInitLibUpDepLib which
# checks the Protocol of gEfiMpInitLibUpDepProtocolGuid.
#
MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
NULL|OvmfPkg/Library/MpInitLibDepLib/DxeMpInitLibUpDepLib.inf
}
OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf
OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf

View File

@ -189,9 +189,6 @@ INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF UefiCpuPkg/CpuDxe/CpuDxe.inf
INF FILE_GUID = $(UP_CPU_DXE_GUID) UefiCpuPkg/CpuDxe/CpuDxe.inf
INF OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf
INF OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf

View File

@ -323,6 +323,8 @@
!endif
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
CpuArchLib|UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@ -739,6 +741,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
@ -760,7 +765,6 @@
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf
!ifdef $(CSM_ENABLE)
OvmfPkg/8259InterruptControllerDxe/8259.inf
OvmfPkg/8254TimerDxe/8254Timer.inf

View File

@ -218,7 +218,6 @@ INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF UefiCpuPkg/CpuDxe/CpuDxe.inf
!ifdef $(CSM_ENABLE)
INF OvmfPkg/8259InterruptControllerDxe/8259.inf
INF OvmfPkg/8254TimerDxe/8254Timer.inf

View File

@ -329,6 +329,8 @@
!endif
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
CpuArchLib|UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@ -760,6 +762,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
@ -781,7 +786,6 @@
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf
!ifdef $(CSM_ENABLE)
OvmfPkg/8259InterruptControllerDxe/8259.inf
OvmfPkg/8254TimerDxe/8254Timer.inf

View File

@ -219,7 +219,6 @@ INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF UefiCpuPkg/CpuDxe/CpuDxe.inf
!ifdef $(CSM_ENABLE)
INF OvmfPkg/8259InterruptControllerDxe/8259.inf
INF OvmfPkg/8254TimerDxe/8254Timer.inf

View File

@ -348,6 +348,8 @@
!endif
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
CpuArchLib|UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@ -798,6 +800,9 @@
<LibraryClasses>
NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
@ -820,29 +825,6 @@
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf {
<LibraryClasses>
#
# Directly use DxeMpInitLib. It depends on DxeMpInitLibMpDepLib which
# checks the Protocol of gEfiMpInitLibMpDepProtocolGuid.
#
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
NULL|OvmfPkg/Library/MpInitLibDepLib/DxeMpInitLibMpDepLib.inf
}
UefiCpuPkg/CpuDxe/CpuDxe.inf {
<Defines>
FILE_GUID = $(UP_CPU_DXE_GUID)
<LibraryClasses>
#
# Directly use MpInitLibUp. It depends on DxeMpInitLibUpDepLib which
# checks the Protocol of gEfiMpInitLibUpDepProtocolGuid.
#
MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
NULL|OvmfPkg/Library/MpInitLibDepLib/DxeMpInitLibUpDepLib.inf
}
!ifdef $(CSM_ENABLE)
OvmfPkg/8259InterruptControllerDxe/8259.inf
OvmfPkg/8254TimerDxe/8254Timer.inf

View File

@ -242,9 +242,6 @@ INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF UefiCpuPkg/CpuDxe/CpuDxe.inf
INF FILE_GUID = $(UP_CPU_DXE_GUID) UefiCpuPkg/CpuDxe/CpuDxe.inf
!ifdef $(CSM_ENABLE)
INF OvmfPkg/8259InterruptControllerDxe/8259.inf
INF OvmfPkg/8254TimerDxe/8254Timer.inf

View File

@ -258,6 +258,9 @@ AmdSevEsInitialize (
Status = PcdSet64S (PcdGhcbBase, GhcbBasePa);
ASSERT_RETURN_ERROR (Status);
PlatformInfoHob->GhcbBase = GhcbBasePa;
Status = PcdSet64S (PcdGhcbSize, EFI_PAGES_TO_SIZE (GhcbPageCount));
ASSERT_RETURN_ERROR (Status);
@ -368,6 +371,8 @@ AmdSevInitialize (
PcdStatus = PcdSet64S (PcdPteMemoryEncryptionAddressOrMask, EncryptionMask);
ASSERT_RETURN_ERROR (PcdStatus);
PlatformInfoHob->PteMemoryEncryptionAddressOrMask = EncryptionMask;
DEBUG ((DEBUG_INFO, "SEV is enabled (mask 0x%lx)\n", EncryptionMask));
//
@ -428,10 +433,13 @@ AmdSevInitialize (
//
if (MemEncryptSevSnpIsEnabled ()) {
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrAmdSevSnp);
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrAmdSevSnp;
} else if (MemEncryptSevEsIsEnabled ()) {
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrAmdSevEs);
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrAmdSevEs;
} else {
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrAmdSev);
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrAmdSev;
}
ASSERT_RETURN_ERROR (PcdStatus);

View File

@ -30,11 +30,12 @@
**/
VOID
IntelTdxInitialize (
VOID
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
)
{
#ifdef MDE_CPU_X64
RETURN_STATUS PcdStatus;
UINT64 PageMask;
if (!TdIsEnabled ()) {
return;
@ -45,9 +46,14 @@ IntelTdxInitialize (
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrIntelTdx);
ASSERT_RETURN_ERROR (PcdStatus);
PcdStatus = PcdSet64S (PcdTdxSharedBitMask, TdSharedPageMask ());
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrIntelTdx;
PageMask = TdSharedPageMask ();
PcdStatus = PcdSet64S (PcdTdxSharedBitMask, PageMask);
ASSERT_RETURN_ERROR (PcdStatus);
PlatformInfoHob->PcdTdxSharedBitMask = PageMask;
PcdStatus = PcdSetBoolS (PcdSetNxForStack, TRUE);
ASSERT_RETURN_ERROR (PcdStatus);
#endif

View File

@ -365,7 +365,7 @@ InitializePlatform (
MiscInitialization (PlatformInfoHob);
}
IntelTdxInitialize ();
IntelTdxInitialize (PlatformInfoHob);
InstallFeatureControlCallback (PlatformInfoHob);
return EFI_SUCCESS;

View File

@ -90,7 +90,7 @@ AmdSevInitialize (
**/
VOID
IntelTdxInitialize (
VOID
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
);
/**

View File

@ -1,16 +0,0 @@
// /** @file
// CPU driver installs CPU Architecture Protocol and CPU MP Protocol.
//
// CPU driver installs CPU Architecture Protocol and CPU MP Protocol.
//
// Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol."
#string STR_MODULE_DESCRIPTION #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol."

View File

@ -0,0 +1,31 @@
/** @file
CPU DXE Module to produce CPU ARCH Protocol.
Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef _CPU_ARCH_LIB_H_
#define _CPU_ARCH_LIB_H_
/**
Initialize the state information for the CPU Architectural Protocol.
@retval EFI_SUCCESS Thread can be successfully created
@retval EFI_OUT_OF_RESOURCES Can not allocate protocol data structure
@retval EFI_DEVICE_ERROR Can not create the thread
**/
EFI_STATUS
InitializeCpu (
VOID
);
/**
Initialize Multi-processor support.
**/
VOID
InitializeMpSupport (
VOID
);
#endif // _CPU_ARCH_LIB_H_

View File

@ -1,5 +1,5 @@
## @file
# CPU driver installs CPU Architecture Protocol and CPU MP protocol.
# This library installs CPU Architecture Protocol and CPU MP protocol.
#
# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
@ -10,16 +10,17 @@
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = CpuDxe
MODULE_UNI_FILE = CpuDxe.uni
FILE_GUID = 1A1E4886-9517-440e-9FDE-3BE44CEE2136
MODULE_TYPE = DXE_DRIVER
BASE_NAME = CpuArchLib
MODULE_UNI_FILE = CpuArchLib.uni
FILE_GUID = EF9CBDF2-BD7C-48F1-9D87-EE83A0269EEE
MODULE_TYPE = DXE_CORE
VERSION_STRING = 1.0
ENTRY_POINT = InitializeCpu
LIBRARY_CLASS = CpuArchLib
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
OvmfPkg/OvmfPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
@ -31,7 +32,6 @@
MemoryAllocationLib
MtrrLib
UefiBootServicesTableLib
UefiDriverEntryPoint
LocalApicLib
UefiLib
CpuExceptionHandlerLib
@ -39,7 +39,8 @@
ReportStatusCodeLib
MpInitLib
TimerLib
SerialPortLib
[Sources]
CpuDxe.c
CpuDxe.h
@ -66,19 +67,18 @@
[Guids]
gIdleLoopEventGuid ## CONSUMES ## Event
gEfiVectorHandoffTableGuid ## SOMETIMES_CONSUMES ## SystemTable
gUefiOvmfPkgPlatformInfoGuid ## CONSUMES ## HOB
[Ppis]
gEfiSecPlatformInformation2PpiGuid ## UNDEFINED # HOB
gEfiSecPlatformInformationPpiGuid ## UNDEFINED # HOB
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask ## CONSUMES
[Depex]
TRUE

View File

@ -0,0 +1,13 @@
// /** @file
// This library installs CPU Architecture Protocol and CPU MP Protocol.
//
// Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "This library installs CPU Architecture Protocol and CPU MP Protocol."
#string STR_MODULE_DESCRIPTION #language en-US "This library installs CPU Architecture Protocol and CPU MP Protocol."

View File

@ -0,0 +1,24 @@
## @file
# This library provides dummy InitializeCpu() for DxeMain.inf.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = CpuArchLib
FILE_GUID = EF9CBDF2-BD7C-48F1-9D87-EE83A0269EEE
MODULE_TYPE = DXE_CORE
VERSION_STRING = 1.0
LIBRARY_CLASS = CpuArchLib
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
BaseLib
[Sources]
CpuDxeNull.c

View File

@ -21,7 +21,7 @@ BOOLEAN mIsFlushingGCD;
BOOLEAN mIsAllocatingPageTable = FALSE;
UINT64 mTimerPeriod = 0;
EFI_CPU_ARCH_PROTOCOL gCpu = {
EFI_CPU_ARCH_PROTOCOL gCpuImpl = {
CpuFlushCpuDataCache,
CpuEnableInterrupt,
CpuDisableInterrupt,
@ -34,6 +34,8 @@ EFI_CPU_ARCH_PROTOCOL gCpu = {
4 // DmaBufferAlignment
};
EFI_HOB_PLATFORM_INFO *mPlatformInfoHob2 = NULL;
//
// CPU Arch Protocol Functions
//
@ -947,7 +949,7 @@ FreeMemorySpaceMap:
**/
VOID
AddLocalApicMemorySpace (
IN EFI_HANDLE ImageHandle
VOID
)
{
EFI_STATUS Status;
@ -968,7 +970,7 @@ AddLocalApicMemorySpace (
0,
SIZE_4KB,
&BaseAddress,
ImageHandle,
gImageHandle,
NULL
);
if (EFI_ERROR (Status)) {
@ -985,23 +987,24 @@ AddLocalApicMemorySpace (
/**
Initialize the state information for the CPU Architectural Protocol.
@param ImageHandle Image handle this driver.
@param SystemTable Pointer to the System Table.
@retval EFI_SUCCESS Thread can be successfully created
@retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
@retval EFI_DEVICE_ERROR Cannot create the thread
@retval EFI_OUT_OF_RESOURCES Can not allocate protocol data structure
@retval EFI_DEVICE_ERROR Can not create the thread
**/
EFI_STATUS
EFIAPI
InitializeCpu (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
VOID
)
{
EFI_STATUS Status;
EFI_EVENT IdleLoopEvent;
EFI_STATUS Status;
EFI_EVENT IdleLoopEvent;
EFI_HOB_GUID_TYPE *GuidHob;
GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
if (GuidHob != NULL) {
mPlatformInfoHob2 = (EFI_HOB_PLATFORM_INFO *)(GET_GUID_HOB_DATA (GuidHob));
}
InitializePageTableLib ();
@ -1028,7 +1031,7 @@ InitializeCpu (
Status = gBS->InstallMultipleProtocolInterfaces (
&mCpuHandle,
&gEfiCpuArchProtocolGuid,
&gCpu,
&gCpuImpl,
NULL
);
ASSERT_EFI_ERROR (Status);
@ -1041,7 +1044,7 @@ InitializeCpu (
//
// Add and allocate local APIC memory mapped space
//
AddLocalApicMemorySpace (ImageHandle);
AddLocalApicMemorySpace ();
//
// Setup a callback for idle events
@ -1056,7 +1059,5 @@ InitializeCpu (
);
ASSERT_EFI_ERROR (Status);
InitializeMpSupport ();
return Status;
}

View File

@ -35,6 +35,7 @@
#include <Library/ReportStatusCodeLib.h>
#include <Library/MpInitLib.h>
#include <Library/TimerLib.h>
#include <Library/PlatformInitLib.h>
#include <Guid/IdleLoopEvent.h>
#include <Guid/VectorHandoffTable.h>
@ -293,7 +294,8 @@ PageFaultExceptionHandler (
IN EFI_SYSTEM_CONTEXT SystemContext
);
extern BOOLEAN mIsAllocatingPageTable;
extern UINTN mNumberOfProcessors;
extern BOOLEAN mIsAllocatingPageTable;
extern UINTN mNumberOfProcessors;
extern EFI_HOB_PLATFORM_INFO *mPlatformInfoHob2;
#endif

View File

@ -9,6 +9,4 @@
#string STR_PROPERTIES_MODULE_NAME
#language en-US
"CPU Architectural and CPU Multi-processor DXE Driver"
"CPU Architectural and CPU Multi-processor DXE library"

View File

@ -0,0 +1,25 @@
/**
Initialize the state information for the CPU Architectural Protocol.
@retval EFI_SUCCESS Thread can be successfully created
@retval EFI_OUT_OF_RESOURCES Can not allocate protocol data structure
@retval EFI_DEVICE_ERROR Can not create the thread
**/
EFI_STATUS
InitializeCpu (
VOID
)
{
return EFI_SUCCESS;
}
/**
Initialize Multi-processor support.
**/
VOID
InitializeMpSupport (
VOID
)
{
}

View File

@ -9,15 +9,6 @@
#ifndef _CPU_MP_H_
#define _CPU_MP_H_
/**
Initialize Multi-processor support.
**/
VOID
InitializeMpSupport (
VOID
);
/**
This service retrieves the number of logical processor in the platform
and the number of those logical processors that are enabled on this boot.

View File

@ -90,13 +90,13 @@ PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = {
PAGE_TABLE_POOL *mPageTablePool = NULL;
BOOLEAN mPageTablePoolLock = FALSE;
PAGE_TABLE_LIB_PAGING_CONTEXT mPagingContext;
EFI_SMM_BASE2_PROTOCOL *mSmmBase2 = NULL;
EFI_SMM_BASE2_PROTOCOL *mSmmBase2 = NULL;
//
// Record the page fault exception count for one instruction execution.
//
UINTN *mPFEntryCount;
UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT];
UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT];
/**
Check if current execution environment is in SMM mode or not, via
@ -308,9 +308,9 @@ GetPageTableEntry (
// Make sure AddressEncMask is contained to smallest supported address field.
//
AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
AddressEncMask = mPlatformInfoHob2->PteMemoryEncryptionAddressOrMask & PAGING_1G_ADDRESS_MASK_64;
if (AddressEncMask == 0) {
AddressEncMask = PcdGet64 (PcdTdxSharedBitMask) & PAGING_1G_ADDRESS_MASK_64;
AddressEncMask = mPlatformInfoHob2->PcdTdxSharedBitMask & PAGING_1G_ADDRESS_MASK_64;
}
if (PagingContext->MachineType == IMAGE_FILE_MACHINE_X64) {
@ -566,7 +566,7 @@ SplitPage (
// Make sure AddressEncMask is contained to smallest supported address field.
//
AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
AddressEncMask = mPlatformInfoHob2->PteMemoryEncryptionAddressOrMask & PAGING_1G_ADDRESS_MASK_64;
if (PageAttribute == Page2M) {
//

View File

@ -13,7 +13,7 @@
FILE_GUID = B88F7146-9834-4c55-BFAC-481CC0C33736
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.1
LIBRARY_CLASS = MpInitLib|DXE_DRIVER
LIBRARY_CLASS = MpInitLib|DXE_DRIVER DXE_CORE
#
# The following information is for reference only and not required by the build tools.
@ -43,6 +43,7 @@
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
OvmfPkg/OvmfPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
@ -68,10 +69,9 @@
gEfiEventExitBootServicesGuid ## CONSUMES ## Event
gEfiEventLegacyBootGuid ## SOMETIMES_CONSUMES ## Event
gEdkiiMicrocodePatchHobGuid ## SOMETIMES_CONSUMES ## HOB
gUefiOvmfPkgPlatformInfoGuid ## CONSUMES ## HOB
[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOMETIMES_CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES
@ -83,5 +83,3 @@
gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase ## SOMETIMES_CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdFirstTimeWakeUpAPsBySipi ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr ## CONSUMES

View File

@ -9,12 +9,16 @@
**/
#include "MpLib.h"
#include <Library/CcExitLib.h>
#include <Library/PlatformInitLib.h>
#include <Register/Amd/Fam17Msr.h>
#include <Register/Amd/Ghcb.h>
EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID;
EFI_GUID mMpHandOffGuid = MP_HANDOFF_GUID;
EFI_GUID mMpHandOffGuid = MP_HANDOFF_GUID;
EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID;
EFI_HOB_PLATFORM_INFO *mPlatformInfoHob = NULL;
/**
Save the volatile registers required to be restored following INIT IPI.
@ -522,7 +526,7 @@ CollectProcessorCount (
// FinishedCount is the number of check-in APs.
//
CpuMpData->CpuCount = CpuMpData->FinishedCount + 1;
ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
ASSERT (CpuMpData->CpuCount <= mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber);
//
// Enable x2APIC mode if
@ -1154,7 +1158,7 @@ AllocateResetVectorBelow1Mb (
// of processors for calculating the total stack area.
//
ApResetStackSize = (AP_RESET_STACK_SIZE *
PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber);
//
// Invoke GetWakeupBuffer a second time to allocate the stack area
@ -1306,7 +1310,7 @@ WakeUpAP (
}
if (CpuMpData->InitFlag == ApInitConfig) {
if (PcdGet32 (PcdCpuBootLogicalProcessorNumber) > 0) {
if (mPlatformInfoHob->PcdCpuBootLogicalProcessorNumber > 0) {
//
// The AP enumeration algorithm below is suitable only when the
// platform can tell us the *exact* boot CPU count in advance.
@ -1322,7 +1326,7 @@ WakeUpAP (
//
TimedWaitForApFinish (
CpuMpData,
PcdGet32 (PcdCpuBootLogicalProcessorNumber) - 1,
mPlatformInfoHob->PcdCpuBootLogicalProcessorNumber - 1,
MAX_UINT32 // approx. 71 minutes
);
} else {
@ -1360,7 +1364,7 @@ WakeUpAP (
//
TimedWaitForApFinish (
CpuMpData,
PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,
mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber - 1,
PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)
);
@ -2006,10 +2010,16 @@ MpInitLibInitialize (
UINTN ApResetVectorSizeAbove1Mb;
UINTN BackupBufferAddr;
UINTN ApIdtBase;
EFI_HOB_GUID_TYPE *GuidHob;
GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
if (GuidHob != NULL) {
mPlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)(GET_GUID_HOB_DATA (GuidHob));
}
MpHandOff = GetMpHandOffHob ();
if (MpHandOff == NULL) {
MaxLogicalProcessorNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
MaxLogicalProcessorNumber = mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber;
} else {
MaxLogicalProcessorNumber = MpHandOff->CpuCount;
}
@ -2086,7 +2096,7 @@ MpInitLibInitialize (
CpuMpData->SevEsIsEnabled = ConfidentialComputingGuestHas (CCAttrAmdSevEs);
CpuMpData->SevSnpIsEnabled = ConfidentialComputingGuestHas (CCAttrAmdSevSnp);
CpuMpData->SevEsAPBuffer = (UINTN)-1;
CpuMpData->GhcbBase = PcdGet64 (PcdGhcbBase);
CpuMpData->GhcbBase = mPlatformInfoHob->GhcbBase;
CpuMpData->UseSevEsAPMethod = CpuMpData->SevEsIsEnabled && !CpuMpData->SevSnpIsEnabled;
if (CpuMpData->SevSnpIsEnabled) {
@ -3117,7 +3127,7 @@ ConfidentialComputingGuestHas (
//
// Get the current CC attribute.
//
CurrentAttr = PcdGet64 (PcdConfidentialComputingGuestAttr);
CurrentAttr = mPlatformInfoHob->PcdConfidentialComputingGuestAttr;
//
// If attr is for the AMD group then call AMD specific checks.

View File

@ -39,8 +39,9 @@
MpHandOff.h
[Packages]
MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
MdeModulePkg/MdeModulePkg.dec
OvmfPkg/OvmfPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
@ -56,8 +57,6 @@
MicrocodeLib
[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOMETIMES_CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES
@ -67,8 +66,6 @@
gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase ## SOMETIMES_CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdFirstTimeWakeUpAPsBySipi ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr ## CONSUMES
[Ppis]
gEdkiiPeiShadowMicrocodePpiGuid ## SOMETIMES_CONSUMES
@ -76,3 +73,4 @@
[Guids]
gEdkiiS3SmmInitDoneGuid
gEdkiiMicrocodePatchHobGuid
gUefiOvmfPkgPlatformInfoGuid ## CONSUMES ## HOB

View File

@ -64,6 +64,10 @@
## @libraryclass Provides functions for manipulating smram savestate registers.
MmSaveStateLib|Include/Library/MmSaveStateLib.h
## @libraryclass Installs CPU Architecture Protocol.
##
CpuArchLib|Include/Library/CpuArchLib.h
[LibraryClasses.RISCV64]
## @libraryclass Provides functions to manage MMU features on RISCV64 CPUs.
##

View File

@ -68,6 +68,7 @@
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
CpuArchLib|UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
[LibraryClasses.common.SEC]
PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
@ -129,7 +130,6 @@
CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
[Components.IA32, Components.X64]
UefiCpuPkg/CpuDxe/CpuDxe.inf
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf {
<LibraryClasses>
NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
@ -144,6 +144,8 @@
UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
@ -161,7 +163,6 @@
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
UefiCpuPkg/SecCore/SecCore.inf

View File

@ -342,6 +342,8 @@
!if $(PERFORMANCE_MEASUREMENT_ENABLE)
PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
!endif
CpuArchLib|UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf
MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
[LibraryClasses.common.DXE_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@ -646,6 +648,9 @@
SerialPortLib|UefiPayloadPkg/Library/BaseSerialPortLibHob/DxeBaseSerialPortLibHob.inf
!endif
NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
DxeServicesTableLib|MdeModulePkg/Library/DxeCoreDxeServicesTableLib/DxeCoreDxeServicesTableLib.inf
UefiBootServicesTableLib|MdeModulePkg/Library/DxeCoreUefiBootServicesTableLib/DxeCoreUefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdeModulePkg/Library/DxeCoreUefiRuntimeServicesTableLib/DxeCoreUefiRuntimeServicesTableLib.inf
}
#
@ -654,7 +659,6 @@
!if $(SECURITY_STUB_ENABLE) == TRUE
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
!endif
UefiCpuPkg/CpuDxe/CpuDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
!if $(BOOTSPLASH_IMAGE)
MdeModulePkg/Logo/LogoDxe.inf

View File

@ -159,7 +159,6 @@ INF CryptoPkg/Driver/CryptoDxe.inf
!if $(SECURITY_STUB_ENABLE) == TRUE
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
!endif
INF UefiCpuPkg/CpuDxe/CpuDxe.inf
INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
INF MdeModulePkg/Universal/Metronome/Metronome.inf