audk/UefiCpuPkg/Library/CpuArchLib/CpuArchLib.inf

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
2.9 KiB
INI
Raw Normal View History

## @file
# 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>
# Copyright (c) 2024, Loongson Technology Corporation Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = CpuArchLib
MODULE_UNI_FILE = CpuArchLib.uni
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
OvmfPkg/OvmfPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses.common]
BaseLib
BaseMemoryLib
CpuExceptionHandlerLib
CpuLib
DebugLib
DxeServicesTableLib
HobLib
MemoryAllocationLib
MpInitLib
ReportStatusCodeLib
SerialPortLib
TimerLib
UefiBootServicesTableLib
UefiLib
[LibraryClasses.IA32, LibraryClasses.X64]
LocalApicLib
MtrrLib
[LibraryClasses.LoongArch64]
CacheMaintenanceLib
CpuMmuLib
[Sources.IA32, Sources.X64]
CpuDxe.c
CpuDxe.h
CpuGdt.c
CpuGdt.h
CpuMp.c
CpuMp.h
CpuPageTable.h
CpuPageTable.c
[Sources.IA32]
Ia32/CpuAsm.nasm
Ia32/PagingAttribute.c
[Sources.X64]
X64/CpuAsm.nasm
X64/PagingAttribute.c
[Sources.LoongArch64]
CpuMp.h
LoongArch64/CpuDxe.c
LoongArch64/CpuMp.c
LoongArch64/Exception.c
LoongArch64/CpuDxe.h
[Protocols]
gEfiCpuArchProtocolGuid ## PRODUCES
gEfiMpServiceProtocolGuid ## PRODUCES
UefiCpuPkg/CpuDxe: allow accessing (DXE) page table in SMM mode The MdePkg/Library/SmmMemoryAllocationLib, used only by DXE_SMM_DRIVER, allows to free memory allocated in DXE (before EndOfDxe). This is done by checking the memory range and calling gBS services to do real operation if the memory to free is out of SMRAM. If some memory related features, like Heap Guard, are enabled, gBS interface will turn to EFI_CPU_ARCH_PROTOCOL.SetMemoryAttributes(), provided by DXE driver UefiCpuPkg/CpuDxe, to change memory paging attributes. This means we have part of DXE code running in SMM mode in certain circumstances. Because page table in SMM mode is different from DXE mode and CpuDxe always uses current registers (CR0, CR3, etc.) to get memory paging attributes, it cannot get the correct attributes of DXE memory in SMM mode from SMM page table. This will cause incorrect memory manipulations, like fail the releasing of Guard pages if Heap Guard is enabled. The solution in this patch is to store the DXE page table information (e.g. value of CR0, CR3 registers, etc.) in a global variable of CpuDxe driver. If CpuDxe detects it's in SMM mode, it will use this global variable to access page table instead of current processor registers. This can avoid retrieving wrong DXE memory paging attributes and changing SMM page table attributes unexpectedly. Cc: Eric Dong <eric.dong@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
2018-06-14 03:51:34 +02:00
gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
gIdleLoopEventGuid ## CONSUMES ## Event
gEfiVectorHandoffTableGuid ## SOMETIMES_CONSUMES ## SystemTable
gUefiOvmfPkgPlatformInfoGuid ## CONSUMES ## HOB
[Ppis]
gEfiSecPlatformInformation2PpiGuid ## UNDEFINED # HOB
gEfiSecPlatformInformationPpiGuid ## UNDEFINED # HOB
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize ## CONSUMES
[Pcd.LoongArch64]
gUefiCpuPkgTokenSpaceGuid.PcdLoongArchExceptionVectorBaseAddress ## CONSUMES
[Depex]
TRUE
[UserExtensions.TianoCore."ExtraFiles"]
CpuDxeExtra.uni