]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
22 months agoBaseTools/Ecc: Fix grammar in Ecc error message
Rebecca Cran [Sun, 19 Jun 2022 22:07:09 +0000 (06:07 +0800)]
BaseTools/Ecc: Fix grammar in Ecc error message

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
22 months agoOvmf: Include HardwareInfoLib library classes for IntelTdx
Nicolas Ojeda Leon [Thu, 23 Jun 2022 15:26:23 +0000 (17:26 +0200)]
Ovmf: Include HardwareInfoLib library classes for IntelTdx

Include HardwareInfoLib classes in the IntelTdxX64.dsc for this
platform to use it during build given that PciHostBridgeUtilityLib
depends on it.

Cc: Alexander Graf <graf@amazon.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@amazon.com>
22 months agoArmVirtPkg: Include DxeHardwareInfoLib library class in dsc
Nicolas Ojeda Leon [Thu, 23 Jun 2022 15:23:27 +0000 (17:23 +0200)]
ArmVirtPkg: Include DxeHardwareInfoLib library class in dsc

Include DxeHardwareInfoLib class in the common ArmVirt.dsc.inc so that
ArmVirt* platforms use it during build given that PciHostBridgeUtilityLib
depends on it.

Cc: Alexander Graf <graf@amazon.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@amazon.com>
22 months agoUefiPayloadPkg: Backward support with python 3.6
KasimX Liu [Fri, 24 Jun 2022 03:35:43 +0000 (11:35 +0800)]
UefiPayloadPkg: Backward support with python 3.6

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

Currently, UniversalPayloadBuild.py don't have support
python3.6, we use python3.6 will encounter f"" failure
use the change to fix it to support python3.6/3.7/3.8.

Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: KasimX Liu <kasimx.liu@intel.com>
22 months agoUefiCpuPkg: CpuDxe: Set RW and P Attributes on Split Pages
Ray Ni [Thu, 23 Jun 2022 06:20:32 +0000 (14:20 +0800)]
UefiCpuPkg: CpuDxe: Set RW and P Attributes on Split Pages

A memory range can be submitted for attribute changes which is large
enough to not require a page split during the attribute update. Consider
the following scenario:

1. An attribute update removed the RW attribute on a range large enough
to not require a page split.
2. Later, an attributes update is called to re-add the RW attribute for
a subsection of that larger page which requires a split
3. The attribute update logic performs a page split, so now the parent
and child pages have matching attributes
4. Then, the attribute update logic changes the child page to have the
RW attribute.
5. The child page would then correctly have the RW attribute added but
the parent page would still have the RW attribute removed which will
cause an improper access violation.

The page being split should have loose attributes to accommodate the
above case. The split page should always have the attributes set so
the lowest level page frame determines the access rights as detailed
in 4.10.2.2 of the Intel 64 and IA-32 Architectures Software
Developer Manual. Setting the User/Supervisor attribute shouldn't
be necessary.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Taylor Beebe <t@taylorbeebe.com>
22 months agoArmPlatformPkg: Add PCD for serial debug port interrupt
Thomas Abraham [Wed, 22 Jun 2022 15:38:43 +0000 (21:08 +0530)]
ArmPlatformPkg: Add PCD for serial debug port interrupt

For Arm platforms that support more that one serial port, one of the
serial port can be used for connecting debuggers such as WinDbg. There
are PCDs that allow the base address and clock rate to be specified for
this debug serial port but not its interrupt number. So add a PCD to
specify the interrupt number assigned to the serial debug port
controller.

Signed-off-by: Thomas Abraham <thomas.abraham@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
22 months agoOvmfPkg/PciHostBridgeUtilityLib: Initialize RootBridges apertures with spec
Nicolas Ojeda Leon [Tue, 29 Jun 2021 15:52:13 +0000 (17:52 +0200)]
OvmfPkg/PciHostBridgeUtilityLib: Initialize RootBridges apertures with spec

Consume the host-provided specification of PCI host bridges if
available. Using the DxeHardwareInfoLib, populate a list of
hardware descriptors based on the content of the "hardware-info"
fw-cfg file, if provided. In the affirmative case, use the
resources and attributes specified by the hypervisor for each
Host Bridge to create the RootBridge elements.

In Ovmf platforms, the host can provide the specification of
non-discoverable hardware resources like PCI host bridges. If the
proper fw-cfg file is found, parse the contents provided by the
host into a linked list by using the Hardware Info library. Then,
using the list of PCI host bridges' descriptions, populate the
PCI_ROOT_BRIDGES array with the resources and attributes specified
by the host. If the file is not provided or no Host Bridge is found
in it, fold back to the legacy method based on pre-defined
apertures and rules.

In some use cases, the host requires additional control over the
hardware resources' configurations in the guest for performance and
discoverability reasons. For instance, to disclose information about
the PCI hierarchy to the guest so that this can profit from
optimized accesses. In this case, the host can decide to describe
multiple PCI Host Bridges and provide a specific set of resources
(e.g. MMIO apertures) so that the guest uses the values provided.
Using the provided values may entitle the guest to added performance,
for example by using specific MMIO mappings that can enable peer-to-peer
communication across the PCI hierarchy or by allocating memory closer
to a device for faster DMA transactions.

Cc: Alexander Graf <graf@amazon.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@amazon.com>
22 months agoOvmf/PlatformPei: Use host-provided GPA end if available
Nicolas Ojeda Leon [Wed, 19 Jan 2022 14:48:33 +0000 (15:48 +0100)]
Ovmf/PlatformPei: Use host-provided GPA end if available

Read the "hardware-info" item from fw-cfg to extract specifications
of PCI host bridges and analyze the 64-bit apertures of them to
find out the highest 64-bit MMIO address required which determines
the address space required by the guest, and, consequently, the
FirstNonAddress used to calculate size of physical addresses.

Using the static PeiHardwareInfoLib, read the fw-cfg file of
hardware information to extract, one by one, all the host
bridges. Find the last 64-bit MMIO address of each host bridge,
using the HardwareInfoPciHostBridgeLib API, and compare it to an
accumulate value to discover the highest address used, which
corresponds to the highest value that must be included in the
guest's physical address space.

Given that platforms with multiple host bridges may provide the PCI
apertures' addresses, the memory detection logic must take into
account that, if the host provided the MMIO windows that can and must
be used, the guest needs to take those values. Therefore, if the
MMIO windows are found in the host-provided fw-cfg file, skip all the
logic calculating the physical address size and just use the value
provided. Since each PCI host bridge corresponds to an element in
the information provided by the host, each of these must be analyzed
looking for the highest address used.

Cc: Alexander Graf <graf@amazon.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@amazon.com>
22 months agoOvmf/HardwareInfoLib: Add Dxe lib to dynamically parse heterogenous data
Nicolas Ojeda Leon [Wed, 19 Jan 2022 14:12:30 +0000 (15:12 +0100)]
Ovmf/HardwareInfoLib: Add Dxe lib to dynamically parse heterogenous data

