summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
AgeCommit message (Collapse)Author
2017-04-13MdeModulePkg/Dxe/Image: Restore mCurrentImage on all pathsHao Wu
This commit makes sure that in function CoreStartImage(), module variable 'mCurrentImage' is restored to the current start image context on all code paths. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> (cherry picked from commit 7a14d54f6c50a1ff73351e4aaee8570ec5f8a476)
2017-04-06MdeModulePkg: Remove unsupported PcdExpression usage in module INFLiming Gao
https://bugzilla.tianocore.org/show_bug.cgi?id=442 PcdExpression used in INF to control PCD and Source is unsupported feature. Current sample usage in module INF brings confuse. Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-03-31MdeModulePkg/SmmCore: Fix memory leak on Profile unregistered.Jiewen Yao
Issue reported at bugzillar 445. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com>
2017-03-29MdeModulePkg/PeiCore: avoid EFI_IMAGE_MACHINE_TYPE_SUPPORTED to check archArd Biesheuvel
The EFI_IMAGE_MACHINE_TYPE_SUPPORTED() macro is abused in the PeiCore code to decide whether the system we are compiling for can deal with executable code being copied elsewhere and executed from there. As stated in the comment, this is fundamentally a property of the compiler target, and so this should be made dependent on MDE_CPU_xxx preprocessor defines, and not on whether or not the runtime target can deal with PE/COFF images of a certain machine type. On X86/IA32, this mostly boils down to the same thing, but not on other architectures, so let's clean this up. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-03-29MdeModulePkg/DxeCore: add missing id-to-string mapping for AARCH64Ard Biesheuvel
Add a mapping for EFI_IMAGE_MACHINE_AARCH64 to mMachineTypeInfo[] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-03-28MdeModulePkg/MemoryProtection: Fix coding style issueDandan Bi
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-03-21MdeModulePkg/MemoryProtection: split protect and unprotect pathsArd Biesheuvel
Currently, the PE/COFF image memory protection code uses the same code paths for protecting and unprotecting an image. This is strange, since unprotecting an image involves a single call into the CPU arch protocol to clear the permission attributes of the entire range, and there is no need to parse the PE/COFF headers again. So let's store the ImageRecord entries in a linked list, so we can find it again at unprotect time, and simply clear the permissions. Note that this fixes a DEBUG hang on an ASSERT() that occurs when the PE/COFF image fails to load, which causes UnprotectUefiImage() to be invoked before the image is fully loaded. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-03-20MdeModulePkg/Core/Dxe: downgrade "CodeSegmentCount is 0" msg to DEBUG_WARNLaszlo Ersek
UEFI executables that consist of a single read+write+exec PE/COFF section trigger this message, but such a binary layout isn't actually an error. The image can be launched alright, only image protection cannot be applied to it fully. One example that elicits the message is (some) Linux kernels (with the EFI stub of course). Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Feng Tian <feng.tian@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-03-17MdeModulePkg/DxeCore: deal with allocations spanning several memmap entriesArd Biesheuvel
When attempting to perform page allocations using AllocateAddress, we fail to check whether the entire region is free before splitting the region. This may lead to memory being leaked further into the routine, when it turns out that one of the memory map entries intersected by the region is already occupied. In this case, prior conversions are not rolled back. For instance, starting from this situation 0x000040000000-0x00004007ffff [ConventionalMemory ] 0x000040080000-0x00004009ffff [Boot Data ] 0x0000400a0000-0x000047ffffff [ConventionalMemory ] a failed EfiLoaderData allocation @ 0x40000000 that covers the BootData region will fail, but leave the first part of the allocation converted, so we end up with 0x000040000000-0x00004007ffff [Loader Data ] 0x000040080000-0x00004009ffff [Boot Data ] 0x0000400a0000-0x000047ffffff [ConventionalMemory ] even though the AllocatePages() call returned an error. So let's check beforehand that AllocateAddress allocations are covered by a single memory map entry, so that it either succeeds or fails completely, rather than leaking allocations. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-03-15MdeModulePkg DxeCore: Remove unreferenced symbol for memory profileStar Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=370 Use GLOBAL_REMOVE_IF_UNREFERENCED for some memory profile global variables, then their symbols could be removed when memory profile is disabled. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-03-15MdeModulePkg PiSmmCore: Remove unreferenced symbol for SMRAM profileStar Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=370 Use GLOBAL_REMOVE_IF_UNREFERENCED for some SMRAM profile global variables, then their symbols could be removed when SMRAM profile is disabled. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-03-13MdeModulePkg/SmmCore: Add Context in SmiHandlerProfileUnregister.Jiewen Yao
The reason is that we observe that a platform may use same Handler for different context. In order to support Unregister such handler, we have to input context information as well. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-03-07MdeModulePkg/DxeCore: Fix coding style issuesBi, Dandan
Add comments for functions. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-03-06MdeModulePkg/PeiCore: honour minimal runtime allocation granularityArd Biesheuvel
Architectures such as AArch64 may run the OS with 16 KB or 64 KB sized pages, and for this reason, the UEFI spec mandates a minimal allocation granularity of 64 KB for regions that may require different memory attributes at OS runtime. So make PeiCore's implementation of AllocatePages () take this into account as well. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-03-06MdeModulePkg/PiSmmCore: switch to MdePkg allocation granularity macrosArd Biesheuvel
Remove the local definitions for the default and runtime page allocation granularity macros, and switch to the new MdePkg versions. Note that this replaces a reference to the 'default' version with the more correct 'runtime' version, but this matters little in practice. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-03-06MdeModulePkg/DxeCore: switch to MdePkg allocation granularity macrosArd Biesheuvel
Remove the local definitions for the default and runtime page allocation granularity macros, and switch to the new MdePkg versions. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-03-06MdeModulePkg: Refine casting expression result to bigger sizeHao Wu
There are cases that the operands of an expression are all with rank less than UINT64/INT64 and the result of the expression is explicitly cast to UINT64/INT64 to fit the target size. An example will be: UINT32 a,b; // a and b can be any unsigned int type with rank less than UINT64, like // UINT8, UINT16, etc. UINT64 c; c = (UINT64) (a + b); Some static code checkers may warn that the expression result might overflow within the rank of "int" (integer promotions) and the result is then cast to a bigger size. The commit refines codes by the following rules: 1). When the expression is possible to overflow the range of unsigned int/ int: c = (UINT64)a + b; 2). When the expression will not overflow within the rank of "int", remove the explicit type casts: c = a + b; 3). When the expression will be cast to pointer of possible greater size: UINT32 a,b; VOID *c; c = (VOID *)(UINTN)(a + b); --> c = (VOID *)((UINTN)a + b); 4). When one side of a comparison expression contains only operands with rank less than UINT32: UINT8 a; UINT16 b; UINTN c; if ((UINTN)(a + b) > c) {...} --> if (((UINT32)a + b) > c) {...} For rule 4), if we remove the 'UINTN' type cast like: if (a + b > c) {...} The VS compiler will complain with warning C4018 (signed/unsigned mismatch, level 3 warning) due to promoting 'a + b' to type 'int'. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-03-01MdeModulePkg: use LShiftU64() instead of "<<" to avoid IA32 build error.Fu Siyuan
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-03-01MdeModulePkg/Core/DxeIplPeim: Add support for PCD ↵Leo Duran
PcdPteMemoryEncryptionAddressOrMask This PCD holds the address mask for page table entries when memory encryption is enabled on AMD processors supporting the Secure Encrypted Virtualization (SEV) feature. The mask is applied when creating page tables. Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leo Duran <leo.duran@amd.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-02-28MdeModulePkg/DxeCore: implement memory protection policyArd Biesheuvel
This implements a DXE memory protection policy that ensures that regions that don't require executable permissions are mapped with the non-exec attribute set. First of all, it iterates over all entries in the UEFI memory map, and removes executable permissions according to the configured DXE memory protection policy, as recorded in PcdDxeNxMemoryProtectionPolicy. Secondly, it sets or clears the non-executable attribute when allocating or freeing pages, both for page based or pool based allocations. Note that this complements the image protection facility, which applies strict permissions to BootServicesCode/RuntimeServicesCode regions when the section alignment allows it. The memory protection configured by this patch operates on non-code regions only. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-02-28MdeModulePkg/DxeCore: use separate lock for pool allocationsArd Biesheuvel
In preparation of adding memory permission attribute management to the pool allocator, split off the locking of the pool metadata into a separate lock. This is an improvement in itself, given that pool allocations can only interfere with the page allocation bookkeeping if pool pages are allocated or released. But it is also required to ensure that the permission attribute management does not deadlock, given that it may trigger page table splits leading to additional page tables being allocated. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-02-28MdeModulePkg/PeiCore: allocate BootServicesCode memory for PE/COFF imagesArd Biesheuvel
Ensure that any memory allocated for PE/COFF images is identifiable as a boot services code region, so that we know it requires its executable permissions to be preserved when we tighten mapping permissions later on. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-02-26MdeModulePkg/DxeCore: base code protection on permission attributesArd Biesheuvel
Instead of assuming that a PE/COFF section of type EFI_IMAGE_SCN_CNT_CODE can always be mapped read-only, classify a section as a code section only if it has the executable attribute set and the writable attribute cleared. This adheres more closely to the PE/COFF spec, and avoids issues with Linux OS loaders that may consist of a single read/write/execute section. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-02-22MdeModulePkg/PiSmmCore: Add SmiHandlerProfile support.Jiewen Yao
1) SmmCore maintains the root SMI handler and NULL SMI handler database. 2) SmmCore consumes PcdSmiHandlerProfilePropertyMask to decide if SmmCore need support SMI handler profile. If SMI handler profile is supported, the SmmCore installs SMI handler profile protocol and SMI handler profile communication handler. 3) SMI handler profile protocol will record the hardware SMI handler profile registered by SmmChildDispatcher. 4) SMI handler profile communication handler will return all SMI handler profile info (NULL SMI handler, GUID SMI handler, and hardware SMI handler) Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-02-22MdeModulePkg/DxeCore: Add UEFI image protection.Jiewen Yao
If the UEFI image is page aligned, the image code section is set to read only and the image data section is set to non-executable. 1) This policy is applied for all UEFI image including boot service driver, runtime driver or application. 2) This policy is applied only if the UEFI image meets the page alignment requirement. 3) This policy is applied only if the Source UEFI image matches the PcdImageProtectionPolicy definition. 4) This policy is not applied to the non-PE image region. The DxeCore calls CpuArchProtocol->SetMemoryAttributes() to protect the image. If the CpuArch protocol is not installed yet, the DxeCore enqueues the protection request. Once the CpuArch is installed, the DxeCore dequeues the protection request and applies policy. Once the image is unloaded, the protection is removed automatically. The UEFI runtime image protection is teared down at ExitBootServices(), the runtime image code relocation need write code segment at SetVirtualAddressMap(). We cannot assume OS/Loader has taken over page table at that time. NOTE: It is per-requisite that code section and data section should not be not merged. That is same criteria for SMM/runtime driver. We are not able to detect during BIOS boot, because we can only get LINK warning below: "LINK : warning LNK4254: section '.data' (C0000040) merged into '.text' (60000020) with different attributes" But final attribute in PE code section is same. Cc: Star Zeng <star.zeng@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2017-02-10MdeModulePkg PiSmmIpl: Update SmmCommunication comments to match code logicLiming Gao
Cc: Star Zeng <star.zeng@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-02-10MdeModulePkg PeiCore: Don't cache GUIDED section with AUTH_NOT_TESTEDLiming Gao
If GUIDED section authentication has EFI_AUTH_STATUS_NOT_TESTED, its matched extraction ppi may not be installed. So, don't cache its data. Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-02-10MdeModulePkg PeiCore: Reset PeimNeedingDispatch when its security violationLiming Gao
When PEIM is security violation, its matched extraction ppi may not be installed. So, its PeimNeedingDispatch will still reset to TRUE. Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-02-08MdeModulePkg: Fix some typos of "according"Liming Gao
Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Rebecca Cran <rebecca@bluestop.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> Reviewed-by: He Junjie <junjie.he@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2017-01-20MdeModulePkg: Use EfiEventEmptyFunction from UefiLibStar Zeng
Use EfiEventEmptyFunction from UefiLib and remove the duplication of event empty function. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=298 Cc: Feng Tian <feng.tian@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-01-12MdeModulePkg/Stall: Refine to compare 2 values with the same typeHao Wu
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-01-12MdeModulePkg/DxeCore:Clear RT attribute on SetCapabilities.Jiewen Yao
When gDS->SetMemorySpaceCapabilities() is called, current DXE core will sync all GCD attributes to memory map attributes, including RUNTIME attributes. It is wrong, because RUNTIME attributes should be set for runtime memory only. This fix clears the RUNTIME attributes before convert to UEFI memory map. So that the UEFI memory map is good after gDS->SetMemorySpaceCapabilities() is called. Cc: Star Zeng <star.zeng@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-01-10MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messagesMichael Kinney
If a BaseAddress of NULL is passed into DXE Core services CoreAllocateIoSpace() or CoreAllocateMemorySpace(), and DEBUG() messages are enabled, then a NULL pointer reference is made. The parameter check for BaseAddress is performed in the function CoreAllocateSpace() after the DEBUG() messages. A check is added in the DEBUG() messages to prevent the NULL pointer reference. This issue was found with PI SCTs with DEBUG messages enabled in the DXE Core. Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Feng Tian <feng.tian@Intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-12-14MdeModulePkg: Make the comments align with the functionDandan Bi
Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2016-12-12MdeModulePkg PiSmmCore: Retrieve Smram base address from system tableLiming Gao
PiSmmIpl records LoadModuleAtFixAddressSmramBase in LMFAConfigurationTable. Update PiSmmCore to directly get the address from this system table. Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2016-12-12MdeModulePkg SmmIpl: Fill Smram range for SMM driver when LMFA enableLiming Gao
Allocate the additional Smram range to describe the reserved smram for SMM core and driver when LMFA feature is enabled. Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2016-12-12MdeModulePkg PiSmmCore: Update FreePages to handle zero address and pagesLiming Gao
https://bugzilla.tianocore.org/show_bug.cgi?id=278 Zero memory address or zero number pages are invalid to SmmFreePages(). Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2016-12-07MdeModulePkg/PiSmmCore: use EfiPagesToSize to prevent build error.Jiewen Yao
EFI_PAGES_TO_SIZE only handles UINTN, so we use EfiPagesToSize to handle UINT64. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
2016-12-07MdeModulePkg/PiSmmCore; Use DEBUG_WARN for non 4k aligned image.Jiewen Yao
Cc: Jeff Fan <jeff.fan@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
2016-12-07MdeModulePkg/PiSmmCore: MemoryAttributeTable need keep non-PE record.Jiewen Yao
Current memory attribute table implementation will only mark PE code to be EfiRuntimeServicesCode, and mark rest to be EfiRuntimeServicesData. However, there might be a case that a SMM code wants to allocate EfiRuntimeServicesCode explicitly to let page table protect this region to be read only. It is unsupported. This patch enhances the current solution so that MemoryAttributeTable does not touch non PE image record. Only the PE image region is forced to be EfiRuntimeServicesCode for code and EfiRuntimeServicesData for data. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
2016-12-07MdeModulePkg/PiSmmCore: AllocatePool should use MemoryType.Jiewen Yao
PiSmmCore supports page level protection based upon the Memory Type (EfiRuntimeServicesCode/EfiRuntimeServicesData) and PE image. However, the Memory Type information is ignored in AllocatePool(). If a caller calls AllocatePool with EfiRuntimeServicesCode, the final memory is still allocated as EfiRuntimeServicesData. This patch supports AllocatePool with EfiRuntimeServicesCode. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
2016-12-05MdeModulePkg PiSmmCore: Update comments in InitializeMemoryServicesLiming Gao
Add the comments to describe Free and Allocated SMRAM are added separately. Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2016-11-29MdeModulePkg PeiCore: Make SetPeiServicesTablePointer() early in EntryPointLiming Gao
Make SetPeiServicesTablePointer() earlier than ProcessLibraryConstructorList() so the constructor() function can get the correct pei service table pointer. https://bugzilla.tianocore.org/show_bug.cgi?id=238 Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2016-11-22MdeModulePkg/PiSmmCore: Cache CommunicationBuffer info before using itJeff Fan
gSmmCorePrivate->CommunicationBuffer and gSmmCorePrivate->BufferSize locate at runtime memory region. That means they could be modified by non-SMM code during runtime. We should cache them into SMM local variables before we verify them. After verification, we should use the cached ones directly instead of the ones in gSmmCorePrivate. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com>
2016-11-17MdeModulePkg/PiSmmCore: Add MemoryAttributes support.Jiewen Yao
The SMM memory attribute table concept is similar to UEFI memory attribute table. The new file MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c and the new code in MdeModulePkg/Core/PiSmmCore/Page.c are based on the algorithms and implementation from MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c and MdeModulePkg/Core/Dxe/Mem/Page.c. These new components are based on the Memory Attributes Table feature from the UEFI Specification and the existing DXE Core implementation that supports that feature. This SMM MemoryAttributes table is produced at SmmEndOfDxe event. So that the consumer (PiSmmCpu) may consult this table to set memory attribute in page table. This patch also installs LoadedImage protocol to SMM protocol database, so that the SMM image info can be got easily to construct the PiSmmMemoryAttributes table. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2016-11-17MdeModulePkg DxeCore: Show error message on unaligned FvImage issueStar Zeng
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=205 Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2016-11-09MdeModulePkg/DxeIplPeim: UINTN used wrongly for EFI_PHYSICAL_ADDRESSJeff Fan
PeiServicesAllocatePages () will output sizeof (EFI_PHYSICAL_ADDRESS) value. IdtTableForX64 is sizeof (UINTN) local variable. It will overwrite other local variable. This issue is found when we dump BaseOfStack value. Cc: Feng Tian <feng.tian@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-11-09MdeModulePkg: Display new stack base and sizeJeff Fan
Dump new stack base and size information could help developer to narrow down stack crash issue. Cc: Feng Tian <feng.tian@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-10-27MdeModulePkg PeiCore: Make sure FvInfo has FFS2 format if Ffs2Guid FvFormatStar Zeng
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=160 Cc: Liming Gao <liming.gao@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-10-27MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()Laszlo Ersek
Cc: Feng Tian <feng.tian@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Feng Tian <feng.tian@Intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>