]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
3 years agoUefiCpuPkg/PiSmmCpuDxeSmm: Fix SMM stack offset is not correct edk2-stable202102
Sheng Wei [Fri, 26 Feb 2021 04:00:34 +0000 (12:00 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm: Fix SMM stack offset is not correct

In function InitGdt(), SmiPFHandler() and Gen4GPageTable(), it uses
 CpuIndex * mSmmStackSize to get the SMM stack address offset for
 multi processor. It misses the SMM Shadow Stack Size. Each processor
 will use mSmmStackSize + mSmmShadowStackSize in the memory.
It should use CpuIndex * (mSmmStackSize + mSmmShadowStackSize) to get
 this SMM stack address offset. If mSmmShadowStackSize > 0 and multi
 processor enabled, it will get the wrong offset value.
CET shadow stack feature will set the value of mSmmShadowStackSize.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3237

Signed-off-by: Sheng Wei <w.sheng@intel.com>
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: Jiewen Yao <jiewen.yao@intel.com>
Cc: Roger Feng <roger.feng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoUefiCpuPkg/CpuExceptionHandlerLib: Clear CET shadow stack token busy bit
Sheng Wei [Tue, 26 Jan 2021 09:00:58 +0000 (17:00 +0800)]
UefiCpuPkg/CpuExceptionHandlerLib: Clear CET shadow stack token busy bit

If CET shadows stack feature enabled in SMM and stack switch is enabled.
When code execute from SMM handler to SMM exception, CPU will check SMM
exception shadow stack token busy bit if it is cleared or not.
If it is set, it will trigger #DF exception.
If it is not set, CPU will set the busy bit when enter SMM exception.
So, the busy bit should be cleared when return back form SMM exception to
SMM handler. Otherwise, keeping busy bit 1 will cause to trigger #DF
exception when enter SMM exception next time.
So, we use instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP to clear the
shadow stack token busy bit before RETF instruction in SMM exception.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192

Signed-off-by: Sheng Wei <w.sheng@intel.com>
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: Jiewen Yao <jiewen.yao@intel.com>
Cc: Roger Feng <roger.feng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoMdePkg/Include: Add CET instructions to Nasm.inc
Sheng Wei [Tue, 26 Jan 2021 08:54:15 +0000 (16:54 +0800)]
MdePkg/Include: Add CET instructions to Nasm.inc

This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in Nasm.
The open CI is using NASM 2.14.02.
CET instructions are supported since NASM 2.15.01.

DB-encoded CET instructions need to be removed after open CI update to
 NASM 2.15.01.
The BZ ticket is https://bugzilla.tianocore.org/show_bug.cgi?id=3227 .

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192

Signed-off-by: Sheng Wei <w.sheng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoArmPkg/ArmGicLib: Fix GICR_IPRIORITYR address wrong issue
Ming Huang [Thu, 25 Feb 2021 03:32:12 +0000 (11:32 +0800)]
ArmPkg/ArmGicLib: Fix GICR_IPRIORITYR address wrong issue

The register address of GICR_IPRIORITYR is in SGI_base frame. Add
IPRIORITY_ADDRESS macro for getting GICR_IPRIORITYR address. Otherwise
GIC RAS error(Uncorrected software error) may report in ArmGicDxe.

This resolves BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3236

Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Tested-by: Ard Biesheuvel <ardb@kernel.org> # QEMU/kvm guest on ThunderX2
Tested-by: Quan Nguyen <quan@os.amperecomputing.com>
3 years agoArmPkg/ArmGicLib: Fix two macros issue for offset parameter
Ming Huang [Thu, 25 Feb 2021 03:32:11 +0000 (11:32 +0800)]
ArmPkg/ArmGicLib: Fix two macros issue for offset parameter

Modify two macros to put "offset" in parentheses and remove
parentheses from "4 * offset".

Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Fix uninitialised variable in ArmMmuStandaloneMmLib
Sami Mujawar [Thu, 25 Feb 2021 17:11:10 +0000 (17:11 +0000)]
ArmPkg: Fix uninitialised variable in ArmMmuStandaloneMmLib

The following patches added support for StandaloneMM using FF-A:
9da5ee116a28 ArmPkg: Allow FF-A calls to set memory region's attributes
0e43e02b9bd8 ArmPkg: Allow FF-A calls to get memory region's attributes

However, in the error handling logic for the Get/Set Memory attributes,
the CLANG compiler reports that a status variable could be used without
initialisation. This issue is a false positive and is not seen with GCC.

The Get/Set Memory attributes operation is atomic and therefore an
FFA_INTERRUPT or FFA_SUCCESS response is not expected in response
to FFA_MSG_SEND_DIRECT_REQ. So the remaining cases that could occur
are:
 - the target sends FFA_MSG_SEND_DIRECT_RESP with a success or
   failure code.
 or
 - FFA_MSG_SEND_DIRECT_REQ transmission failure.

Therefore,
 - reorder the error handling conditions such that it prevents the
   uninitialised variable issue being flagged by CLANG.
 - move the repetitive code to a static helper function and add
   documentation at the appropriate places.
 - fix error handling in functions that invoke GetMemoryPermissions().

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sughosh Ganu <sughosh.ganu@linaro.org>
3 years agoStandaloneMmPkg: Remove StandaloneMmDriverEntryPoint.h
Michael Kubacki [Thu, 25 Feb 2021 03:33:12 +0000 (19:33 -0800)]
StandaloneMmPkg: Remove StandaloneMmDriverEntryPoint.h

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3235

The library for this header initially resided in StandaloneMmPkg
but moved to MdePkg and now this file is a duplicate of the header
file in MdePkg.

This change removes the header file from StandaloneMmPkg. More
details regarding the history of the library transitioning from
StandaloneMmPkg to MdePkg are below.

The following commit removed the library from StandaloneMmPkg:
  d6253d2f9a33 ("StandaloneMmPkg: remove redundant
  StandaloneMmDriverEntryPoint driver", 2019-03-11)

The following commits added the library class & instance to MdePkg:
  7df4764e6a81a ("MdePkg: introduce standalone MM entry point
  library class", 2019-01-14)

  5866d4992396 ("MdePkg: introduce standalone MM entry point
  library implementation", 2019-01-14)

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
3 years agoUefiCpuPkg/MpInitLib: Use XADD to avoid lock acquire/release
Ray Ni [Thu, 28 Jan 2021 03:42:43 +0000 (11:42 +0800)]
UefiCpuPkg/MpInitLib: Use XADD to avoid lock acquire/release

When AP firstly wakes up, MpFuncs.nasm contains below logic to assign
an unique ApIndex to each AP according to who comes first:
---ASM---
TestLock:
    xchg       [edi], eax
    cmp        eax, NotVacantFlag
    jz         TestLock

    mov        ecx, esi
    add        ecx, ApIndexLocation
    inc        dword [ecx]
    mov        ebx, [ecx]

Releaselock:
    mov        eax, VacantFlag
    xchg       [edi], eax
---ASM END---

"lock inc" cannot be used to increase ApIndex because not only the
global ApIndex should be increased, but also the result should be
stored to a local general purpose register EBX.

This patch learns from the NASM implementation of
InternalSyncIncrement() to use "XADD" instruction which can increase
the global ApIndex and store the original ApIndex to EBX in one
instruction.

With this patch, OVMF when running in a 255 threads QEMU spends about
one second to wakeup all APs. Original implementation needs more than
10 seconds.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoBaseTools: Align include guards policy
Pierre Gondois [Tue, 16 Feb 2021 09:29:07 +0000 (17:29 +0800)]
BaseTools: Align include guards policy

The EDK II C Coding Standards Specification states that:
"Names starting with one or two underscores, such as
_MACRO_GUARD_FILE_NAME_H_, must not be used. They are
reserved for compiler implementation." [1]

The Ecc tool currently checks that the include guard end with
a trailing underscore. Thus, the check and the error message
should both be modified.

The new check forces having one sole trailing underscore
character, as the example in the specification shows:
"FILE_NAME_H_" [1]
This would allow to have more consistency.

[1] Section 5.3.5 "All include file contents must be protected
by a #include guard":
https://edk2-docs.gitbook.io/
edk-ii-c-coding-standards-specification/5_source_files/53_include_files

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <Sami.Mujawar@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
3 years agoMdeModulePkg/UefiBootManagerLib: Put BootMenu at the end of BootOrder
Li, Walon [Fri, 19 Feb 2021 09:39:32 +0000 (17:39 +0800)]
MdeModulePkg/UefiBootManagerLib: Put BootMenu at the end of BootOrder

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3135

When Boot Menu does not exist in the BootOrder, BmRegisterBootManagerMenu
will create one into list. However, it should be put at the "end" of
BootOrder instead of "start" of BootOrder. Replace 0 by -1 to adjust
order of load options.

Signed-off-by: Walon Li <walon.li@hpe.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
3 years agoRedfishPkg/RedfishContentCodingLib: EDKII Redfish En/Decode library
Abner Chang [Mon, 18 Jan 2021 02:58:25 +0000 (10:58 +0800)]
RedfishPkg/RedfishContentCodingLib: EDKII Redfish En/Decode library

BZ#:3174
Platform library to provide the encoding/decoding algorithms for
the Redfish packets.
The supported value could be one of below or any which is
platform-specific.
  - HTTP_CONTENT_ENCODING_IDENTITY "identity"
  - HTTP_CONTENT_ENCODING_GZIP     "gzip"
  - HTTP_CONTENT_ENCODING_COMPRESS "compress"
  - HTTP_CONTENT_ENCODING_DEFLATE  "deflate"
  - HTTP_CONTENT_ENCODING_BROTLI   "br"

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
3 years agoRedfishPkg/Include: EDKII Redfish Config Handler Protocol header file
Abner Chang [Thu, 14 Jan 2021 05:29:39 +0000 (13:29 +0800)]
RedfishPkg/Include: EDKII Redfish Config Handler Protocol header file

BZ:2911

This is the header file of EDKII Redfish config handler protocol,
which is used by EDKII Redfish feature driver in order to
manipulate Redfish properties based on the Redfish schema.

Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Fan Wang <fan.wang@intel.com>
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
3 years agoRedfishPkg/JsonLib: Ignore the build error of conditional expression.
Abner Chang [Fri, 29 Jan 2021 04:11:59 +0000 (12:11 +0800)]
RedfishPkg/JsonLib: Ignore the build error of conditional expression.

Ignore the build error of assignment within conditional expression.
Add build option to ignore the build error of "assignment within
conditional expression".
This build error is caused by the macros defined in open source
project jansson header file jansson.h.

- json_object_foreach
- json_object_foreach_safe
- json_array_foreach

We use build option to avoid the build errors on Visual Studio
(GCC doesn't havvve this problem) for now. Already sent an email
to jansson open source community to revise these macro as Leif's
suggestion as below,

for (key = json_object_iter_key(json_object_iter(object));    \
       key;                                                   \
       key = json_object_iter_key(                            \
            json_object_iter_next(object,
json_object_key_to_iter(key)))) { \
       value =
json_object_iter_value(json_object_key_to_iter(key));         \
      if (!value) \
        break; \
  } \

We will remove this build option once the patch is accepted and
upstreamed.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
3 years agoRedfishPkg/JsonLib: Fix the mistake of removing code by a accident
Abner Chang [Fri, 29 Jan 2021 03:54:11 +0000 (11:54 +0800)]
RedfishPkg/JsonLib: Fix the mistake of removing code by a accident

json_string_value() in JsonValueGetAsciiString () is removed by a accident
when clean up the code.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
3 years agoRedfishPkg/JsonLib: Add JsonLoadString function
Abner Chang [Fri, 29 Jan 2021 03:46:53 +0000 (11:46 +0800)]
RedfishPkg/JsonLib: Add JsonLoadString function

Add JsonLoadString function to load a NULL terminated-string JSON

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
3 years agoRedfishPkg/RedfishCrtLib: Add more CRT functions
Abner Chang [Mon, 25 Jan 2021 03:35:46 +0000 (11:35 +0800)]
RedfishPkg/RedfishCrtLib: Add more CRT functions

Add more functions which were missed in the first time commit,
that causes the build error with EDK2 Redfish feature driver.

strerror - We don't support this on edk2 environment.
strpbrk  - Cloned this function from edk2-LibC
File operation functions - Not supported on edk2 environment.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
Acked-by: Leif Lindholm <leif@nuviainc.com>
3 years agoStandaloneMmPkg: Allow sending FFA Direct Request message to StandaloneMm
Ilias Apalodimas [Fri, 19 Feb 2021 06:36:07 +0000 (12:06 +0530)]
StandaloneMmPkg: Allow sending FFA Direct Request message to StandaloneMm

Allow passing of a request to StandaloneMm Core through the Firmware
Framework(FF-A) using FFA_MSG_SEND_DIRECT_REQ method. This method is
used as a mechanism for requesting some service from StandaloneMm.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoMdeModulePkg/VariableStandaloneMm: Set PcdFlashNvStorageVariableBase to Pcd
Ilias Apalodimas [Fri, 19 Feb 2021 06:36:06 +0000 (12:06 +0530)]
MdeModulePkg/VariableStandaloneMm: Set PcdFlashNvStorageVariableBase to Pcd

Instead of running StMM in SPM, OP-TEE creates a new secure partition,
which emulates SPM and isolates StMM from the rest of the Trusted
Applications (TAs). We can then compile StMM as an FD image and run it
in OP-TEE. With the addition of a new RPMB driver, we can leverage OP-TEE
and store variables to an RPMB device.

Since EDK2 upper layers expect byte addressable code, for the RPMB to
work, we need to allocate memory and sync it with the hardware on
read/writes. Since DynamicPCDs are not supported in that context we
can only use PatchablePCDs. So let's switch them to Pcd instead of
FixedPcd and accomodate the new driver. While at it, move the rest
of the variables under Pcd section, instead of FixedPcd -- this is in
line with how the variables are defined in the other Variable
modules.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg: Allow FF-A calls to set memory region's attributes
Achin Gupta [Fri, 19 Feb 2021 06:36:05 +0000 (12:06 +0530)]
ArmPkg: Allow FF-A calls to set memory region's attributes

Allow setting memory region's permissions using either of the Firmware
Framework(FF-A) ABI transport or through the earlier used SVC calls.

Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Co-developed-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg: Allow FF-A calls to get memory region's attributes
Achin Gupta [Fri, 19 Feb 2021 06:36:04 +0000 (12:06 +0530)]
ArmPkg: Allow FF-A calls to get memory region's attributes

Allow getting memory region's permissions using either of the Firmware
Framework(FF-A) ABI transport or through the earlier used SVC calls.

Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Co-developed-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg: Use FF-A header file in Standalone MM Arm MMU library
Achin Gupta [Fri, 19 Feb 2021 06:36:03 +0000 (12:06 +0530)]
ArmPkg: Use FF-A header file in Standalone MM Arm MMU library

Add the FF-A header for invoking the mmu functions using FF-A calls as
the transport mechanism. Support for invoking the functions through
FF-A will be added in a subsequent patch.

Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoStandaloneMmPkg: Add option to use FF-A calls for communication with SPM
Achin Gupta [Fri, 19 Feb 2021 06:36:02 +0000 (12:06 +0530)]
StandaloneMmPkg: Add option to use FF-A calls for communication with SPM

Add support for reporting completion of a MM request using either the
Firmware Framework(FF-A) ABI transport or through the earlier used SVC
calls.

Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Co-developed-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoStandaloneMmPkg: Add option to use FF-A calls for getting SPM version
Sughosh Ganu [Fri, 19 Feb 2021 06:36:01 +0000 (12:06 +0530)]
StandaloneMmPkg: Add option to use FF-A calls for getting SPM version

With the introduction of Firmware Framework(FF-A), a Secure Partition
can get the SPM version either using FF-A calls or through the
existing svc calls. Use a runtime check to use either of the two
methods based on the Pcd feature flag value.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Co-developed-by: Achin Gupta <achin.gupta@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg: Add macros for SPM version with FF-A support enabled
Sughosh Ganu [Fri, 19 Feb 2021 06:36:00 +0000 (12:06 +0530)]
ArmPkg: Add macros for SPM version with FF-A support enabled

Declare the values of SPM major and minor versions as macros with FF-A
enabled, which can be used in the module for checking the SPM version
compatibility. These SPM major and minor version numbers are mandated
for having support for the Firmware Framework(FF-A) feature enabled.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoStandaloneMmPkg: Use macros for SPM version check
Sughosh Ganu [Fri, 19 Feb 2021 06:35:59 +0000 (12:05 +0530)]
StandaloneMmPkg: Use macros for SPM version check

Declare module wide variables for SPM major and minor versions to be
used in checking the SPM version compatibility. Use the SPM major and
minor version macros declared in the previous patch for the version
check.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg: Add macros for SPM version
Sughosh Ganu [Fri, 19 Feb 2021 06:35:58 +0000 (12:05 +0530)]
ArmPkg: Add macros for SPM version

Declare the values of SPM major and minor versions as macros which can
be used in the module for checking the SPM version compatibility.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg: Introduce support for PcdFfaEnable
Sughosh Ganu [Fri, 19 Feb 2021 06:35:57 +0000 (12:05 +0530)]
ArmPkg: Introduce support for PcdFfaEnable

The Secure Partition(SP) can request services from the Secure
Partition Manager Core(SPMC) either through FF-A calls or through the
existing SVC calls. Add a feature flag Pcd for enabling the FF-A
method -- when this is set to FALSE, the SP uses the existing SVC
calls for making the requests.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoStandaloneMmPkg: Use FF-A header file in Standalone MM Core entry point
Achin Gupta [Fri, 19 Feb 2021 06:35:56 +0000 (12:05 +0530)]
StandaloneMmPkg: Use FF-A header file in Standalone MM Core entry point

Add the Firmware Framework(FF-A) header in the StandaloneMm entry
point driver. Support for invoking the functions through FF-A will be
added in a subsequent patch.

Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg/ArmSvcLib: Return x4-x7 in output parameters
Achin Gupta [Fri, 19 Feb 2021 06:35:55 +0000 (12:05 +0530)]
ArmPkg/ArmSvcLib: Return x4-x7 in output parameters

The Arm SMC calling convention standard v1.2 allows 8 input and output
parameter registers. The FF-A specification relies on this
communication. This patch extends the number of output registers
returned by ArmCallSvc() to match this convention.

Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg/IndustryStandard: Add barebones FF-A header
Achin Gupta [Fri, 19 Feb 2021 06:35:54 +0000 (12:05 +0530)]
ArmPkg/IndustryStandard: Add barebones FF-A header

This patch adds a rudimentary header file with defines for FF-A ABIs
that will be used as the transport between S-EL0 and the SPM

Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoArmPkg: Update OemGetChassisType function to return MISC_CHASSIS_TYPE
Rebecca Cran [Tue, 23 Feb 2021 04:53:53 +0000 (21:53 -0700)]
ArmPkg: Update OemGetChassisType function to return MISC_CHASSIS_TYPE

Update OemGetChassisType in OemMiscLib to return MISC_CHASSIS_TYPE
instead of EFI_STATUS, which matches other OemMiscLib functions.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Rename some functions and parameters in OemMiscLib
Rebecca Cran [Tue, 23 Feb 2021 04:53:52 +0000 (21:53 -0700)]
ArmPkg: Rename some functions and parameters in OemMiscLib

o Rename 'mHiiHandle' parameter in OemUpdateSmbiosInfo to 'HiiHandle'.
o Rename 'Offset' parameter in OemUpdateSmbiosInfo to 'Field'.
o Rename OemGetProcessorMaxSockets to OemGetMaxProcessors.
o Rename OemIsSocketPresent to OemIsProcessorPresent.
o Update Universal/Smbios to follow the changes to OemMiscLib.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Fix ordering of return type and EFIAPI specifier in OemMiscLib
Rebecca Cran [Tue, 23 Feb 2021 04:53:51 +0000 (21:53 -0700)]
ArmPkg: Fix ordering of return type and EFIAPI specifier in OemMiscLib

The return type should be on the line before any EFIAPI specifier.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoBaseTools: Fix BrotliCompress run issue on Linux
Yunhua Feng [Thu, 4 Feb 2021 08:36:10 +0000 (16:36 +0800)]
BaseTools: Fix BrotliCompress run issue on Linux

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3210
BrotliCompress changed, but not completely on Linux

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
3 years agoEmbeddedPkg/VirtualRealTimeClockLib: Reduce DEBUG message verbosity
Samer El-Haj-Mahmoud [Sat, 20 Feb 2021 16:41:33 +0000 (11:41 -0500)]
EmbeddedPkg/VirtualRealTimeClockLib: Reduce DEBUG message verbosity

The DEBUG message for using compilation time epoch is appearing very
frequently on DEBUG firmware builds, for example during UEFI SCT runs.
Reduce verbosity to avoid the annoying repetitive message.

Signed-off-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoDynamicTablesPkg/AmlLib: Remove unused variables
Pierre Gondois [Mon, 15 Feb 2021 18:29:57 +0000 (18:29 +0000)]
DynamicTablesPkg/AmlLib: Remove unused variables

Building the DynamicTablesPkg for a NOOPT target
fails because unused variables are set.
Remove these variables.

Fixes: d9800046ea43
Reported-by: Leif Lindholm <leif@nuviainc.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoUefiPayloadPkg/PlatformBootManager: Connect console after EndOfDxe
Guo Dong [Fri, 12 Feb 2021 04:30:49 +0000 (21:30 -0700)]
UefiPayloadPkg/PlatformBootManager: Connect console after EndOfDxe

Currently the console is connected before EndOfDxe causing OptionsROMs
to be loaded, but their drivers aren't used and thus no GOP is installed.
To make use of 3rdparty OptionROMs connect the console after EndOfDxe.
Tested on Intel CFL board using Nvidia Quadro GPU.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
3 years agoUefiPayloadPkg: Fix PciLib dependency on BlSupportDxe
Guo Dong [Fri, 12 Feb 2021 04:22:45 +0000 (21:22 -0700)]
UefiPayloadPkg: Fix PciLib dependency on BlSupportDxe

The PciLib depends on PCDs
- PcdPciExpressBaseAddress
- PcdPciExpressBaseSize
being updated by BlSupportDxe before MMCONF accesses are working.

Add BlSupportDxe to APRIORI to start it first and get the system into
an usable state where at least PCI accesses work reliable.

Fixes a bug where BlSupportDxe is scheduled too late and other DXEs fail
to load due to broken PCI access.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
3 years agoUefiPayloadPkg: Enable NVMe support
Guo Dong [Fri, 12 Feb 2021 03:55:47 +0000 (20:55 -0700)]
UefiPayloadPkg: Enable NVMe support

Signed-off-by: Tim Crawford <tcrawford@system76.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
3 years agoDynamicTablesPkg: Add an override for 16550 HID in SSDT
Joey Gouly [Fri, 22 Jan 2021 12:51:12 +0000 (12:51 +0000)]
DynamicTablesPkg: Add an override for 16550 HID in SSDT

Some platforms advertise support for a 16550 UART, but are not
compatible with the PNP0500 HID. Allow them to override the HID by
setting PcdNonBsaCompliant16550SerialHid.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoDynamicTablesPkg: Don't use gEfiMdeModulePkgTokenSpaceGuid
Joey Gouly [Fri, 22 Jan 2021 12:51:11 +0000 (12:51 +0000)]
DynamicTablesPkg: Don't use gEfiMdeModulePkgTokenSpaceGuid

Introduce gEdkiiDynamicTablesPkgTokenSpaceGuid and use that instead.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoStandaloneMmPkg/StandaloneMmCore: Fix compiler warning
Michael Kubacki [Thu, 11 Feb 2021 01:04:20 +0000 (17:04 -0800)]
StandaloneMmPkg/StandaloneMmCore: Fix compiler warning

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3204

Fixes the following compiler warning in VS2019 by changing defining
the MmramRangeCount variable to be UINTN and type casting prior
to value assignment.

\edk2\StandaloneMmPkg\Core\StandaloneMmCore.c(570): error C2220:
  the following warning is treated as an error
\edk2\StandaloneMmPkg\Core\StandaloneMmCore.c(570): warning C4244:
  '=': conversion from 'UINT64' to 'UINT32', possible loss of data

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoStandaloneMmPkg: Add X64 build support
Michael Kubacki [Thu, 11 Feb 2021 01:01:15 +0000 (17:01 -0800)]
StandaloneMmPkg: Add X64 build support

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3202

Several libraries have been added to the package to support X64 but
the package itself does not support X64. This modifies the DSC to
enable X64 build.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoStandaloneMmPkg/FvLib.h: Add EFIAPI to FfsFindSection()
Michael Kubacki [Wed, 3 Feb 2021 03:52:14 +0000 (19:52 -0800)]
StandaloneMmPkg/FvLib.h: Add EFIAPI to FfsFindSection()

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3203

The EFIAPI modifier is present in the function definition in
FvLib.c but missing in FvLib.h. Causes a GCC build error.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoArmPkg: Fix ARM ProcessorSubClassDxe build
Rebecca Cran [Wed, 10 Feb 2021 15:04:57 +0000 (08:04 -0700)]
ArmPkg: Fix ARM ProcessorSubClassDxe build

The ARM ProcessorSubClassDxe build was broken due to changes in the
SmbiosProcessor API and an unused variable.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoBaseTools: Fix the ending character for Linux script BuildEnv
Bob Feng [Tue, 9 Feb 2021 14:58:08 +0000 (06:58 -0800)]
BaseTools: Fix the ending character for Linux script BuildEnv

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Matthew Carlson <matthewfcarlson@gmail.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
3 years agoArmPkg: add DebugLib to OemMiscLibNull
Leif Lindholm [Mon, 8 Feb 2021 23:39:43 +0000 (23:39 +0000)]
ArmPkg: add DebugLib to OemMiscLibNull

The just added OemMiscLibNull fails to build due to DebugLib.h not
being included, missing the ASSERT definition. Add the include and the
library dependency.

Cc: Rebecca Cran <rebecca@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Rebecca Cran <rebecca@nuviainc.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoIntelFsp2Pkg: Add YAML file generation support
Loo Tung Lun [Mon, 8 Feb 2021 05:04:16 +0000 (13:04 +0800)]
IntelFsp2Pkg: Add YAML file generation support

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3091

Add support for YAML format file generation in addition
to current BSF structure. Configuration of YAML format
output will be supported by an open source ConfigEditor.

Reference to YAML code, test and ConfigEditor is at
https://github.com/joshloo/fsp_yaml_cfg/tree/master/Tools

A unit test is also added in Tests folder. This test compares
the generated yaml file against the expected output to know
if it is constructing the yaml data structure as expected.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Signed-off-by: Loo Tung Lun <tung.lun.loo@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
3 years agoBaseTools: Use pip module if available, CI uses it by default
Matthew Carlson [Tue, 9 Feb 2021 00:50:33 +0000 (08:50 +0800)]
BaseTools: Use pip module if available, CI uses it by default

Use the new edk2-basetools pip module.
Includes a helpful message in setup to let users know which has been
selected.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Yuwei <Chen<yuwei.chen@intel.com>
Signed-off-by: Matthew Carlson <matthewfcarlson@gmail.com>
3 years agoArmPkg: Add Universal/Smbios/SmbiosMiscDxe
Rebecca Cran [Mon, 8 Feb 2021 00:52:54 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/SmbiosMiscDxe

SmbiosMiscDxe provides SMBIOS tables 0, 1, 2, 3, 13, and 32.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
3 years agoArmPkg: Add SMBIOS PCDs to ArmPkg.dec
Rebecca Cran [Mon, 8 Feb 2021 00:52:53 +0000 (17:52 -0700)]
ArmPkg: Add SMBIOS PCDs to ArmPkg.dec

Platforms are expected to override these PCDs to provide relevant
information to SMBIOS.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type32
Rebecca Cran [Mon, 8 Feb 2021 00:52:52 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type32

This code provides information for the SMBIOS Type 32 table.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
3 years agoArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type13
Rebecca Cran [Mon, 8 Feb 2021 00:52:51 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type13

This code provides information for the SMBIOS Type 13 table.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type03
Rebecca Cran [Mon, 8 Feb 2021 00:52:50 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type03

This code provides information for the SMBIOS Type 3 table.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
3 years agoArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type02
Rebecca Cran [Mon, 8 Feb 2021 00:52:49 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type02

This code provides information for the SMBIOS Type 2 table.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
3 years agoArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type01
Rebecca Cran [Mon, 8 Feb 2021 00:52:48 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type01

This code provides information for the SMBIOS Type 1 table.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
3 years agoArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type00
Rebecca Cran [Mon, 8 Feb 2021 00:52:47 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type00

This code provides information for the SMBIOS Type 0 table.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add Universal/Smbios/ProcessorSubClassDxe
Rebecca Cran [Mon, 8 Feb 2021 00:52:46 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/ProcessorSubClassDxe

ProcessorSubClassDxe provides SMBIOS CPU information using generic
methods combined with calls into OemMiscLib.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
3 years agoArmPkg: Add Universal/Smbios/OemMiscLibNull
Rebecca Cran [Mon, 8 Feb 2021 00:52:45 +0000 (17:52 -0700)]
ArmPkg: Add Universal/Smbios/OemMiscLibNull

Add a Null implementation of OemMiscLib.

OemMiscLib provides functions that platforms implement to fill in
SMBIOS information for the SmbiosMiscDxe and ProcessSubClassDxe drivers.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Acked-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add Library/OemMiscLib.h
Rebecca Cran [Mon, 8 Feb 2021 00:52:44 +0000 (17:52 -0700)]
ArmPkg: Add Library/OemMiscLib.h

OemMiscLib.h provides the interface which platforms should implement to
interact with the SmbiosMiscDxe and ProcessorSubClassDxe drivers to
update SMBIOS tables.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Acked-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add helper to read the CCSIDR2 register
Rebecca Cran [Mon, 8 Feb 2021 00:52:43 +0000 (17:52 -0700)]
ArmPkg: Add helper to read the CCSIDR2 register

Add helper function to read the CCSIDR2 register.
This is used when CCIDX is supported in AARCH32 mode.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add helper to read CCIDX status
Rebecca Cran [Mon, 8 Feb 2021 00:52:42 +0000 (17:52 -0700)]
ArmPkg: Add helper to read CCIDX status

Add a helper function to determine CCIDX support.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add definition of the maximum cache level in ARMv8-A
Rebecca Cran [Mon, 8 Feb 2021 00:52:41 +0000 (17:52 -0700)]
ArmPkg: Add definition of the maximum cache level in ARMv8-A

The ARM Architecture Reference Manual for ARMv8-A defines up to
seven levels of cache, L1 through L7.
Define MAX_ARM_CACHE_LEVEL to be 7.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoArmPkg: Update ArmLibPrivate.h with cache register definitions
Rebecca Cran [Mon, 8 Feb 2021 00:52:40 +0000 (17:52 -0700)]
ArmPkg: Update ArmLibPrivate.h with cache register definitions

Update the cache definitions in ArmLibPrivate.h based on current
ARMv8 documentation.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoArmPkg: Fix the return type of the ReadCCSIDR function
Rebecca Cran [Mon, 8 Feb 2021 00:52:39 +0000 (17:52 -0700)]
ArmPkg: Fix the return type of the ReadCCSIDR function

When CCIDX is supported, the Current Cache Size ID Register contains
data above 32 bits: namely the number of sets. Avoid truncating this
by returning a UINTN instead of UINT32. On AARCH32, the expanded
number of sets data can be read via the CCSIDR2 register.

Also, add Doxygen comments for the function.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add helper function to read the Memory Model Feature Register 4
Rebecca Cran [Mon, 8 Feb 2021 00:52:38 +0000 (17:52 -0700)]
ArmPkg: Add helper function to read the Memory Model Feature Register 4

In AARCH32, CCIDX support is indicated in the MMFR4 register - unlike
under AARCH64 where it's in MMFR2. Add a helper function to read it.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3 years agoArmPkg: Add helper to read the Memory Model Features Register 2
Rebecca Cran [Mon, 8 Feb 2021 00:52:37 +0000 (17:52 -0700)]
ArmPkg: Add helper to read the Memory Model Features Register 2

Add helper function to read the MMFR2 register. We will need this to
determine CCIDX support.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoArmPkg: Add register encoding definition for MMFR2
Rebecca Cran [Mon, 8 Feb 2021 00:52:36 +0000 (17:52 -0700)]
ArmPkg: Add register encoding definition for MMFR2

Add register encoding definition for Memory Model Feature Register 2.
We need to define it here because we build for ARMv8.0, which doesn't
have it.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoMdePkg: Update IndustryStandard/SmBios.h with processor status data
Rebecca Cran [Mon, 8 Feb 2021 00:52:35 +0000 (17:52 -0700)]
MdePkg: Update IndustryStandard/SmBios.h with processor status data

Add a bitfield that describes the structure of the byte in the Status
field of the SMBIOS Type 4 Processor Information table.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Acked-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoArmPkg: Add ARM SMC Architecture functions to ArmStdSmc.h
Rebecca Cran [Mon, 8 Feb 2021 00:52:34 +0000 (17:52 -0700)]
ArmPkg: Add ARM SMC Architecture functions to ArmStdSmc.h

The ARM SMC Architecture functions were missing from ArmStdSmc.h.
Add them, based on the SMC Calling Convention version 1.2 specification.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
3 years agoMaintainers.txt: Change Jordan Justen to a reviewer for OvmfPkg
Jordan Justen [Thu, 4 Feb 2021 19:49:02 +0000 (11:49 -0800)]
Maintainers.txt: Change Jordan Justen to a reviewer for OvmfPkg

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Message-Id: <20210204194902.101548-2-jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoMaintainers.txt: Remove Jordan Justen from EmulatorPkg
Jordan Justen [Thu, 4 Feb 2021 19:49:01 +0000 (11:49 -0800)]
Maintainers.txt: Remove Jordan Justen from EmulatorPkg

Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
Message-Id: <20210204194902.101548-1-jordan.l.justen@intel.com>

3 years agoBaseTools: fix the split output files root dir
Bob Feng [Mon, 1 Feb 2021 10:28:58 +0000 (18:28 +0800)]
BaseTools: fix the split output files root dir

If the output file path is a relative path, the split
tool will create the output file under the input file path.
But the expected behavior for this case is the output file
should be relative to the current directory. This patch will
fix this bug.

If the output file path is not specified and output prefix is not
specified, the output file should be under the input file path

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
3 years agoMdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish
Abner Chang [Fri, 22 Jan 2021 02:54:57 +0000 (10:54 +0800)]
MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish

Add HiiGetStringEx and leveraged by HiiGetString function to support
getting string with the best language in optionally. This avoids the
string in x-uefi language is misled to the language defined by
"PlatformLang" or the "Supported Languages". This change is introduced
to support x-uefi keyword language for configuring BIOS setting.

Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Fan Wang <fan.wang@intel.com>
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
3 years agoArmPkg/Library: prevent endless reboot loop with emulated NV varstore
Leif Lindholm [Thu, 4 Feb 2021 12:36:59 +0000 (12:36 +0000)]
ArmPkg/Library: prevent endless reboot loop with emulated NV varstore

If no valid boot options were found, PlatformBootManagerLib refreshes a
set of sane default options and then reboots. However, if there is in
fact no persistent varstore, the same thing happens again on next boot,
and we end up in an endlessly rebooting loop.

So when PcdEmuVariableNvModeEnable is TRUE, skip the reboot step and
enter the setup menu instead.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
3 years agoUefiCpuPkg: Move MigrateGdt from DiscoverMemory to TempRamDone. (CVE-2019-11098)
Guomin Jiang [Wed, 13 Jan 2021 10:08:09 +0000 (18:08 +0800)]
UefiCpuPkg: Move MigrateGdt from DiscoverMemory to TempRamDone. (CVE-2019-11098)

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1614
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3160

The GDT still in flash with commit 60b12e69fb1c8c7180fdda92f008248b9ec83db1
after TempRamDone

So move the action to TempRamDone event to avoid reading GDT from flash.

Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
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: Debkumar De <debkumar.de@intel.com>
Cc: Harry Han <harry.han@intel.com>
Cc: Catharine West <catharine.west@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoUefiCpuPkg/CpuCacheInfoLib: Support no enabled AP case in DxeLib
Lou, Yun [Mon, 1 Feb 2021 08:28:50 +0000 (16:28 +0800)]
UefiCpuPkg/CpuCacheInfoLib: Support no enabled AP case in DxeLib

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3195

Support system has no enabled AP case in DxeCpuCacheInfoLib.
Otherwise, if the system only has 1 BSP without any enabled AP,
UEFI POST hangs when invoking StartupAllAPs protocol because
EFI_NOT_STARTED is returned.

Signed-off-by: Jason Lou <yun.lou@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
3 years agoUefiCpuPkg/CpuCacheInfoLib: Add MpService dependency
Lou, Yun [Tue, 2 Feb 2021 00:41:29 +0000 (08:41 +0800)]
UefiCpuPkg/CpuCacheInfoLib: Add MpService dependency

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3190

Add MpService dependency to enforce the executability of CpuCacheInfoLib.

Signed-off-by: Jason Lou <yun.lou@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
3 years agoShellPkg/AcpiView: HMAT Parser
Marc Moisson-Franckhauser [Wed, 4 Nov 2020 11:17:02 +0000 (19:17 +0800)]
ShellPkg/AcpiView: HMAT Parser

Bugzilla: 3045 (https://bugzilla.tianocore.org/show_bug.cgi?id=3045)

Add a new parser for the Heterogeneous Memory Attribute Table. The
parser also validates some fields for this table.

The HMAT table is used to describe the memory attributes such as memory
side cache attributes and bandwidth and latency details related to
memory proximity domains. The info in the HMAT table can be used by an
operating system for optimisation.

Signed-off-by: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
3 years agoMdeModulePkg/TerminalDxe: Terminal fifo buffer overflow.
gechao [Thu, 14 Jan 2021 03:22:59 +0000 (11:22 +0800)]
MdeModulePkg/TerminalDxe: Terminal fifo buffer overflow.

Fix the bug of terminal fifo buffer overflow with UINT8 type.

typedef struct {
  UINT8 Head;
  UINT8 Tail;
  UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];
} RAW_DATA_FIFO;
RAW_FIFO_MAX_NUMBER is 256.
the data buffer size is 257 (Index from 0 to 256), but the max value of
the index, Head or Tail (UINT8), is 255. That means the last data of the
data buffer would be always empty if we use Head/Tail to output/input the
data correctly.  And because of the incorrect buffer size the FIFO full
check "((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head" would never meet.

Signed-off-by: gechao <gechao@greatwall.com.cn>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
3 years agoMdeModulePkg/PciBusDxe: Fix a bug in ProcessOptionRomLight
Aiden Park [Wed, 13 Jan 2021 19:01:14 +0000 (03:01 +0800)]
MdeModulePkg/PciBusDxe: Fix a bug in ProcessOptionRomLight

The ProcessOptionRomLight() assumes that OpRom has already been
processed in the previous full enumeration and updates
AllOpRomProcessed flag to TRUE by default. However, this may not
be applicable with other pre-stage boot firmwares.

This will update AllOpRomProcessed flag properly by checking
PciRomGetImageMapping().

Signed-off-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoUefiCpuPkg: SmmCpuExceptionHandlerLib: Added StandaloneMm module support
Kun Qin [Fri, 18 Dec 2020 03:27:20 +0000 (19:27 -0800)]
UefiCpuPkg: SmmCpuExceptionHandlerLib: Added StandaloneMm module support

This change of SmmCpuExceptionHandlerLib adds support for StandaloneMm
components to allow x64 StandaloneMm environment setting up exception
handlers.

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>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoUefiCpuPkg: CpuIo2Smm: Support of CpuIo driver under StandaloneMm
Kun Qin [Sat, 23 Jan 2021 02:09:04 +0000 (18:09 -0800)]
UefiCpuPkg: CpuIo2Smm: Support of CpuIo driver under StandaloneMm

This change adds a new CpuIo driver instance for MM_STANDALONE type. The
new driver entrypoint is implemented in a separate file to match the
interface definition of MM_STANDALONE modules.

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>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoUefiCpuPkg: CpuIo2Smm: Abstract SMM specific functions into separate file
Kun Qin [Tue, 12 Jan 2021 03:00:05 +0000 (19:00 -0800)]
UefiCpuPkg: CpuIo2Smm: Abstract SMM specific functions into separate file

This change abstracts CpuIo2Smm driver entrypoint into separate file and
moves functions/definitions that are not substantially specific to
Traditional MM (SMM) into CpuIo2Mm.* in order to set ways for Standalone
MM support in the future.

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>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoUefiCpuPkg: CpuIo2Smm: Move CpuIo2Smm driver to consume gMmst
Kun Qin [Fri, 18 Dec 2020 03:12:50 +0000 (19:12 -0800)]
UefiCpuPkg: CpuIo2Smm: Move CpuIo2Smm driver to consume gMmst

This change replaced gSmst with gMmst to support broader compatibility
under MM environment for CpuIo2Smm driver.

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>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoSecurityPkg: Tpm2DeviceLibDTpm: Introduce StandaloneMm instance
Kun Qin [Fri, 18 Dec 2020 06:31:21 +0000 (22:31 -0800)]
SecurityPkg: Tpm2DeviceLibDTpm: Introduce StandaloneMm instance

This change added a new instance of Tpm2DeviceLibDTpm to support drivers
of type MM_STANDALONE. It abstracts dynamic Pcd access into separate file
for different instances to avoid dynamic usage for StandaloneMm modules.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Qi Zhang <qi1.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
3 years agoSecurityPkg: Tcg2PpVendorLibNull: Added support for MM_STANDALONE type
Kun Qin [Thu, 17 Dec 2020 23:27:46 +0000 (15:27 -0800)]
SecurityPkg: Tcg2PpVendorLibNull: Added support for MM_STANDALONE type

This change extends this null instance of Tcg2PpVendorLib to support
MM_STANDALONE drivers.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Qi Zhang <qi1.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
3 years agoSecurityPkg: Tcg2PhysicalPresenceLib: Introduce StandaloneMm instance
Kun Qin [Thu, 17 Dec 2020 23:24:08 +0000 (15:24 -0800)]
SecurityPkg: Tcg2PhysicalPresenceLib: Introduce StandaloneMm instance

This change added a new instance of Tcg2PhysicalPresenceLib to support
MM_STANDALONE type drivers. It centralizes the common routines into
shared files and abstract the library constructor into corresponding
files to implement each constructor function prototypes.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Qi Zhang <qi1.zhang@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
3 years agoPcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib
Kun Qin [Thu, 17 Dec 2020 22:47:07 +0000 (14:47 -0800)]
PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib

This change added a new instance of AcpiTimerLib for StandaloneMm core
and drivers. It centralizes the common routines into shared files and
abstract the library constructor into corresponding files to accommodate
each constructor function prototypes.

Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoMdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm
Kun Qin [Thu, 17 Dec 2020 22:35:38 +0000 (14:35 -0800)]
MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm

This change added an instance of UefiDevicePathLib for StandaloneMm. It
abstracts DevicePathFromHandle function into different files for
Standalone MM and other instances to avoid linking gBS into MM_STANDALONE
drivers.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
3 years agoMdeModulePkg: SmmSmiHandlerProfileLib: Support StandaloneMm Instance
Kun Qin [Tue, 26 Jan 2021 07:10:21 +0000 (23:10 -0800)]
MdeModulePkg: SmmSmiHandlerProfileLib: Support StandaloneMm Instance

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3185

This change added support of SMI handler profile library router under
StandaloneMm. This change replaces gSmst with gMmst. It also abstracts
standalone and traditional MM driver entrypoints into separate files to
allow maximal common implementations.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
3 years agoMdeModulePkg: ReportStatusCodeRouter: Support StandaloneMm RSC Router
Kun Qin [Thu, 17 Dec 2020 22:28:57 +0000 (14:28 -0800)]
MdeModulePkg: ReportStatusCodeRouter: Support StandaloneMm RSC Router

This change added support of RSC router under StandaloneMm. It replaces
SMM version ReportStatusCode protocol definitions with MM version. This
patch also switched to use gMmst instead of gSmst. Lastly, it abstracts
standalone and traditional MM driver entrypoints into separate files to
allow maximal common implementations.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
3 years agoMdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support
Kun Qin [Thu, 17 Dec 2020 22:15:13 +0000 (14:15 -0800)]
MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support

This change added support of FPDT driver under StandaloneMm. It replaces
SMM version ReportStatusCode protocol with MM version. This patch also
abstracts standalone and traditional MM interfaces into separate files to
support each corresponding function prototypes and implementations.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
3 years agoMdeModulePkg: StatusCodeHandler: StatusCodeHandler driver in StandaloneMm
Kun Qin [Thu, 31 Dec 2020 09:56:51 +0000 (01:56 -0800)]
MdeModulePkg: StatusCodeHandler: StatusCodeHandler driver in StandaloneMm

This change added support of StandaloneMm for StatusCodeHandler. It
adds a new instance of StatusCodeHandler of MM_STANDALONE type, and
abstracts the driver entrypoint into separate files, replaced gSmst with
gMmst, and switched to MM version of RscHandlerProtocol.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
3 years agoMdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm
Kun Qin [Thu, 17 Dec 2020 21:38:50 +0000 (13:38 -0800)]
MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm

This change added support of StandaloneMm for ReportStatusCodeLib. It
adds a new instance of ReportStatusCodeLib for MM_STANDALONE type, and
abstracts the references of gMmst and gSmst functionalities into separate
files in order to link in proper Service Table for SMM core/drivers.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
3 years agoMdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib
Kun Qin [Thu, 17 Dec 2020 21:18:51 +0000 (13:18 -0800)]
MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib

This change added support of StandaloneMm for SmmLockBoxLib. It replaces
gSmst with gMmst to support both traditional MM and standalone MM. The
contructor and desctructor functions are abstracted to support different
function prototype definitions.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
3 years agoStandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture
Kun Qin [Fri, 18 Dec 2020 11:09:24 +0000 (03:09 -0800)]
StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture

This change extends StandaloneMmMemLib library to support X64
architecture. The implementation is ported from MdePkg/Library/SmmMemLib.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
3 years agoStandaloneMmPkg: StandaloneMmCoreMemoryAllocationLib: Fix compiler warning
Kun Qin [Fri, 18 Dec 2020 02:51:05 +0000 (18:51 -0800)]
StandaloneMmPkg: StandaloneMmCoreMemoryAllocationLib: Fix compiler warning

Assigning MmramRangeCount from MmCorePrivate (UINT64) to local variable
MmramRangeCount (UINT32) will cause compilation failure due to "warning
C4244: '=': conversion from 'UINT64' to 'UINT32', possible loss of data".
This changes defines local MmramRangeCount as UINTN type and adds type
cast before value assignment.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
3 years agoStandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core
Kun Qin [Fri, 18 Dec 2020 02:33:19 +0000 (18:33 -0800)]
StandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core

This change adds support of x64 version of StandaloneMmCoreHobLib. It
brings in global variable "gHobList" through StandaloneMmCoreEntryPoint,
imports implementation from DxeCoreHobLib.inf to support x64 Mm Core and
moved shared functional plementations into a common file.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
3 years agoStandaloneMmPkg: StandaloneMmCoreEntryPoint: Extends support for X64
Kun Qin [Fri, 18 Dec 2020 01:23:35 +0000 (17:23 -0800)]
StandaloneMmPkg: StandaloneMmCoreEntryPoint: Extends support for X64

This change extends StandaloneMmCoreEntryPoint library to support X64
architecture.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>