Following the Hardware Info library, create the DxeHardwareInfoLib
which implements the whole API capable of parsing heterogeneous hardware
information. The list-like API grants callers a flexible and common
pattern to retrieve the data. Moreover, the initial source is a BLOB
which generalizes the host-to-guest transmission mechanism.

The Hardware Info library main objective is to provide a way to
describe non-discoverable hardware so that the host can share the
available resources with the guest in Ovmf platforms. This change
features and embraces the main idea behind the library by providing
an API that parses a BLOB into a linked list to retrieve hardware
data from any source. Additionally, list-like APIs are provided so
that the hardware info list can be traversed conveniently.
Similarly, the capability is provided to filter results by specific
hardware types. However, heterogeneous elements can be added to the
list, increasing the flexibility. This way, a single source, for
example a fw-cfg file, can be used to describe several instances of
multiple types of hardware.

This part of the Hardware Info library makes use of dynamic memory
and is intended for stages in which memory services are available.
A motivation example is the PciHostBridgeLib. This library, part
of the PCI driver populates the list of PCI root bridges during DXE
stage for future steps to discover the resources under them. The
hardware info library can be used to obtain the detailed description
of available host bridges, for instance in the form of a fw-cfg file,
and parse that information into a dynmaic list that allows, first to
verify consistency of the data, and second discover the resources
availabe for each root bridge.

Cc: Alexander Graf <graf@amazon.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@amazon.com>
22 months agoOvmf/HardwareInfoLib: Create Pei lib to parse directly from fw-cfg
Nicolas Ojeda Leon [Wed, 19 Jan 2022 09:49:15 +0000 (10:49 +0100)]
Ovmf/HardwareInfoLib: Create Pei lib to parse directly from fw-cfg

Define the HardwareInfoLib API and create the PeiHardwareInfoLib
which implements it, specifically for Pei usage, supporting
only static accesses to parse data directly from a fw-cfg file.
All list-like APIs are implemented as unsupported and only a
fw-cfg wrapper to read hardware info elements is provided.

The Hardware Info library is intended to describe non-discoverable
hardware information and share that from the host to the guest in Ovmf
platforms. The QEMU fw-cfg extension for this library provides a first
variation to parse hardware info by reading it directly from a fw-cfg
file. This library offers a wrapper function to the plain
QmeuFwCfgReadBytes which, specifically, parses header-data pairs out
of the binary values in the file. For this purpose, the approach is
incremental, reading the file block by block and outputting the values
only for a specific known hardware type (e.g. PCI host bridges). One
element is returned in each call until the end of the file is reached.

Considering fw-cfg as the first means to transport hardware info from
the host to the guest, this wrapping library offers the possibility
to statically, and in steps, read a specific type of hardware info
elements out of the file. This method reads one hardware element of a
specific type at a time, without the need to pre-allocate memory and
read the whole file or dynamically allocate memory for each new
element found.

As a usage example, the static approach followed by this library
enables early UEFI stages to use and read hardware information
supplied by the host. For instance, in early times of the PEI stage,
hardware information can be parsed out from a fw-cfg file prescinding
from memory services, that may not yet be available, and avoiding
dynamic memory allocations.

Cc: Alexander Graf <graf@amazon.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@amazon.com>
22 months agoOvmfPkg/Library: Create base HardwareInfoLib for PCI Host Bridges
Nicolas Ojeda Leon [Tue, 18 Jan 2022 18:45:18 +0000 (19:45 +0100)]
OvmfPkg/Library: Create base HardwareInfoLib for PCI Host Bridges

Create the Hardware Info library base together with the specifics to
describe PCI Host Bridges.

The Hardware Info library is intended to be used for disclosing
non-discoverable hardware information from the host to the guest in
Ovmf platforms. Core functionality will provide the possibility to
parse information from a generic BLOB into runtime structures. The
library is conceived in a generic way so that further hardware
elements can also be described using it. For such purpose the length
of the BLOB is not restricted but instead regarded as a sequence of
header-info elements that allow the parsing during runtime. The first
type of hardware defined will be PCI host bridges, providing the
possibility to define multiple and specify the resources each of them
can use. This enables the guest firmware to configure PCI resources
properly. Having the size of each individual element favors the reuse
of a single interface to convey descriptions of an arbitrary number
of heterogenous hardware elements. Furthermore, flexible access
mechanisms coupled with the size will grant the possibility of
interpreting them in a single run.

Define the base types of the generic Hardware Info library to parse
heterogeneous data. Also provide the specific changes to support
PCI host bridges as the first hardware type supported by the
library.
Additionally, define the HOST_BRIDGE_INFO structure to describe PCI
host bridges along with the functionality to parse such information
into proper structures used by the PCI driver in a centralized manner
and taking care of versioning.

As an example and motivation, the library will be used to define
multiple PCI host bridges for complex platforms that require it.
The first means of transportation that will be used is going to be
fw-cfg, over which a stream of bytes will be transferred and later
parsed by the hardware info library. Accordingly, the PCI driver
will make use of these host bridges definitions to populate the
list of Root Bridges and proceed with the configuration and discovery
of underlying hardware components.

As mentioned before, the binary data to be parsed by the Hardware
Info library should be organized as a sequence of Header-element
pairs in which the header describes the type and size of the associated
element that comes right after it. As an illustration, to provide
inforation of 3 host bridges the data, conceptually, would look
like this:

Header PCI Host Bridge (type and size) # 1
PCI Host Bridge info # 1
Header PCI Host Bridge (type and size) # 2
PCI Host Bridge info # 2
Header PCI Host Bridge (type and size) # 3
PCI Host Bridge info # 3

Cc: Alexander Graf <graf@amazon.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@amazon.com>
22 months agoOvmfPkg: reduce the number of dsc include files for tpm libs
Gerd Hoffmann [Thu, 16 Jun 2022 12:56:33 +0000 (14:56 +0200)]
OvmfPkg: reduce the number of dsc include files for tpm libs

We can have multiple [LibraryClasses] sections, so we can place
all TPM-related library configuration to a single include file.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
22 months agoArmPlatformPkg: Remove overly verbose DEBUG lines in LcdGraphicsBlt
Rebecca Cran [Tue, 3 May 2022 20:07:56 +0000 (14:07 -0600)]
ArmPlatformPkg: Remove overly verbose DEBUG lines in LcdGraphicsBlt

The DEBUG output in LcdGraphicsBlt is overly verbose, and makes using
the console difficult, for example when using the UiApp.

Since the extra output should no longer be needed, delete the DEBUG
lines.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
22 months agoMdeModulePkg/XhciDxe: Check return value of XHC_PAGESIZE register
Luo, Heng [Mon, 20 Jun 2022 07:08:16 +0000 (15:08 +0800)]
MdeModulePkg/XhciDxe: Check return value of XHC_PAGESIZE register

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

Report error if reserved bits are not 0 for PageSize

Cc: Ray Ni <ray.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Signed-off-by: Heng Luo <heng.luo@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
22 months agoUefiPayloadPkg: UniversalPayloadBuild.py to support --pcd feature
Gua Guo [Tue, 21 Jun 2022 03:52:05 +0000 (11:52 +0800)]
UefiPayloadPkg: UniversalPayloadBuild.py to support --pcd feature

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

