2010-02-24 00:58:38 +01:00
|
|
|
## @file
|
2016-07-22 04:42:47 +02:00
|
|
|
# CPU driver installs CPU Architecture Protocol and CPU MP protocol.
|
2009-05-27 23:09:47 +02:00
|
|
|
#
|
2019-09-12 07:22:18 +02:00
|
|
|
# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.<BR>
|
2017-03-03 00:36:03 +01:00
|
|
|
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
|
|
|
|
#
|
2019-04-04 01:07:22 +02:00
|
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
2009-05-27 23:09:47 +02:00
|
|
|
#
|
2010-02-24 00:58:38 +01:00
|
|
|
##
|
2009-05-27 23:09:47 +02:00
|
|
|
|
|
|
|
[Defines]
|
|
|
|
INF_VERSION = 0x00010005
|
|
|
|
BASE_NAME = CpuDxe
|
2014-08-28 07:09:12 +02:00
|
|
|
MODULE_UNI_FILE = CpuDxe.uni
|
2010-04-06 04:56:49 +02:00
|
|
|
FILE_GUID = 1A1E4886-9517-440e-9FDE-3BE44CEE2136
|
2009-05-27 23:09:47 +02:00
|
|
|
MODULE_TYPE = DXE_DRIVER
|
|
|
|
VERSION_STRING = 1.0
|
|
|
|
ENTRY_POINT = InitializeCpu
|
|
|
|
|
|
|
|
[Packages]
|
|
|
|
MdePkg/MdePkg.dec
|
2011-06-17 01:28:16 +02:00
|
|
|
MdeModulePkg/MdeModulePkg.dec
|
2009-05-27 23:09:47 +02:00
|
|
|
UefiCpuPkg/UefiCpuPkg.dec
|
|
|
|
|
|
|
|
[LibraryClasses]
|
|
|
|
BaseLib
|
|
|
|
BaseMemoryLib
|
|
|
|
CpuLib
|
|
|
|
DebugLib
|
|
|
|
DxeServicesTableLib
|
|
|
|
MemoryAllocationLib
|
|
|
|
MtrrLib
|
|
|
|
UefiBootServicesTableLib
|
|
|
|
UefiDriverEntryPoint
|
2012-05-18 22:29:14 +02:00
|
|
|
LocalApicLib
|
2012-07-06 07:49:53 +02:00
|
|
|
UefiCpuLib
|
2013-11-22 07:24:41 +01:00
|
|
|
UefiLib
|
|
|
|
CpuExceptionHandlerLib
|
2015-06-16 04:55:54 +02:00
|
|
|
HobLib
|
|
|
|
ReportStatusCodeLib
|
2016-07-22 04:42:47 +02:00
|
|
|
MpInitLib
|
2017-02-20 09:17:05 +01:00
|
|
|
TimerLib
|
2018-08-20 05:31:00 +02:00
|
|
|
PeCoffGetEntryPointLib
|
2009-05-27 23:09:47 +02:00
|
|
|
|
|
|
|
[Sources]
|
|
|
|
CpuDxe.c
|
|
|
|
CpuDxe.h
|
|
|
|
CpuGdt.c
|
2014-11-13 19:25:29 +01:00
|
|
|
CpuGdt.h
|
2014-11-13 19:24:25 +01:00
|
|
|
CpuMp.c
|
|
|
|
CpuMp.h
|
2017-01-14 08:40:20 +01:00
|
|
|
CpuPageTable.h
|
|
|
|
CpuPageTable.c
|
2009-05-27 23:09:47 +02:00
|
|
|
|
|
|
|
[Sources.IA32]
|
2016-06-14 09:43:44 +02:00
|
|
|
Ia32/CpuAsm.nasm
|
2019-09-12 07:22:18 +02:00
|
|
|
Ia32/PagingAttribute.c
|
2009-05-27 23:09:47 +02:00
|
|
|
|
|
|
|
[Sources.X64]
|
2016-06-14 09:43:44 +02:00
|
|
|
X64/CpuAsm.nasm
|
2019-09-12 07:22:18 +02:00
|
|
|
X64/PagingAttribute.c
|
2009-05-27 23:09:47 +02:00
|
|
|
|
|
|
|
[Protocols]
|
2014-08-28 07:09:12 +02:00
|
|
|
gEfiCpuArchProtocolGuid ## PRODUCES
|
2016-07-22 04:42:47 +02:00
|
|
|
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
|
2009-05-27 23:09:47 +02:00
|
|
|
|
2011-06-17 01:28:16 +02:00
|
|
|
[Guids]
|
2014-08-28 07:09:12 +02:00
|
|
|
gIdleLoopEventGuid ## CONSUMES ## Event
|
|
|
|
gEfiVectorHandoffTableGuid ## SOMETIMES_CONSUMES ## SystemTable
|
2011-06-17 01:28:16 +02:00
|
|
|
|
2015-06-16 04:55:54 +02:00
|
|
|
[Ppis]
|
|
|
|
gEfiSecPlatformInformation2PpiGuid ## UNDEFINED # HOB
|
|
|
|
gEfiSecPlatformInformationPpiGuid ## UNDEFINED # HOB
|
|
|
|
|
2017-03-03 00:36:03 +01:00
|
|
|
[Pcd]
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
|
2017-12-07 13:17:05 +01:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
|
2018-08-20 05:31:00 +02:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
|
2017-12-07 13:17:05 +01:00
|
|
|
gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList ## CONSUMES
|
|
|
|
gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize ## CONSUMES
|
2021-10-21 10:49:12 +02:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask ## CONSUMES
|
2017-03-03 00:36:03 +01:00
|
|
|
|
2009-05-27 23:09:47 +02:00
|
|
|
[Depex]
|
|
|
|
TRUE
|
|
|
|
|
2014-08-28 07:09:12 +02:00
|
|
|
[UserExtensions.TianoCore."ExtraFiles"]
|
|
|
|
CpuDxeExtra.uni
|