Currently, UPL freezed all PCD and only known UPL hob can hook DXE
Drivers behavior, add optional feature on UniversalPayloadBuild.py to
have another way to hook PCD value.

Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: : Ray Ni <ray.ni@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
22 months agoUefiPayloadPkg: Always split page table entry to 4K if it covers stack.
Liu, Zhiguang [Fri, 17 Jun 2022 08:28:03 +0000 (16:28 +0800)]
UefiPayloadPkg: Always split page table entry to 4K if it covers stack.

We observed page fault in the following situation:
1.PayloadEntry uses 2M entry in page table to cover DXE stack range.
2.In DXE phase, image protection code needs to mark some sub-range in
this 2M entry as readonly. So the the 2M page table entry is split to
512 4K entries, and some of the entries are marked as readonly.
(the entries covering stack still remain R/W)
3.Page fault exception happens when trying to access stack.

Always split the page table entry to 4K if it covers stack to avoid this
issue.
More discussion about this issue can be seen at below link
https://edk2.groups.io/g/devel/topic/91446026

Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
22 months agoUefiPayloadPkg: Increase the PcdMaximumUnicodeStringLength
Xie, Yuanhao [Wed, 15 Jun 2022 10:11:08 +0000 (18:11 +0800)]
UefiPayloadPkg: Increase the PcdMaximumUnicodeStringLength

The maximum Unicode string could be as large as 1800000 in certain
platforms when HII code builds the configuration strings.
This causes assertion in PrintLib.
The patch increases the PcdMaximumUnicodeStringLength to 1800000 to
avoid the assertion.

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
22 months agoBaseTools: output the intermediate library instance when error occurs
Ni, Ray [Wed, 15 Jun 2022 04:54:39 +0000 (12:54 +0800)]
BaseTools: output the intermediate library instance when error occurs

When a module "Module" depends on a library instance "Lib1" which
depends on "Lib2" which depends on "Lib3" ... depends on "LibN",
but "LibN" doesn't support the type (e.g.: SEC) of the "Module", the
following error messages are printed by build tool:

<DSC path>(...): error 1001: Module by library instance [<LibN path>]
        consumed by [<Module path>]

But it's unclear to user how LibN is consumed by the Module.

With the patch, following errors are printed:

<DSC path>(...): error 1001: Module by library instance [<LibN path>]
        consumed by library instance [<Lib N-1 path>] which is
        consumed by module[<Module path>]

It doesn't print all the intermediate library instances between the
Module and LibN but at least the path of Lib N-1 can help users
to help how to fix the build errors.

I hope this patch can be a trigger point that a better solution could
be developed by tool experts to print all the library instances
between the Module and LibN.

Signed-off-by: Ray Ni <ray.ni@intel.com>
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.fen@intel.com>
22 months agoSecurityPkg/HashLibTdx: Return EFI_UNSUPPORTED if it is not Tdx guest
Min M Xu [Sun, 12 Jun 2022 11:24:34 +0000 (19:24 +0800)]
SecurityPkg/HashLibTdx: Return EFI_UNSUPPORTED if it is not Tdx guest

HashLibTdx is designed for the Tdx guest. So if is not a Tdx guest,
return EFI_UNSUPPORTED in RegisterHashInterfaceLib.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: Use PcdOvmfWorkAreaBase instead of PcdSevEsWorkAreaBase
Min M Xu [Sun, 12 Jun 2022 11:24:33 +0000 (19:24 +0800)]
OvmfPkg: Use PcdOvmfWorkAreaBase instead of PcdSevEsWorkAreaBase

It is an typo error that HobList pointer should be stored at
PcdOvmfWorkAreaBase, not PcdSevEsWorkAreaBase.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoDxeMain: Fix the bug that StackGuard is not enabled
Ray Ni [Fri, 10 Jun 2022 08:43:32 +0000 (16:43 +0800)]
DxeMain: Fix the bug that StackGuard is not enabled

Commit e7abb94d1 removed InitializeCpuExceptionHandlersEx
and updated DxeMain to call InitializeCpuExceptionHandlers
for exception setup. But the old behavior that calls *Ex() sets
up the stack guard as well. To match the old behavior,
the patch calls InitializeSeparateExceptionStacks.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
22 months agoArmPkg/ArmExceptionLib: Follow new CpuExceptionHandlerLib APIs
Ray Ni [Mon, 13 Jun 2022 01:51:06 +0000 (09:51 +0800)]
ArmPkg/ArmExceptionLib: Follow new CpuExceptionHandlerLib APIs

CpuExceptionHandlerLib has been refactored with following changes:
1. Removed InitializeCpuInterruptHandlers in 2a09527ebcb459b40
2. Removed InitializeCpuExceptionHandlersEx and
   added InitializeSeparateExceptionStacks in e7abb94d1fb8a0e7

The patch updates ARM version of CpuExceptionHandlerLib to follow
the API changes.

The functionality to ARM platforms should be none.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
22 months agoMdePkg/BaseLib: Add CRC16-ANSI and CRC32c implementations
Pedro Falcato [Thu, 7 Apr 2022 22:02:00 +0000 (06:02 +0800)]
MdePkg/BaseLib: Add CRC16-ANSI and CRC32c implementations

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

Add the CRC16-ANSI and CRC32C implementations previously found at
Features/Ext4Pkg/Ext4Dxe/Crc{16,32c}.c to BaseLib.

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: Pedro Falcato <pedro.falcato@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
22 months agoMdePkg: Remove "assert" from SmmCpuRendevousLibNull.c
Zhihao Li [Wed, 18 May 2022 12:01:51 +0000 (20:01 +0800)]
MdePkg: Remove "assert" from SmmCpuRendevousLibNull.c

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

Some drivers will break down when they use
SmmWaitForAllProcessor() which from SmmCpuRendezvousLibNull.c.
Removing the code "ASSERT(False)" will make consumer
work normally if they keep default setting for sync mode.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Zhihao Li <zhihao.li@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
22 months agoRevert "OvmfPkg/Sec: fix stack switch"
Gerd Hoffmann [Fri, 10 Jun 2022 11:02:44 +0000 (19:02 +0800)]
Revert "OvmfPkg/Sec: fix stack switch"

This reverts commit ff36b2550f94dc5fac838cf298ae5a23cfddf204.

Has no effect because GCC_IA32_CC_FLAGS and GCC_X64_CC_FLAGS are unused.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoMpInitLib: Move the Above1Mb vector allocation to MpInitLibInitialize
Ray Ni [Sun, 8 May 2022 05:22:49 +0000 (13:22 +0800)]
MpInitLib: Move the Above1Mb vector allocation to MpInitLibInitialize

The AP vector consists of 2 parts:
1. the initial 16-bit code that should be under 1MB and page aligned.
2. the 32-bit/64-bit code that can be anywhere in the memory with any
   alignment.

The need of part #2 is because the memory under 1MB is temporary
"stolen" for use and will "give" back after all AP wake up. The range
of memory is not marked as code page in page table. CPU may trigger
exception as soon as NX is enabled.

The part #2 memory allocation can be done in the MpInitLibInitialize.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoMpInitLib: Only allocate below 1MB memory for 16bit code
Ray Ni [Sat, 7 May 2022 14:25:19 +0000 (22:25 +0800)]
MpInitLib: Only allocate below 1MB memory for 16bit code

Today's implementation allocates below 1MB memory for the 16bit, 32bit
and 64bit code.

But it's not necessary since now the 32bit and 64bit code run at high
memory no matter in PEI and DXE phase.

The patch simplifies the logic to remove the code that handles the
case when WakeupBufferHigh is 0.
It also reduce the memory foot print under 1MB by allocating
memory for 16bit code only.

MP_CPU_EXCHANGE_INFO is still under 1MB which is immediate
after the 16bit code.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoMpInitLib: Put SEV logic in separate file
Ray Ni [Sat, 7 May 2022 13:19:08 +0000 (21:19 +0800)]
MpInitLib: Put SEV logic in separate file

The patch does several simplifications:
1. Treat SwitchToRealProc as part of RendezvousFunnelProc.
   So the common logic in MpLib.c doesn't need to be aware of
   SwitchToRealProc.
   As a result, SwitchToRealSize/Offset are removed from
   MP_ASSEMBLY_ADDRESS_MAP.

2. Move SwitchToRealProc to AmdSev.nasm.
   All other assembly code in AmdSev.nasm is called through
   OneTimeCall.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Michael Roth <michael.roth@amd.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
22 months agoMpInitLib: remove unneeded global ASM_PFX
Ray Ni [Sat, 7 May 2022 12:34:36 +0000 (20:34 +0800)]
MpInitLib: remove unneeded global ASM_PFX

global in NASM file is used for symbols that are
referenced in C files.
Remove unneeded global keyword in NASM file.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoMpInitLib: Allocate code buffer for PEI phase
Ray Ni [Sat, 7 May 2022 09:10:49 +0000 (17:10 +0800)]
MpInitLib: Allocate code buffer for PEI phase

Today's implementation assumes PEI phase runs at 32bit so
the execution-disable feature is not applicable.
It's not always TRUE.
The patch allocates 32bit&64bit code buffer for PEI phase as well.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Add InitializeSeparateExceptionStacks
Ray Ni [Fri, 20 May 2022 11:12:35 +0000 (19:12 +0800)]
CpuException: Add InitializeSeparateExceptionStacks

Today InitializeCpuExceptionHandlersEx is called from three modules:
1. DxeCore (links to DxeCpuExceptionHandlerLib)
    DxeCore expects it initializes the IDT entries as well as
    assigning separate stacks for #DF and #PF.
2. CpuMpPei (links to PeiCpuExceptionHandlerLib)
   and CpuDxe (links to DxeCpuExceptionHandlerLib)
    It's called for each thread for only assigning separate stacks for
    #DF and #PF. The IDT entries initialization is skipped because
    caller sets InitData->X64.InitDefaultHandlers to FALSE.

Additionally, SecPeiCpuExceptionHandlerLib, SmmCpuExceptionHandlerLib
also implement such API and the behavior of the API is simply to initialize
IDT entries only.

Because it mixes the IDT entries initialization and separate stacks
assignment for certain exception handlers together, in order to know
whether the function call only initializes IDT entries, or assigns stacks,
we need to check:
1. value of InitData->X64.InitDefaultHandlers
2. library instance

This patch cleans up the code to separate the stack assignment to a new API:
InitializeSeparateExceptionStacks().

Only when caller calls the new API, the separate stacks are assigned.
With this change, the SecPei and Smm instance can return unsupported which
gives caller a very clear status.

The old API InitializeCpuExceptionHandlersEx() is removed in this patch.
Because no platform module is consuming the old API, the impact is none.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
22 months agoCpuException: Remove InitializeCpuInterruptHandlers
Ray Ni [Wed, 18 May 2022 09:51:21 +0000 (17:51 +0800)]
CpuException: Remove InitializeCpuInterruptHandlers

InitializeCpuExceptionHandlers() expects caller allocates IDT while
InitializeCpuInterruptHandlers() allocates 256 IDT entries itself.

InitializeCpuExceptionHandlers() fills max 32 IDT entries allocated
by caller. If caller allocates 10 entries, the API just fills 10 IDT
entries.

The inconsistency between the two APIs makes code hard to
unerstand and hard to share.

Because there is only one caller (CpuDxe) for
InitializeCpuInterruptHandler(), this patch updates CpuDxe driver
to allocates 256 IDT entries then call
InitializeCpuExceptionHandlers().

This is also a backward compatible change.

With this change, InitializeCpuInterruptHandlers() is removed
completely.

And InitializeCpuExceptionHandlers() fills max 32 entries for PEI
and SMM instance, max 256 entries for DXE instance.
Such behavior matches to the original one.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Avoid allocating page but using global variables
Ray Ni [Wed, 18 May 2022 06:45:37 +0000 (14:45 +0800)]
CpuException: Avoid allocating page but using global variables

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Init global variables in-place
Ray Ni [Wed, 18 May 2022 05:56:05 +0000 (13:56 +0800)]
CpuException: Init global variables in-place

Additionally removed two useless global variables:
"SPIN_LOCK  mDisplayMessageSpinLock" from SMM instance.
"UINTN mEnabledInterruptNum" from DXE instance.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Avoid allocating code pages for DXE instance
Ray Ni [Wed, 18 May 2022 05:44:24 +0000 (13:44 +0800)]
CpuException: Avoid allocating code pages for DXE instance

Today the DXE instance allocates code page and then copies the IDT
vectors to the allocated code page. Then it fixes up the vector number
in the IDT vector.

But if we update the NASM file to generate 256 IDT vectors, there is
no need to do the copy and fix-up.

A side effect is 4096 bytes (HOOKAFTER_STUB_SIZE * 256) is used for
256 IDT vectors while 32 IDT vectors only require 512 bytes without
this change, in following library instances:
1. 32bit SecPeiCpuExceptionHandlerLib and PeiCpuExceptionHandlerLib
2. 64bit PeiCpuExceptionHandlerLib

But considering the code logic simplification, 3.5K extra space is
not a big deal.
If 3.5K is too much, we can enhance the code further to generate 32
vectors for above mentioned library instances.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Acked-by: Eric Dong <eric.dong@intel.com>
22 months agoOvmfPkg/Sec: fix stack switch
Gerd Hoffmann [Wed, 8 Jun 2022 10:09:36 +0000 (18:09 +0800)]
OvmfPkg/Sec: fix stack switch

The ebp/rbp register can either be used for the frame pointer or
as general purpose register.  With gcc (and clang) this depends
on the -f(no-)omit-frame-pointer switch.

This patch updates tools_def.template to explicitly set the compiler
option and also add a define to allow conditionally compile code.

The new define is used to fix stack switching in TemporaryRamMigration.
The ebp/rbp must not be touched when the compiler can use it as general
purpose register.  With version 12 gcc starts actually using the
register, so changing it leads to firmware crashes in some
configurations.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3934
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: Delete SecMeasurementLibTdx
Min M Xu [Sun, 5 Jun 2022 01:02:48 +0000 (09:02 +0800)]
OvmfPkg: Delete SecMeasurementLibTdx

The feature of SecMeasurementLibTdx is replaced by SecTpmMeasurementLibTdx
(which is in SecurityPkg). So SecMeasurementLibTdx is deleted.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: Implement MeasureHobList/MeasureFvImage
Min M Xu [Sun, 5 Jun 2022 01:02:47 +0000 (09:02 +0800)]
OvmfPkg: Implement MeasureHobList/MeasureFvImage

MeasureHobList and MeasureFvImage once were implemented in
SecMeasurementTdxLib. The intention of this patch-set is to refactor
SecMeasurementTdxLib to be an instance of TpmMeasurementLib. So these
2 functions (MeasureHobList/MeasureFvImage) are moved to
PeilessStartupLib. This is because:
1. RTMR based trusted boot is implemented in Config-B (See below link)
2. PeilessStartupLib is designed for PEI-less boot and it is the right
   place to do the measurement for Hoblist and Config-FV.

Config-B: https://edk2.groups.io/g/devel/message/76367

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoSecurity: Add SecTpmMeasurementLibTdx
Min M Xu [Sun, 5 Jun 2022 01:02:46 +0000 (09:02 +0800)]
Security: Add SecTpmMeasurementLibTdx

SecTpmMeasurementLitTdx is an instance of TpmMeasurementLib. It is
designed to used in a Td guest. This lib measures and logs data, and
extendx the measurement result into a specific RTMR.

SecTpmMeasurementLibTdx is a refactored lib of
OvmfPkg/Library/SecMeasurementLibTdx and it just copies
GetMappedRtmrIndex/TdxMeasureAndLogData from that lib. At the end of
this patch-set SecMeasurementLibTdx will be deleted.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months ago.pytool: UncrustifyCheck: Set IgnoreFiles path relative to package path
Kun Qin [Mon, 6 Jun 2022 19:24:54 +0000 (12:24 -0700)]
.pytool: UncrustifyCheck: Set IgnoreFiles path relative to package path

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

`IgnoreFiles` tag is specified in the CI YAML files in each individual
packages. The current logic for UncrustifyCheck script bases specified
file paths from workspace, which requires the package name to be included
in each entry.

This change updates the ignore checking logic to be based on current
package path in order to reduce redundancy. It also keeps the consistency
of `IgnoreFiles` field other pytools such as SpellCheck and EccCheck.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
22 months agoBaseTools: Fix dependency issue in PcdValueInit
Jake Garver [Thu, 7 Apr 2022 16:59:03 +0000 (00:59 +0800)]
BaseTools: Fix dependency issue in PcdValueInit

The generated Makefile was missing a dependency.  This resulted in a
build-time race condition if the recursive make is multi-threaded and
shares job control.

Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
22 months agoOvmfPkg/IntelTdx: Enable RTMR based measurement and measure boot
Min Xu [Mon, 16 May 2022 07:42:23 +0000 (15:42 +0800)]
OvmfPkg/IntelTdx: Enable RTMR based measurement and measure boot

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

Enable RTMR based measurement and measure boot for Td guest.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg/IntelTdx: Add TdTcg2Dxe
Min Xu [Mon, 16 May 2022 07:42:22 +0000 (15:42 +0800)]
OvmfPkg/IntelTdx: Add TdTcg2Dxe

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

TdTcg2Dxe mimics the Security/Tcg/Tcg2Dxe. It does below tasks:
 - Set up and install CC_EVENTLOG ACPI table
 - Parse the GUIDed HOB (gCcEventEntryHobGuid) and create CC event log
 - Measure handoff tables, Boot##### variables etc
 - Measure Exit Boot Service failed
 - Install CcMeasurement Protocol

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoMdePkg: Define CC Measure EventLog ACPI Table
Min Xu [Mon, 16 May 2022 07:42:21 +0000 (15:42 +0800)]
MdePkg: Define CC Measure EventLog ACPI Table

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

TDVF set up an ACPI table (EFI_CC_EVENTLOG_ACPI_TABLE) to pass the
event-log information. The event log created by the TD owner contains
the hashes to reconstruct the MRTD and RTMR registers.

Please refer to Sec 4.3.3 in blow link:
https://www.intel.com/content/dam/develop/external/us/en/documents/
intel-tdx-guest-hypervisor-communication-interface-1.0-344426-002.pdf

Please be noted, the definition of EFI_CC_EVENTLOG_ACPI_TABLE is a
little different from the above document. This difference is based on
below discussion:
- https://edk2.groups.io/g/devel/message/87396
- https://edk2.groups.io/g/devel/message/87402

This change will be reflected in the next version of the above document.

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>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg: Add PCDs for LAML/LASA field in CC EVENTLOG ACPI table
Min Xu [Mon, 16 May 2022 07:42:20 +0000 (15:42 +0800)]
OvmfPkg: Add PCDs for LAML/LASA field in CC EVENTLOG ACPI table

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

Add PCDs to records LAML/LASA field in CC EVENTLOG ACPI table.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg/IntelTdx: Measure Td HobList and Configuration FV
Min Xu [Mon, 16 May 2022 07:42:19 +0000 (15:42 +0800)]
OvmfPkg/IntelTdx: Measure Td HobList and Configuration FV

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

TdHobList and Configuration FV are external data provided by Host VMM.
These are not trusted in Td guest. So they should be validated , measured
and extended to Td RTMR registers. In the meantime 2 EFI_CC_EVENT_HOB are
created. These 2 GUIDed HOBs carry the hash value of TdHobList and
Configuration FV. In DXE phase EFI_CC_EVENT can be created based on these
2 GUIDed HOBs.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg: Introduce SecMeasurementLib
Min Xu [Mon, 16 May 2022 07:42:18 +0000 (15:42 +0800)]
OvmfPkg: Introduce SecMeasurementLib

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

SecMeasurementLib is designed to do the measurement in SEC phase. In
current stage there are 2 functions introduced:
 - MeasureHobList: Measure the Hoblist passed from the VMM.
 - MeasureFvImage: Measure the FV image.

SecMeasurementLibTdx is the TDX version of the library.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoSecurityPkg: Add definition of EFI_CC_EVENT_HOB_GUID
Min Xu [Mon, 16 May 2022 07:42:17 +0000 (15:42 +0800)]
SecurityPkg: Add definition of EFI_CC_EVENT_HOB_GUID

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

EFI_CC_EVENT_HOB_GUID is the global ID of a GUIDed HOB used to pass
TDX_DIGEST_VALUE from SEC to a DXE Driver ( This DXE driver will
be introduced in the following commit in this patch-sets ). In that
DXE driver this GUIDed HOB will be parsed and the TDX_DIGEST_VALUE
then will be extracted. After that a EFI_CC_EVENT will be created
based on it.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoCryptoPkg: Add SecCryptLib
Min Xu [Mon, 16 May 2022 07:42:16 +0000 (15:42 +0800)]
CryptoPkg: Add SecCryptLib

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

This is the Cryptographic library instance for SEC. The motivation of
this library is to support SHA384 in SEC phase for Td guest. So only
Hash/CryptSha512.c is included which supports SHA384 and SHA512. Other
cryptographics are added with the null version, such as CryptMd5Null.c.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoSecurity: Add HashLibTdx
Min Xu [Mon, 16 May 2022 07:42:15 +0000 (15:42 +0800)]
Security: Add HashLibTdx

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

This library provides hash service by registered hash handler in Td
guest. Currently only SHA384 is supported. After that the hash value is
extended to Td RTMR registers which is similar to TPM PCRs.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg: Don't access A20 gate register on Cloud Hypervisor
Sebastien Boeuf [Tue, 10 May 2022 12:50:46 +0000 (20:50 +0800)]
OvmfPkg: Don't access A20 gate register on Cloud Hypervisor

Since Cloud Hypervisor doesn't emulate an A20 gate register on I/O port
0x92, it's better to avoid accessing it when the platform is identified
as Cloud Hypervisor.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: CloudHv: Rely on QemuFwCfgLibNull implementation
Sebastien Boeuf [Tue, 10 May 2022 12:50:45 +0000 (20:50 +0800)]
OvmfPkg: CloudHv: Rely on QemuFwCfgLibNull implementation

Since Cloud Hypervisor doesn't support the fw_cfg mechanism, it's more
appropriate to rely on QemuFwCfgLibNull implementation of QemuFwCfgLib
since it provides a null implementation that will not issue any PIO
accesses to ports 0x510 and 0x511.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: Check for QemuFwCfg availability before accessing it
Sebastien Boeuf [Tue, 10 May 2022 12:50:44 +0000 (20:50 +0800)]
OvmfPkg: Check for QemuFwCfg availability before accessing it

There are few places in the codebase assuming QemuFwCfg will be present
and supported, which can cause some issues when trying to rely on the
QemuFwCfgLibNull implementation of QemuFwCfgLib.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: CloudHv: Fix FW_BASE_ADDRESS
Sebastien Boeuf [Tue, 10 May 2022 12:50:43 +0000 (20:50 +0800)]
OvmfPkg: CloudHv: Fix FW_BASE_ADDRESS

The FW_BASE_ADDRESS value provided by OvmfPkgDefines.fdf.inc is
incorrect for the CloudHv target. We know the generated firmware
contains a PVH ELF header, meaning it will be loaded according to the
address provided through this header. And since we know this address
isn't going to change as it's part of CloudHvElfHeader.fdf.inc, we can
hardcode it through a new include file CloudHvDefines.fdf.inc, which
replaces the generic one OvmfPkgDefines.fdf.inc.

With this change, we prevent the firmware from accessing MMIO addresses
from the address range 0xffc00000-0xffffffff since we know the firmware
hasn't been loaded on this address range.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
22 months agoOvmfPkg/Microvm/pcie: add pcie support
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:16 +0000 (10:42 +0200)]
OvmfPkg/Microvm/pcie: add pcie support

Link in pcie and host bridge bits.  Enables support for PCIe in microvm
(qemu-system-x86_64 -M microvm,pcie=on).

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3777
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Microvm/pcie: mPhysMemAddressWidth tweak
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:15 +0000 (10:42 +0200)]
OvmfPkg/Microvm/pcie: mPhysMemAddressWidth tweak

microvm places the 64bit mmio space at the end of the physical address
space.  So mPhysMemAddressWidth must be correct, otherwise the pci host
bridge setup throws an error because it thinks the 64bit mmio window is
not addressable.

On microvm we can simply use standard cpuid to figure the address width
because the host-phys-bits option (-cpu ${name},host-phys-bits=on) is
forced to be enabled.  Side note: For 'pc' and 'q35' this is not the
case for backward compatibility reasons.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Microvm/pcie: no vbeshim please
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:14 +0000 (10:42 +0200)]
OvmfPkg/Microvm/pcie: no vbeshim please

Those old windows versions which need the vbeshim hack
will not run on microvm anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Platform: unfix PcdPciExpressBaseAddress
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:13 +0000 (10:42 +0200)]
OvmfPkg/Platform: unfix PcdPciExpressBaseAddress

Will be set by FdtPciHostBridgeLib, so it can't be an fixed when we
want use that library.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/FdtPciHostBridgeLib: io range is not mandatory
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:12 +0000 (10:42 +0200)]
OvmfPkg/FdtPciHostBridgeLib: io range is not mandatory

io range is not mandatory according to pcie spec,
so allow host bridges without io address space.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Microvm: drop CODE and VARS files
Gerd Hoffmann [Thu, 2 Jun 2022 09:35:23 +0000 (11:35 +0200)]
OvmfPkg/Microvm: drop CODE and VARS files

microvm doesn't support pflash and loads the firmware via -bios,
so we can't use the separate CODE and VARS files.  Remove them.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
22 months agoOvmfPkg/AmdSev: remove unused SMM bits from .dsc and .fdf files
Gerd Hoffmann [Thu, 2 Jun 2022 09:11:05 +0000 (11:11 +0200)]
OvmfPkg/AmdSev: remove unused SMM bits from .dsc and .fdf files

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Dov Murik <dovmurik@linux.ibm.com>
22 months agoOvmfPkg: Search EFI_RESOURCE_MEMORY_UNACCEPTED for Fw hoblist
Min Xu [Tue, 31 May 2022 14:31:17 +0000 (22:31 +0800)]
OvmfPkg: Search EFI_RESOURCE_MEMORY_UNACCEPTED for Fw hoblist

In current TDVF implementation all unaccepted memory passed in Hoblist
are tagged as EFI_RESOURCE_MEMORY_UNACCEPTED. They're all accepted before
they can be accessed. After accepting memory region, the Hob ResourceType
is unchanged (still be EFI_RESOURCE_MEMORY_UNACCEPTED).

TDVF Config-B skip PEI phase and it tries to find a memory region which
is the largest one below 4GB. Then this memory region will be used as the
firmware hoblist.

So we should walk thru the input hoblist and search for the memory region
with the type of EFI_RESOURCE_MEMORY_UNACCEPTED.

Because EFI_RESOURCE_MEMORY_UNACCEPTED has not been officially in PI spec.
So it cannot be defined in MdePkg/Include/Pi/PiHob.h. As a temporary
solution it is defined in Hob.c.

There is a patch-set for lazy-accept very soon. In that patch-set
EFI_RESOURCE_MEMORY_UNACCEPTED will be defined in MdeModulePkg.

Config-B: https://edk2.groups.io/g/devel/message/76367

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg: Fix TDVMCALL error in ApRunLoop.nasm
Min Xu [Tue, 31 May 2022 14:31:16 +0000 (22:31 +0800)]
OvmfPkg: Fix TDVMCALL error in ApRunLoop.nasm

According to GHCI Spec Table 2-1, in TDVMCALL R10 should be cleared
to 0 in input operands, and be checked for the return result.
https://cdrdv2.intel.com/v1/dl/getContent/726790

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/ResetVector: Removing SEV-ES CPUID bit check
Peter Gonda [Wed, 1 Jun 2022 12:17:45 +0000 (14:17 +0200)]
OvmfPkg/ResetVector: Removing SEV-ES CPUID bit check

The SEV-ES bit of Fn800-001F[EAX] - Bit 3 is used for a host to
determine support for running SEV-ES guests. It should not be checked by
a guest to determine if it is running under SEV-ES. The guest should use
the SEV_STATUS MSR Bit 1 to determine if SEV-ES is enabled. This check
was not part of the original SEV-ES support and was added in
a91b700e38. Removing the check makes this code consistent with the
Linux kernel

Fixes: a91b700e38 ("Ovmf/ResetVector: Simplify and consolidate the SEV features checks")
Signed-off-by: Peter Gonda <pgonda@google.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
23 months agoIntelFsp2WrapperPkg: FSP_TEMP_RAM_INIT call for X64 Calling Convention
Duggapu, Chinni B [Tue, 17 May 2022 08:44:01 +0000 (16:44 +0800)]
IntelFsp2WrapperPkg: FSP_TEMP_RAM_INIT call for X64 Calling Convention

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3926
Pass Input parameters using RCX.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Signed-off-by: cbduggap <chinni.b.duggapu@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Ted Kuo <ted.kuo@intel.com>
23 months agoIntelFsp2Pkg: FSP_TEMP_RAM_INIT call must follow X64 Calling Convention
Duggapu, Chinni B [Tue, 17 May 2022 08:44:00 +0000 (16:44 +0800)]
IntelFsp2Pkg: FSP_TEMP_RAM_INIT call must follow X64 Calling Convention

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3926
This API accept one parameter using RCX and this is consumed
in mutiple sub functions.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Signed-off-by: cbduggap <chinni.b.duggapu@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
23 months agoIntelFsp2Pkg: Add FSP 2.3 header support
Loo, Tung Lun [Wed, 11 May 2022 23:26:29 +0000 (07:26 +0800)]
IntelFsp2Pkg: Add FSP 2.3 header support

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

This patch adds a couple of fields supported in FSP 2.3 header from
both header generation and tool support perspective.

Signed-off-by: Loo Tung Lun <tung.lun.loo@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
23 months agoOvmfPkg/VirtioGpuDxe: replace struct copy with CopyMem call
Gerd Hoffmann [Mon, 30 May 2022 09:22:55 +0000 (11:22 +0200)]
OvmfPkg/VirtioGpuDxe: replace struct copy with CopyMem call

Buildfix for `-t CLANG38 -b NOOPT -p OvmfPkg/OvmfPkgX64.dsc`.

Fixes: 5f6ecaa398ba ("OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode")
Reported-by: Rebecca Cran <quic_rcran@quicinc.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
23 months agoUefiPayloadPkg: Align SpecRevision value with UPL spec
Gua Guo [Thu, 26 May 2022 09:37:44 +0000 (17:37 +0800)]
UefiPayloadPkg: Align SpecRevision value with UPL spec

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3933
URL: https://universalpayload.github.io/documentation/

1. Currently, SpecRevision on USF spec is 0.7. Change to align it.
2. SpecRevision is not be patched into UniversalPayloadInfo.bin due to
different structure item name. Change item name from "HeaderRevision"
 to "SpecRevision" to check the correct value can be patched.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
23 months agoUefiPayloadPkg: Align Identifier value with UPL spec
Gua Guo [Thu, 26 May 2022 01:05:39 +0000 (09:05 +0800)]
UefiPayloadPkg: Align Identifier value with UPL spec

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

URL: https://universalpayload.github.io/documentation/
Currently, Identifier value is "UPLD", it needs to have correct value
"PLDH" based on Universal Payload Specification spec section 2.12.2

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
23 months agoMdeModulePkg/UniversalPayload: Align Identifier value with UPL spec
Gua Guo [Thu, 26 May 2022 00:59:39 +0000 (08:59 +0800)]
MdeModulePkg/UniversalPayload: Align Identifier value with UPL spec

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

URL: https://universalpayload.github.io/documentation/
Currently, Identifier value is "UPLD", it needs to have correct value
"PLDH" based on Universal Payload Specification spec section 2.12.2

Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
23 months agoRemoved prefix to match AsmRelocateApMailBoxLoopStart edk2-stable202205
Theo Jehl [Thu, 26 May 2022 09:40:51 +0000 (17:40 +0800)]
Removed prefix to match AsmRelocateApMailBoxLoopStart

This fixes a compilation issue.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Jehl Theo <theojehl76@gmail.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Rebecca Cran <quic_rcran@quicinc.com>
Tested-by: Rebecca Cran <quic_rcran@quicinc.com>
23 months agoOvmfPkg: fix PcdFSBClock
Gerd Hoffmann [Mon, 23 May 2022 13:45:04 +0000 (21:45 +0800)]
OvmfPkg: fix PcdFSBClock

kvm FSB clock is 1GHz, not 100 MHz.  Timings are off by factor 10.
Fix all affected build configurations.  Not changed: Microvm and
Cloudhw (they have already have the correct value), and Xen (has
no fixed frequency, the PCD is configured at runtime by platform
initialization code).

Fixes: c37cbc030d96 ("OvmfPkg: Switch timer in build time for OvmfPkg")
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months agoOvmfPkg: TdxDxe: Fix AsmRelocateApMailBoxLoop
Isaku Yamahata [Tue, 24 May 2022 07:53:46 +0000 (15:53 +0800)]
OvmfPkg: TdxDxe: Fix AsmRelocateApMailBoxLoop

In TDX, Application Processor busy-loops on Mailbox for OS to issue
MpProtectedModeWakeupCommandWakeup command to UEFI.  As the AP acking to
it, it clears the command member according to ACPI spec 6.4, 5.2.12.19
Multiprocessor Wakeup Structure: "The application processor need clear the
command to Noop(0) as the acknowledgement that the command is received."
However, AsmRelocateApMailBoxLoop wrongly clears WakeupVector.  Correctly
clear command instead of WakeupVector.

Without this patch, TD guest kernel fails to boot APs.

Fixes: fae5c1464d ("OvmfPkg: Add TdxDxe driver")
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
23 months agoOvmfPkg: Make an Ia32/X64 hybrid build work with SEV
Tom Lendacky [Mon, 16 May 2022 20:24:02 +0000 (15:24 -0500)]
OvmfPkg: Make an Ia32/X64 hybrid build work with SEV

The BaseMemEncryptSevLib functionality was updated to rely on the use of
the OVMF/SEV workarea to check for SEV guests. However, this area is only
updated when running the X64 OVMF build, not the hybrid Ia32/X64 build.
Base SEV support is allowed under the Ia32/X64 build, but it now fails
to boot as a result of the change.

Update the ResetVector code to check for SEV features when built for
32-bit mode, not just 64-bit mode (requiring updates to both the Ia32
and Ia32X64 fdf files).

Fixes: f1d1c337e7c0575da7fd248b2dd9cffc755940df
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Michael Roth <michael.roth@amd.com>
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoOvmfPkg/OvmfPkgX64: Use different CcProbeLib when SMM is on or off
Min Xu [Wed, 18 May 2022 03:37:16 +0000 (11:37 +0800)]
OvmfPkg/OvmfPkgX64: Use different CcProbeLib when SMM is on or off

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

CcProbeLib is designed to check the vm guest type. The OvmfPkg/CcProbeLib
reads the OvmfWorkArea (0x80B000) to get the vm guest type which is
written by each guest (SEV or TDX guest). But in SMM drivers the access
to OvmfWorkArea is illegal. PiSmmCpuDxeSmm.inf is an example. It uses
IoLib which in OvmfPkgX64 BaseIoLibIntrinsicSev.inf is included. The
IoLib probes if the working guest is td guest by calling CcProbe().

So CcProbeLibNull will be included when SMM_REQUIRE is set. Currently
only TDVF uses CcProbe to check the guest type, and TDVF doesn't
support SMM, so this fix has no side-effect.

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Dann Frazier <dann.frazier@canonical.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Tested-by: dann frazier <dann.frazier@canonical.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
23 months agoUefiPayloadPkg: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:08:31 +0000 (16:08 -0400)]
UefiPayloadPkg: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Guo Dong <guo.dong@intel.com>
23 months agoOvmfPkg: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:05:38 +0000 (16:05 -0400)]
OvmfPkg: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
23 months agoEmulatorPkg: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:49:10 +0000 (16:49 -0400)]
EmulatorPkg: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Abner Chang <abner.chang@hpe.com>
23 months agoArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:02:13 +0000 (16:02 -0400)]
ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
Michael Kubacki [Wed, 6 Apr 2022 01:40:17 +0000 (21:40 -0400)]
MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info

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

Adds support to the UEFI variable fault tolerant write (FTW) drivers
to receive FTW base and size information dynamically via the Variable
Flash Information library.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg/Variable: Consume Variable Flash Info
Michael Kubacki [Wed, 6 Apr 2022 01:34:51 +0000 (21:34 -0400)]
MdeModulePkg/Variable: Consume Variable Flash Info

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

Updates VariableRuntimeDxe, VariableSmm, and VariableStandaloneMm
to acquire variable flash information from the Variable Flash
Information library.

Note: This introduces a dependency on VariableFlashInfoLib in these
modules. Therefore, a platform building the variable modules must
specify an instance of VariableFlashInfoLib in their platform build.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg/VariableFlashInfoLib: Add initial library
Michael Kubacki [Fri, 8 Apr 2022 15:53:29 +0000 (11:53 -0400)]
MdeModulePkg/VariableFlashInfoLib: Add initial library

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

Adds a new library class VariableFlashInfoLib that abstracts access
to variable flash information. The instance provided first attempts
to retrieve information from the Variable Flash Info HOB. If that
HOB is not present, it falls back to the PCDs defined in
MdeModulePkg.

This fall back behavior provides backward compatibility for platforms
that only provide PCDs but also allows platforms that need to
dynamically provide the information using the Variable Flash Info HOB
to do so at runtime.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg: Add Variable Flash Info HOB
Michael Kubacki [Wed, 6 Apr 2022 01:17:59 +0000 (21:17 -0400)]
MdeModulePkg: Add Variable Flash Info HOB

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

Adds a new GUID that is used to identify a HOB that passes variable
flash information to UEFI variable drivers in HOB consumption phases
such as DXE, Traditional MM, and Standalone MM.

This information was previously passed directly with PCDs such
as EfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
and gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize.

However, the Standalone MM variable driver instance does not have
direct access to the PCD database. Therefore, this HOB will first
be considered as the source for variable flash information and
if platforms do not produce the HOB, reading the information from
the PCDs directly will be a backup to provide backward
compatibility.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months ago.pytool/plugin/SpellCheck: Add more common words
Michael Kubacki [Tue, 17 May 2022 22:57:43 +0000 (18:57 -0400)]
.pytool/plugin/SpellCheck: Add more common words

Appends the word list to reduce the number of errors encountered
by individual packages.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months ago.pytool/plugin/SpellCheck: Allow compound words
Michael Kubacki [Tue, 17 May 2022 22:16:39 +0000 (18:16 -0400)]
.pytool/plugin/SpellCheck: Allow compound words

Sets "allowCompoundWords" to "true" to reduce the number of compound
word issues encountered in the future.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months ago.azurepipelines: Fix cspell version to v5.20.0
Michael Kubacki [Tue, 17 May 2022 21:54:36 +0000 (17:54 -0400)]
.azurepipelines: Fix cspell version to v5.20.0

The v5.21.0 update introduced a number of new issues that might
impact stable tag integration so this fixes the version to the
previous release.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This value can be revisited in the future to update the

23 months agoBaseTools: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:20 +0000 (02:48 +0800)]
BaseTools: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoOvmfPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:19 +0000 (02:48 +0800)]
OvmfPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoEmbeddedPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:18 +0000 (02:48 +0800)]
EmbeddedPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoArmVirtPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:17 +0000 (02:48 +0800)]
ArmVirtPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoNetworkPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:16 +0000 (02:48 +0800)]
NetworkPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoFatPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:15 +0000 (02:48 +0800)]
FatPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoMdePkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:14 +0000 (02:48 +0800)]
MdePkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoCryptoPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:13 +0000 (02:48 +0800)]
CryptoPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoArmPlatformPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:12 +0000 (02:48 +0800)]
ArmPlatformPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoArmPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:11 +0000 (02:48 +0800)]
ArmPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoUefiPayloadPkg: Connect all root bridge in PlatformBootManagerBeforeConsole
Liu, Zhiguang [Thu, 12 May 2022 10:54:59 +0000 (18:54 +0800)]
UefiPayloadPkg: Connect all root bridge in PlatformBootManagerBeforeConsole

Some ConIn or ConOut device may not in the first root bridge, so connect all
root bridge  before detect ConIn and ConOut device.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
23 months agoUefiPayloadPkg: Add Serial IO device path according to related protocol
Liu, Zhiguang [Thu, 12 May 2022 10:54:58 +0000 (18:54 +0800)]
UefiPayloadPkg: Add Serial IO device path according to related protocol

Current code follow some rules to check if the PCI device connected to a
serial port device, but some platform or hardware doesn't follow such rule.
By locating gEfiSerialIoProtocolGuid protocol, we can find the related
device path.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
23 months agoUefiPayloadPkg: Simplify code logic
Liu, Zhiguang [Thu, 12 May 2022 10:54:57 +0000 (18:54 +0800)]
UefiPayloadPkg: Simplify code logic

A little overdesign about VisitAllPciInstances function, since there are
two call back functions. Simplify the code logic by combining the two call
back functions, and unused parameters.
Change the PROTOCOL_INSTANCE_CALLBACK to SIMPLE_PROTOCOL_INSTANCE_CALLBACK
because the former is also defined in OvmfPkg. Rename it to avoid confusion.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>