]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
16 months agoEmulatorPkg/RedfishHostInterface: Add NULL function
Abner Chang [Mon, 19 Dec 2022 13:18:20 +0000 (21:18 +0800)]
EmulatorPkg/RedfishHostInterface: Add NULL function

Add NULL function
RedfishPlatformHostInterfaceNotification that returns
EFI_UNSUPPORTED.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
16 months agoRedfishPkg/RedfishHostInterface: Platform Redfish HI notification
Abner Chang [Mon, 19 Dec 2022 13:18:00 +0000 (21:18 +0800)]
RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

For some use cases, Redfish host interface table relies on
the certain EFI protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the
SMBIOS type 42h record at driver entry point. This patch adds
the mechanism in Redfish host interface DXE driver to listen
to EFI protocol installed by platform library that indicates
the necessary information is ready for building SMBIOS 42h
record.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
16 months agoOvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore
Chun-Yi Lee [Thu, 15 Dec 2022 14:27:23 +0000 (22:27 +0800)]
OvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore

In the commit 4f173db8b4 "OvmfPkg/PlatformInitLib: Add functions for
EmuVariableNvStore", it introduced a PlatformValidateNvVarStore() function
for checking the integrity of NvVarStore.

In some cases when the VariableHeader->StartId is VARIABLE_DATA, the
VariableHeader->State is not just one of the four primary states:
VAR_IN_DELETED_TRANSITION, VAR_DELETED, VAR_HEADER_VALID_ONLY, VAR_ADDED.
The state may combined two or three states, e.g.

    0x3C = (VAR_IN_DELETED_TRANSITION & VAR_ADDED) & VAR_DELETED
or
    0x3D = VAR_ADDED & VAR_DELETED

When the variable store has those variables, system booting/rebooting will
hangs in a ASSERT:

NvVarStore Variable header State was invalid.
ASSERT
/mnt/working/source_code-git/edk2/OvmfPkg/Library/PlatformInitLib/Platform.c(819):
((BOOLEAN)(0==1))

Adding more log to UpdateVariable() and PlatformValidateNvVarStore(), we
saw some variables which have 0x3C or 0x3D state in store.
e.g.

UpdateVariable(), VariableName=BootOrder
L1871, State=0000003F        <-- VAR_ADDED
State &= VAR_DELETED=0000003D
FlushHobVariableToFlash(), VariableName=BootOrder
...
UpdateVariable(), VariableName=InitialAttemptOrder
L1977, State=0000003F
State &= VAR_IN_DELETED_TRANSITION=0000003E
L2376, State=0000003E
State &= VAR_DELETED=0000003C
FlushHobVariableToFlash(), VariableName=InitialAttemptOrder
...
UpdateVariable(), VariableName=ConIn
L1977, State=0000003F
State &= VAR_IN_DELETED_TRANSITION=0000003E
L2376, State=0000003E
State &= VAR_DELETED=0000003C
FlushHobVariableToFlash(), VariableName=ConIn
...

So, only allowing the four primary states is not enough. This patch changes
the falid states list (Follow Jiewen Yao's suggestion):

1. VAR_HEADER_VALID_ONLY (0x7F)
    - Header added (*)
2. VAR_ADDED (0x3F)
    - Header + data added
3. VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
    - marked as deleted, but still valid, before new data is added. (*)
4. VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
    - deleted, after new data is added.
5. VAR_ADDED & VAR_DELETED (0x3D)
    - deleted directly, without new data.
(*) means to support surprise shutdown.

And removed (VAR_IN_DELETED_TRANSITION) and (VAR_DELETED) because they are
invalid states.

v2:
Follow Jiewen Yao's suggestion to add the following valid states:
    VAR_ADDED & VAR_DELETED (0x3D)
    VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
    VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
and removed the following invalid states:
    VAR_IN_DELETED_TRANSITION
    VAR_DELETED

Signed-off-by: Chun-Yi Lee <jlee@suse.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoUefiPayloadPkg: Define default values for the DynamicEX PCDs
jdzhang [Mon, 19 Dec 2022 11:59:42 +0000 (19:59 +0800)]
UefiPayloadPkg: Define default values for the DynamicEX PCDs

The following PCDs have no value in UefiPayloadPkg.dsc
and they can not pass the Ecc tool check, so assign
the default values the same as they are in *.dec file.
1. gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport
2. gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport
3. gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSuppor
4. gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSystemPageSize
5. gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds
6. gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode
7. gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress
8. gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize

Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: jdzhang <jdzhang@kunluntech.com.cn>
16 months agoCryptoPkg: Need to enable crypto functions
Judah Vang [Mon, 7 Nov 2022 22:15:53 +0000 (06:15 +0800)]
CryptoPkg: Need to enable crypto functions

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

V1: Enable CryptAes for PEI phase. Enable CryptHkdf for SMM phase.
    Update Readme.md

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Nishant C Mistry <nishant.c.mistry@intel.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Nishant C Mistry <nishant.c.mistry@intel.com>
Signed-off-by: Judah Vang <judah.vang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoDynamicTablesPkg: Allow for specified CPU names
Jeff Brasen [Mon, 7 Nov 2022 15:57:11 +0000 (08:57 -0700)]
DynamicTablesPkg: Allow for specified CPU names

Allow object to specify the name of processor and processor container
nodes and the UID of processor containers.

This allows these to be more accurately referenced from other tables.
For example for the _PSL method or the UID in the APMT table.

The UID and Name for processor container may be different as if the
intention is to set names as the corresponding affinity level the UID
may need to be different if there are multiple levels of containers.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoUefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV
MarsX Lin [Mon, 19 Dec 2022 02:50:05 +0000 (10:50 +0800)]
UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV

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

Since UefiPayload had supported multiple fv,
move bdsdxe.inf to new firmware volume and
modify the script of UniversalPayloadPkgBuild.py to
support bdsdxe fv in elf file

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: MarsX Lin <marsx.lin@intel.com>
16 months agoMdeModulePkg: Supporting S3 in 64bit PEI
Kuo, Ted [Fri, 16 Dec 2022 12:46:27 +0000 (20:46 +0800)]
MdeModulePkg: Supporting S3 in 64bit PEI

https://bugzilla.tianocore.org/show_bug.cgi?id=4195
Transfer from DXE to OS waking vector by calling SwitchStack() when
both are in the same execution mode.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
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>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
16 months agoUefiCpuPkg: Supporting S3 in 64bit PEI
Kuo, Ted [Fri, 16 Dec 2022 12:46:26 +0000 (20:46 +0800)]
UefiCpuPkg: Supporting S3 in 64bit PEI

https://bugzilla.tianocore.org/show_bug.cgi?id=4195
1.Updated the GDT table in VTF0 to align with the one in S3Resume2Pei.
  By doing so can simplify the changes to enable S3 in 64bit PEI.
2.Use SwitchStack() between PEI and SMM in S3 resume path when both
  are in the same execution mode.
3.Transfer from PEI to OS waking vector by calling SwitchStack() when
  both are in the same execution mode.
4.Removed the debug assertion in S3Resume.c to support 64bit PEI.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
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>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
16 months agoMaintainers: Update OvmfPkg/IoMmuDxe
Min M Xu [Thu, 15 Dec 2022 05:18:10 +0000 (13:18 +0800)]
Maintainers: Update OvmfPkg/IoMmuDxe

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

AmdSevIoMmu.* is renamed as CcIoMmu*. The related section in
Maintainers.txt should be updated as well.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
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>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/IoMmuDxe: Add SEV support for reserved shared memory
Tom Lendacky [Thu, 15 Dec 2022 05:18:09 +0000 (13:18 +0800)]
OvmfPkg/IoMmuDxe: Add SEV support for reserved shared memory

Add support to use the reserved shared memory within the IoMmu library.
This improves boot times for all SEV guests, with SEV-SNP benefiting the
most as it avoids the page state change call to the hypervisor.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/IoMmuDxe: Rename AmdSevIoMmu to CcIoMmu
Min M Xu [Thu, 15 Dec 2022 05:18:08 +0000 (13:18 +0800)]
OvmfPkg/IoMmuDxe: Rename AmdSevIoMmu to CcIoMmu

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

IoMmuDxe once was designed to support DMA operation when SEV is enabled.
After TDX is enabled in IoMmuDxe, some files' name in IoMmuDxe need to
be more general. So this patch rename:
  AmdSevIoMmu.h -> CcIoMmu.h
  AmdSevIoMmu.c -> CcIoMmu.c

Accordingly there are some udates in IoMmuDxe.c and IoMmuDxe.inf.

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>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/IoMmuDxe: Reserve shared memory region for DMA operation
Min M Xu [Thu, 15 Dec 2022 05:18:07 +0000 (13:18 +0800)]
OvmfPkg/IoMmuDxe: Reserve shared memory region for DMA operation

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

A typical QEMU fw_cfg read bytes with IOMMU for td guest is that:
(QemuFwCfgReadBytes@QemuFwCfgLib.c is the example)
1) Allocate DMA Access buffer
2) Map actual data buffer
3) start the transfer and wait for the transfer to complete
4) Free DMA Access buffer
5) Un-map actual data buffer

In step 1/2, Private memories are allocated, converted to shared memories.
In Step 4/5 the shared memories are converted to private memories and
accepted again. The final step is to free the pages.

This is time-consuming and impacts td guest's boot perf (both direct boot
and grub boot) badly.

In a typical grub boot, there are about 5000 calls of page allocation and
private/share conversion. Most of page size is less than 32KB.

This patch allocates a memory region and initializes it into pieces of
memory with different sizes. A piece of such memory consists of 2 parts:
the first page is of private memory, and the other pages are shared
memory. This is to meet the layout of common buffer.

When allocating bounce buffer in IoMmuMap(), IoMmuAllocateBounceBuffer()
is called to allocate the buffer. Accordingly when freeing bounce buffer
in IoMmuUnmapWorker(), IoMmuFreeBounceBuffer() is called to free the
bounce buffer. CommonBuffer is allocated by IoMmuAllocateCommonBuffer
and accordingly freed by IoMmuFreeCommonBuffer.

This feature is tested in Intel TDX pre-production platform. It saves up
to hundreds of ms in a grub boot.

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>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:46:43 +0000 (11:46 -0500)]
OvmfPkg: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

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: Sean Brogan <sean.brogan@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>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
16 months agoEmulatorPkg: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:46:26 +0000 (11:46 -0500)]
EmulatorPkg: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@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>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoBaseTools: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:46:09 +0000 (11:46 -0500)]
BaseTools: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Sean Brogan <sean.brogan@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>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoArmVirtPkg: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:45:33 +0000 (11:45 -0500)]
ArmVirtPkg: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

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: Sean Brogan <sean.brogan@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>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months ago.pytool/Readme.md: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:45:13 +0000 (11:45 -0500)]
.pytool/Readme.md: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Sean Brogan <sean.brogan@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>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoOvmfPkg/AcpiPlatformDxe: Differentiate TDX case for Cloud Hypervisor
Sebastien Boeuf [Thu, 15 Dec 2022 15:10:04 +0000 (23:10 +0800)]
OvmfPkg/AcpiPlatformDxe: Differentiate TDX case for Cloud Hypervisor

Rely on CcProbe() to identify when running on TDX so that ACPI tables
can be retrieved differently for Cloud Hypervisor. Instead of relying on
the PVH structure to find the RSDP pointer, the tables are individually
passed through the HOB.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/PlatformInitLib: Transfer GUID Extension HOB
Sebastien Boeuf [Thu, 15 Dec 2022 15:10:03 +0000 (23:10 +0800)]
OvmfPkg/PlatformInitLib: Transfer GUID Extension HOB

This is required for passing the ACPI tables from the VMM up to the
guest OS. They are transferred through this GUID extension.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/PlatformInitLib: Differentiate TDX case for Cloud Hypervisor
Sebastien Boeuf [Thu, 15 Dec 2022 15:10:02 +0000 (23:10 +0800)]
OvmfPkg/PlatformInitLib: Differentiate TDX case for Cloud Hypervisor

Rely on the CcProbe() function to identify when running on TDX. This
allows the firmware to follow a different codepath for Cloud Hypervisor,
which means it doesn't rely on PVH to find out about memory below 4GiB.
instead it falls back onto the CMOS to retrieve that information.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/AmdSev/SecretDxe: Allocate secret location as EfiACPIReclaimMemory
Dov Murik [Thu, 15 Dec 2022 13:11:51 +0000 (13:11 +0000)]
OvmfPkg/AmdSev/SecretDxe: Allocate secret location as EfiACPIReclaimMemory

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

Commit 079a58276b98 ("OvmfPkg/AmdSev/SecretPei: Mark SEV launch secret
area as reserved") marked the launch secret area itself (1 page) as
reserved so the guest OS can use it during the lifetime of the OS.
However, the address and size of the secret area held in the
CONFIDENTIAL_COMPUTING_SECRET_LOCATION struct are declared as STATIC in
OVMF (in AmdSev/SecretDxe); therefore there's no guarantee that it will
not be written over by OS data.

Fix this by allocating the memory for the
CONFIDENTIAL_COMPUTING_SECRET_LOCATION struct with the
EfiACPIReclaimMemory memory type to ensure the guest OS will not reuse
this memory.

Fixes: 079a58276b98 ("OvmfPkg/AmdSev/SecretPei: Mark SEV launch secret ...")
Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: Validate SEC's GHCB page
Adam Dunlap [Fri, 9 Dec 2022 21:04:16 +0000 (05:04 +0800)]
OvmfPkg/PlatformPei: Validate SEC's GHCB page

When running under SEV-ES, a page of shared memory is allocated for the
GHCB during the SEC phase at address 0x809000. This page of memory is
eventually passed to the OS as EfiConventionalMemory. When running
SEV-SNP, this page is not PVALIDATE'd in the RMP table, meaning that if
the guest OS tries to access the page, it will think that the host has
voilated the security guarantees and will likely crash.

This patch validates this page immediately after EDK2 switches to using
the GHCB page allocated for the PEI phase.

This was tested by writing a UEFI application that reads to and writes
from one byte of each page of memory and checks to see if a #VC
exception is generated indicating that the page was not validated.

Fixes: 6995a1b79bab ("OvmfPkg: Create a GHCB page for use during Sec phase")
Signed-off-by: Adam Dunlap <acdunlap@google.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/SecTpmMeasurementLib: Fix the mapping error of PCR and RTMR index
Min M Xu [Wed, 14 Dec 2022 07:14:19 +0000 (15:14 +0800)]
OvmfPkg/SecTpmMeasurementLib: Fix the mapping error of PCR and RTMR index

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

TDVF has the feature to do RTMR measurement in SEC phase. In the same time
it builds a GUID hob which carries the hash value of the measurement so
that in DXE phase a td event can be created based on this GUID Hob. There
is a mapping error between TPM PCR index and RTMR index according to UEFI
2.10. That PCR6 is missing in the mapping. This patch fixes this issue.

Cc: Erdem Aktas <erdemaktas@google.com> [ruleof2]
Cc: James Bottomley <jejb@linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao@intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky@amd.com> [tlendacky]
Cc: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/TdTcg2Dxe: Fix the mapping error between PCR index and MR index
Min M Xu [Wed, 14 Dec 2022 07:14:18 +0000 (15:14 +0800)]
OvmfPkg/TdTcg2Dxe: Fix the mapping error between PCR index and MR index

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

According to UEFI Spec 2.10 it is supposed to return the mapping from PCR
index to CC MR index:
//
// In the current version, we use the below mapping for TDX:
//
// TPM PCR Index | CC Measurement Register Index | TDX-measurement register
// -----------------------------------------------------------------------
// 0             |   0                           |   MRTD
// 1, 7          |   1                           |   RTMR[0]
// 2~6           |   2                           |   RTMR[1]
// 8~15          |   3                           |   RTMR[2]

In the current implementation TdMapPcrToMrIndex returns the index of RTMR,
not the MR index.

After fix the spec unconsistent, other related codes are updated
accordingly.
1) The index of event log uses the input MrIndex.
2) MrIndex is decreated by 1 before it is sent for RTMR extending.

Cc: Erdem Aktas <erdemaktas@google.com> [ruleof2]
Cc: James Bottomley <jejb@linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao@intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky@amd.com> [tlendacky]
Cc: Arti Gupta <ARGU@microsoft.com>
Reported-by: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/TdTcg2Dxe: Fix incorrect protocol and structure version
Min M Xu [Wed, 14 Dec 2022 07:14:17 +0000 (15:14 +0800)]
OvmfPkg/TdTcg2Dxe: Fix incorrect protocol and structure version

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

According to the Uefi spec 2.10 Section 38.2.2.
EFI_CC_MEASUREMENT_PROTOCOL.GetCapability, the minor version of
StructureVersion and ProtocolVersion should be 0.

Cc: Erdem Aktas <erdemaktas@google.com> [ruleof2]
Cc: James Bottomley <jejb@linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao@intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky@amd.com> [tlendacky]
Cc: Arti Gupta <ARGU@microsoft.com>
Reported-by: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoUnitTestFrameworkPkg/UnitTestLib: Print expected Status on ASSERT fail
devel@edk2.groups.io [Wed, 30 Nov 2022 23:02:15 +0000 (15:02 -0800)]
UnitTestFrameworkPkg/UnitTestLib: Print expected Status on ASSERT fail

Update the UnitTestAssertStatusEqual error message to print out the
expected value in addition to the seen value.

Signed-off-by: Jeshua Smith <jeshuas@nvidia.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
16 months agoOvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:09 +0000 (14:10 +0100)]
OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported

Remove global variables, store the state in PlatformInfoHob instead.
Probing for fw_cfg happens on first use, at library initialization
time the Hob might not be present yet.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/QemuFwCfgLib: rewrite fw_cfg probe
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:08 +0000 (14:10 +0100)]
OvmfPkg/QemuFwCfgLib: rewrite fw_cfg probe

Move the code to a new QemuFwCfgProbe() function.  Use direct Io*() calls
instead of indirect QemuFwCfg*() calls to make sure we don't get
recursive calls.  Also simplify CC guest detection.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/DebugLibIoPort: use Rom version for PEI
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:07 +0000 (14:10 +0100)]
OvmfPkg/DebugLibIoPort: use Rom version for PEI

This variant does not use global variables.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: remove mFeatureControlValue
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:06 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: remove mFeatureControlValue

Use PlatformInfoHob->FeatureControlValue instead.
OnMpServicesAvailable() will find PlatformInfoHob using
GetFirstGuidHob() and pass a pointer to the WriteFeatureControl
callback.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: remove mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:05 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: remove mPlatformInfoHob

Stop using the mPlatformInfoHob global variable.  Let
BuildPlatformInfoHob() allocate and return PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: Verification: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:04 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: Verification: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in S3Verification() and
Q35BoardVerification() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: NoExec: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:03 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: NoExec: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in NoexecDxeInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: MemTypeInfo: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:02 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: MemTypeInfo: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in MemTypeInfoInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:01 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in PublishPeiMemory()
and GetPeiMemoryCap() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei Q35 SMM helpers: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:00 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei Q35 SMM helpers: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in
Q35TsegMbytesInitialization() and
Q35SmramAtDefaultSmbaseInitialization() ) functions.
Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: PeiFv: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:09:59 +0000 (14:09 +0100)]
OvmfPkg/PlatformPei: PeiFv: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in PeiFvInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: AmdSev: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:09:58 +0000 (14:09 +0100)]
OvmfPkg/PlatformPei: AmdSev: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in AmdSevInitialize()
and AmdSevEsInitialize() functions.  Pass a pointer to the
PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoDynamicTablesPkg: SSDT _LPI revision is incorrect
Jeff Brasen [Tue, 15 Nov 2022 18:01:06 +0000 (11:01 -0700)]
DynamicTablesPkg: SSDT _LPI revision is incorrect

_LPI Revision should be 0 per the ACPI 6.5 specification.
"The revision number of the _LPI object. Current revision is 0."

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoMdePkg/UnitTestHostBaseLib: Remove HOST_APPLICATION limitation
Liu, Zhiguang [Wed, 7 Dec 2022 01:36:47 +0000 (09:36 +0800)]
MdePkg/UnitTestHostBaseLib: Remove HOST_APPLICATION limitation

Remove HOST_APPLICATION limitation for UnitTestHostBaseLib, so that
this library can be used as BaseLib by Emulator.
Also, add some missing files

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoUnitTestFrameworkPkg: Modify APIs in UnitTestPersistenceLib
Liu, Zhiguang [Tue, 6 Dec 2022 05:25:43 +0000 (13:25 +0800)]
UnitTestFrameworkPkg: Modify APIs in UnitTestPersistenceLib

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

UnitTestPersistenceLib now consumes private struct definition.
Modify APIs in UnitTestPersistenceLib to make it easy to become
a public library.

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoMdePkg/BaseCpuLib: Remove assembly for CpuFlushTlb
Liu, Zhiguang [Mon, 12 Dec 2022 07:30:22 +0000 (15:30 +0800)]
MdePkg/BaseCpuLib: Remove assembly for CpuFlushTlb

For different compilers, both IA32 and X64 can use
Ia32/CpuFlushTlbGcc.c, which is C code (no inline assembly code).
To simplify, remove other assemly file for CpuFlushTlb,
and rename Ia32/CpuFlushTlbGcc.c to X86CpuFlushTlb.c.

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoMaintainers.txt: Change Anthony's github id
Anthony PERARD [Fri, 16 Sep 2022 15:30:55 +0000 (08:30 -0700)]
Maintainers.txt: Change Anthony's github id

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
16 months agoShellPkg/Shell: Do not set end device path if already end
Michael D Kinney [Fri, 9 Dec 2022 15:53:21 +0000 (07:53 -0800)]
ShellPkg/Shell: Do not set end device path if already end

Update Shell Protocol EfiShellGetMapFromDevicePath() to not
set the end if the device path if it is already an end of
entire device path.  This removes a write operation that can
cause failures if the Device Path Protocol is mapped to
read-only memory.  In general Device Path Protocols should not
be modified unless the API explicitly states that the device
path is modified.

Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
16 months agoShellPkg/AcpiView: APMT Parser
Jeff Brasen [Fri, 4 Nov 2022 16:04:48 +0000 (10:04 -0600)]
ShellPkg/AcpiView: APMT Parser

Add a new parser for the Arm Performance Monitoring Unit Table.
The APMT table describes the properties of PMU support
implemented by components in an Arm-based system.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoMdePkg/IndustryStandard: add definitions for ACPI APMT
Jeff Brasen [Fri, 4 Nov 2022 16:04:47 +0000 (10:04 -0600)]
MdePkg/IndustryStandard: add definitions for ACPI APMT

This adds #defines and struct typedefs for the various node types in
the  ACPI Arm Performance Monitoring Unit (APMT) table.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoDynamicTablesPkg: Remove duplicated words
Pierre Gondois [Tue, 6 Sep 2022 08:28:59 +0000 (10:28 +0200)]
DynamicTablesPkg: Remove duplicated words

In an effort to clean the documentation of the above
package, remove duplicated words.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoMdeModulePkg: SdMmcPciHcDxe: Fix issue that SD1.0 cards can't be recognized
Chevron Li (WH) [Wed, 7 Dec 2022 11:08:39 +0000 (19:08 +0800)]
MdeModulePkg: SdMmcPciHcDxe: Fix issue that SD1.0 cards can't be recognized

SD1.0 cards don't support CMD8 and CMD6
CMD8 result can be used to distinguish the card is SD1.0 or not.
CMD8 result can be used to decide following CMD6 is sent or skip.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Chevron Li <chevron.li@bayhubtech.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
16 months agoMdeModulePkg/Ata: Fix command status reporting
Albecki, Mateusz [Tue, 18 Oct 2022 15:54:19 +0000 (23:54 +0800)]
MdeModulePkg/Ata: Fix command status reporting

Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4016

AtaAtapiPassThru driver was reporting recovery status on failed command
packets which led to incorrect flows in upper layers and to SCT tests
fails. This commit will change the logic to report command status.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
16 months agoOvmfPkg/SmbiosPlatformDxe: use PcdFirmware*
Gerd Hoffmann [Mon, 28 Nov 2022 05:40:20 +0000 (13:40 +0800)]
OvmfPkg/SmbiosPlatformDxe: use PcdFirmware*

Instead of using hard-coded strings ("0.0.0" for BiosVersion etc)
which is mostly useless read the PCDs (PcdFirmwareVendor,
PcdFirmwareVersionString and PcdFirmwareReleaseDateString) and
build the string table dynamuically at runtime.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agomv OvmfPkg: move fdf include snippets to Include/Fdf
Gerd Hoffmann [Fri, 9 Dec 2022 13:03:48 +0000 (21:03 +0800)]
mv OvmfPkg: move fdf include snippets to Include/Fdf

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: move dsc include snippet for Network support to Include/Dsc
Gerd Hoffmann [Fri, 9 Dec 2022 13:03:47 +0000 (21:03 +0800)]
OvmfPkg: move dsc include snippet for Network support to Include/Dsc

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: move dsc and fdf include snippets for TPM support to subdirs
Gerd Hoffmann [Fri, 9 Dec 2022 13:03:46 +0000 (21:03 +0800)]
OvmfPkg: move dsc and fdf include snippets for TPM support to subdirs

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: Add INVD case in #VE handler
Ryan Afranji [Thu, 8 Dec 2022 00:51:15 +0000 (08:51 +0800)]
OvmfPkg: Add INVD case in #VE handler

According to the Intel GHCI specification document section 2.4.1, the
goal for instructions that do not have a corresponding TDCALL is for the
handler to treat the instruction as a NOP.

INVD does not have a corresponding TDCALL. This patch makes the #VE
handler treat INVD as a NOP.

Signed-off-by: Ryan Afranji <afranji@google.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoMdeModulePkg/DxeCore: Use correct type for alignment mask
Ard Biesheuvel [Wed, 7 Dec 2022 17:49:45 +0000 (18:49 +0100)]
MdeModulePkg/DxeCore: Use correct type for alignment mask

The page allocator code in CoreFindFreePagesI() uses a mask derived from
its UINTN Alignment argument to align the descriptor end address of a
MEMORY_MAP entry to the requested alignment, in order to check whether
the descriptor covers enough sufficiently aligned area to satisfy the
request.

However, on 32-bit architectures, 'Alignment' is a 32-bit type, whereas
DescEnd is a 64-bit type, and so the resulting operation performed on
the end address comes down to masking with 0xfffff000 instead of the
intended 0xffffffff_fffff000. Given the -1 at the end of the expression,
the resulting address is 0xffffffff_fffffffff for any descriptor that
ends on a 4G aligned boundary, and this is certainly not what was
intended.

So cast Alignment to UINT64 to ensure that the mask has the right size.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
16 months agoEmulatorPkg: Record Argc, Argv and Envp in EmuThunk Ppi
Liu, Zhiguang [Tue, 6 Dec 2022 05:41:36 +0000 (13:41 +0800)]
EmulatorPkg: Record Argc, Argv and Envp in EmuThunk Ppi

Record Argc, Argv and Envp in EmuThunk Ppi so that other modules
can use these fields to change behavior depends on boot parameters
or environment.

Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoEmulatorPkg: Remove unnecessary dependency on EmbeddedPkg
Liu, Zhiguang [Tue, 6 Dec 2022 05:30:18 +0000 (13:30 +0800)]
EmulatorPkg: Remove unnecessary dependency on EmbeddedPkg

EmulatorPkg doesn't need depend on EmbeddedPkg, so remove the dependency.

Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoEmulatorPkg: Add persistent memory in EmuThunkPpi
Liu, Zhiguang [Tue, 6 Dec 2022 05:40:52 +0000 (13:40 +0800)]
EmulatorPkg: Add persistent memory in EmuThunkPpi

The persistent memory is for PEIM to use, and won't lose during cold
or warm reset. PcdPersistentMemorySize is only used by WinHost.c,
other modules can check the persistent memory size using the field
PersistentMemorySize.

Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoUefiCpuPkg: Bug fix in 5LPage handling
Robert Guenzel [Thu, 8 Dec 2022 08:44:15 +0000 (16:44 +0800)]
UefiCpuPkg: Bug fix in 5LPage handling

When build in DEBUG, the code asserts that 5LPage support is there
when the physical address width is larger than 48.
In a RELEASE build it will just force LA57 to 1 in CR4
even if CPUID(7).ECX[16] says it is not supported.

UefiCpuPkg: Bug fix in 5LPage handling

The hang (in the ASSERT) in DEBUG is not warranted as there are
legal configurations with CPUID(7).ECX[16](==LA57)=0
and with a physical address width of larger than 48 (like 52).

This is also supported by this code:
https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c#L221
There (as long as physical address width is smaller or equal to 52)
any address width above 48 will be reduced to 48 and the
system can and will work without 5LPaging.

The forced setting of LA57 in CR4 (in the absence of LA57 in CPUID(7).ECX)
is a spec violation and should not happen.

Hence the proposed fix
a) removes the assert.
b) only returns TRUE from Is5LevelPagingNeeded if 5LPaging is actually
   supported by HW.

Signed-off-by: Robert Guenzel <robert.guenzel@intel.com>
16 months agoUefiCpuPkg: Check SMM Delayed/Blocked AP Count
Wu, Jiaxin [Wed, 30 Nov 2022 05:13:56 +0000 (13:13 +0800)]
UefiCpuPkg: Check SMM Delayed/Blocked AP Count

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

Due to more core count increasement, it's hard to reflect all APs
state via AP bitvector support in the register. Actually, SMM CPU
driver doesn't need to check each AP state to know all CPUs in SMI
or not, one alternative method is to check the SMM Delayed & Blocked
AP Count number:

APs in SMI + Blocked Count + Disabled Count >= All supported Aps
(code comments explained why can be > All supported Aps)

With above change, the returned value of "SmmRegSmmEnable" &
"SmmRegSmmDelayed" & "SmmRegSmmBlocked" from SmmCpuFeaturesLib
should be the AP count number within the existing CPU package.

For register that return the bitvector state, require
SmmCpuFeaturesGetSmmRegister() returns count number of all bit per
logical processor within the same package.

For register that return the AP count, require
SmmCpuFeaturesGetSmmRegister() returns the register value directly.

v3:
- Refine the coding style

v2:
- Rename "mPackageBspInfo" to "mPackageFirstThreadIndex"
- Clarify the expected value of "SmmRegSmmEnable" & "SmmRegSmmDelayed" &
  "SmmRegSmmBlocked" returned from SmmCpuFeaturesLib.
- Thread: https://edk2.groups.io/g/devel/message/96722

v1:
- Thread: https://edk2.groups.io/g/devel/message/96671

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
16 months agoEmulatorPkg/Win: Unload DLLs before reset
Ray Ni [Mon, 5 Dec 2022 06:51:18 +0000 (14:51 +0800)]
EmulatorPkg/Win: Unload DLLs before reset

EmulatorPkg/Win calls LoadLibraryEx() when the corresponding DLL file
is found for each PEIM or DXE driver. The module entry point is
changed to point to the entry point from the DLL. This helps to
notify Visual Studio that a new windows module is loaded and
corresponding symbol parsing is performed for source level debugging.

But entry point from the DLL is only executed when the module is not
loaded by AddModHandle().
When reset happens, we need to clear the DLL loading so that in next
boot the module can be loaded again by AddModHandle().

Without this patch, source level debugging doesn't work after reset.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Andrew Fish <afish@apple.com>
16 months agoUefiCpuPkg/Test: develop UEFI App and dynamic cmd for MP services UT
Jason Lou [Thu, 24 Nov 2022 12:11:58 +0000 (20:11 +0800)]
UefiCpuPkg/Test: develop UEFI App and dynamic cmd for MP services UT

The code changes develop UEFI application and dynamic command for
EfiMpServiceProtocol unit tests based on current UnitTestFramework.

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>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Dun Tan <dun.tan@intel.com>
16 months agoUefiCpuPkg/Test: Move EfiMpServiceProtocol UT in a separate function
Jason Lou [Thu, 24 Nov 2022 12:11:57 +0000 (20:11 +0800)]
UefiCpuPkg/Test: Move EfiMpServiceProtocol UT in a separate function

Move the implementation of EfiMpServiceProtocol unit tests in a separate
function in preparation for developing the UEFI application and dynamic
command for the same unit tests.

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>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Dun Tan <dun.tan@intel.com>
16 months agoMdeModulePkg: Put USB DEBUGs that occur for bulk timeouts under VERBOSE
Rebecca Cran [Tue, 6 Dec 2022 14:30:39 +0000 (22:30 +0800)]
MdeModulePkg: Put USB DEBUGs that occur for bulk timeouts under VERBOSE

With the pending commit of UsbNetworkPkg, it will become common for
UsbBulkTransfer calls to timeout, given that the drivers are called from
MnpSystemPoll every MNP_SYS_POLL_INTERVAL milliseconds: the drivers
check for network packets by calling UsbBulkTransfer with a timeout of
1ms.

Avoid console spam by moving DEBUG messages that occur each time a bulk
transfer request times out from DEBUG_ERROR to DEBUG_VERBOSE, for both
EHCI and XHCI drivers.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
16 months agoRedfishPkg: Remove overlapping private include path in DEC file
Michael D Kinney [Mon, 5 Dec 2022 19:49:45 +0000 (11:49 -0800)]
RedfishPkg: Remove overlapping private include path in DEC file

Update ReadfishPkg.dec to remove PrivateInclude from the
[Includes.Common.Private] section.  The PrivateInclude directory
does not contain any include files, and the PrivateInclude/Crt
include path remaining in the [Includes.Common.Private] section
providing the include path required to access the CRT related
include files by components within the RedfishPkg.

Without this update, there are two forms of #include statements
that can be used to include the CRT related include files.
Include files should only be available using one form of
#include statements.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
16 months agoUefiPayloadPkg: Support multiple firmware volume
MarsX Lin [Wed, 23 Nov 2022 07:50:06 +0000 (15:50 +0800)]
UefiPayloadPkg: Support multiple firmware volume

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

To support multiple FVs provided by UPL

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: MarsX Lin <marsx.lin@intel.com>
17 months agoEmulatorPkg/WinHost: Add Reset2 PPI
Ni, Ray [Sat, 12 Nov 2022 04:00:42 +0000 (12:00 +0800)]
EmulatorPkg/WinHost: Add Reset2 PPI

When shutdown is requested, WinHost exits.
Otherwise, WinHost re-runs from SEC.
Tested no extra memory consumption with multiple resets in PEI.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
17 months agoEmulatorPkg/WinHost: XIP for SEC and PEI_CORE
Ni, Ray [Sat, 12 Nov 2022 04:00:41 +0000 (12:00 +0800)]
EmulatorPkg/WinHost: XIP for SEC and PEI_CORE

In EmulatorPkg/Win, SEC and PEI_CORE are loaded to memory allocated
through VirtualAlloc. Though the corresponding DLL files are loaded
and the entry points in DLL files are executed. The loading to memory
allocated through VirtualAlloc is for the case when the DLL files can
not be loaded.

Actually some PEIMs like PcdPeim which are loaded before
"physical" RAM is discovered, they are executing in the original
location (FV) like XIP module in real platform.

The SEC and PEI_CORE can follow the same mechanism.
So, the VirtualAlloc call is removed.

This is to prepare the "reset" support to avoid additional OS memory
consumption when reset happens.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Andrew Fish <afish@apple.com
17 months agoEmulatorPkg/WinHost: pre-allocate "physical" RAM
Ni, Ray [Sat, 12 Nov 2022 04:00:40 +0000 (12:00 +0800)]
EmulatorPkg/WinHost: pre-allocate "physical" RAM

Move the "physical" RAM allocation from WinPeiAutoScan
to main() entrypoint.

This is to prepare the changes for "reset" support.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
17 months agoRedfishPkg: Fix typos of the .inc filenames
Rebecca Cran [Thu, 1 Dec 2022 15:20:53 +0000 (08:20 -0700)]
RedfishPkg: Fix typos of the .inc filenames

Fix a typo of "RedfishLibs.dsc.inc" in RedfishLibs.dsc.inc, and correct
the name of the .fdf.inc filename in Redfish.fdf.inc.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
17 months agoCryptoPkg/BaseCryptLib:time overflow
Zihong Yi [Fri, 2 Dec 2022 05:51:50 +0000 (13:51 +0800)]
CryptoPkg/BaseCryptLib:time overflow

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

In CrtLibSupport.h, time_t is defined as INT32, and its maximum value
is 2147483647. That is, the corresponding maximum timestamp is
2038-01-19 11:14:07. Therefore, overflow occurs when the test time
exceeds 2038-01-19 11:14:07. So change the type of time_t to INT64 and
also change the type of variables in function gmtime which calculated
with time_t.

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>
Signed-off-by: Zihong Yi <yizihong@huawei.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
17 months agoCryptPkg: Enable CryptoPkg BaseCryptLib ParallelHash for PEI and DXE
Zhihao Li [Wed, 30 Nov 2022 14:21:02 +0000 (22:21 +0800)]
CryptPkg: Enable CryptoPkg BaseCryptLib ParallelHash for PEI and DXE

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

The BaseCryptLib in the CryptoPkg currently supports ParallelHash
algorithm for SMM. The MP Services PPI and MP Services Protocol
could be used to enable ParallelHash in PEI and DXE
versions of the BaseCryptLib.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Zhihao Li <zhihao.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
17 months agoOvmfPkg/PlatformInitLib: Add check to NvVarStoreFV HeaderLength
Min M Xu [Sun, 27 Nov 2022 07:00:14 +0000 (15:00 +0800)]
OvmfPkg/PlatformInitLib: Add check to NvVarStoreFV HeaderLength

There should be a check that the FV HeaderLength cannot be an odd
number. Otherwise in the following CalculateSum16 there would be an
ASSERT.

In ValidateFvHeader@QemuFlashFvbServicesRuntimeDxe/FwBlockServices.c
there a is similar check to the FwVolHeader->HeaderLength.

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>
17 months agoUnitTestFrameworkPkg: Library classes private to public
Michael D Kinney [Wed, 30 Nov 2022 21:14:09 +0000 (13:14 -0800)]
UnitTestFrameworkPkg: Library classes private to public

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

* Change GoogleTestLib class from private to public.
* Change UnitTestPersistenceLib class from private to public.

Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
17 months agoCryptoPkg/OpensslLib: Upgrade OpenSSL to 1.1.1s
Gang Chen [Thu, 17 Nov 2022 08:39:37 +0000 (16:39 +0800)]
CryptoPkg/OpensslLib: Upgrade OpenSSL to 1.1.1s

Upgrade openssl to 1.1.1s.

Pick up bugfixes from the latest openssl release, which include
some GCC build warnings cleaning up.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Gang Chen <gang.c.chen@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
17 months agoMdeModulePkg: Disable PciDegrade support for LoongArch64
Dongyan Qian [Thu, 17 Nov 2022 02:57:11 +0000 (10:57 +0800)]
MdeModulePkg: Disable PciDegrade support for LoongArch64

LoongArch64: Pcie devices that come with OPROM may require large Mem Space,
and downgrading all 64 Bit Bars may result in insufficient space.

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

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Chao Li <lichao@loongson.cn>
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
Co-authored-by: Bo Zhu <zhubo@loongson.cn>
Reviewed-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
17 months ago.github/ISSUE_TEMPLATE/config.yml: Add initial issue template
Michael Kubacki [Thu, 10 Nov 2022 15:03:08 +0000 (10:03 -0500)]
.github/ISSUE_TEMPLATE/config.yml: Add initial issue template

Adds a GitHub issue template to direct contributors familiar with
GitHub's issue tracker to the external resources used by TianoCore.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
17 months agoEmbeddedPkg/MetronomeDxe: Update outdated lower bound comment
Rebecca Cran [Tue, 29 Nov 2022 12:40:56 +0000 (05:40 -0700)]
EmbeddedPkg/MetronomeDxe: Update outdated lower bound comment

There was previously a lower bound on the value of TickPeriod such that
it couldn't be less than 10 us. However, that was removed from the PI
Specification in the 1.0 errata released in 2007. From the revision
history:

"M171 Remove 10 us lower bound restriction for the TickPeriod in the
Metronome"

Update the documentation of TickPeriod in MetronomeDxe/Metronome.c to
remove mention of the lower bound.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
17 months agoBaseSynchronizationLib: Fix RISC-V helper name
Sunil V L [Fri, 11 Nov 2022 11:21:06 +0000 (19:21 +0800)]
BaseSynchronizationLib: Fix RISC-V helper name

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

Fix the name of InternalSyncCompareExchange64() function.

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
Reported-by: Zhihao Li <zhihao.li@intel.com>
Tested-by: Zhihao Li <zhihao.li@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: Daniel Schaefer <git@danielschaefer.me>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
17 months agoShellPkg/DpDynamicCommand: Add ResetEnd support in DP command
zhenhuay [Mon, 21 Nov 2022 09:34:56 +0000 (17:34 +0800)]
ShellPkg/DpDynamicCommand: Add ResetEnd support in DP command

DP command should be able to parse the FPDT ACPI table and dump
the ResetEnd which was logged at the beginning of the firmware
image execution. So that DP can calculate SEC phase time duration
start from the beginning of firmware image execution.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: zhenhuay <zhenhua.yang@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
17 months ago.github/dependabot.yml: Enable dependabot
Michael Kubacki [Thu, 10 Nov 2022 12:26:23 +0000 (07:26 -0500)]
.github/dependabot.yml: Enable dependabot

Enables dependabot in this repo so we can better alerted when
dependency updates are available.

This GitHub action will automatically create pull requests and
summarize the dependency details. Because it is a pull request,
the CI system will validate the dependency update in the pull
request.

Configures dependabot for:

1. PIP module updates
2. GitHub action updates

The maintainers/reviewers of the .github directory were added as
pull request reviewers so they can be notified when the pull request
is available.

Note to Maintainers:
  After this change is committed, PRs from dependabot will be
  automatically created in the edk2 repo.  Never set the 'push' label
  directly on these PRs. If a dependency identified by dependedabot
  looks like one that should be updated in the edk2 repo, then copy
  the PR generated by dependabot to your personal fork and update the
  commit message to follow the edk2 commit message requirements and
  send as a normal code review.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
17 months agoShellPkg/SmbiosView: Update ProcessorUpgradeTable
Zhang, JuX [Wed, 16 Nov 2022 07:12:57 +0000 (15:12 +0800)]
ShellPkg/SmbiosView: Update ProcessorUpgradeTable

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

Refer to the latest SMBIOS v3.6, SMBIOS Socket not completely defined.

SMBIOS v3.6:
https://www.dmtf.org/sites/default/files/standards/documents/
DSP0134_3.6.0.pdf

Signed-off-by: JuX Zhang <jux.zhang@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
17 months agoUefiPayloadPkg: The UPL info section is not aligned at 4-byte boundary
VictorX Hsu [Tue, 15 Nov 2022 09:55:16 +0000 (17:55 +0800)]
UefiPayloadPkg: The UPL info section is not aligned at 4-byte boundary

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

1.Upgrade spec revision to 0.9
2.Align .upld_info with 4-byte boundary by spec

Reviewed-by: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: VictorX Hsu <victorx.hsu@intel.com>
17 months agoArmPkg/ArmTrngLib: Remove ASSERTs in ArmTrngLibConstructor()
Pierre Gondois [Thu, 24 Nov 2022 16:17:53 +0000 (17:17 +0100)]
ArmPkg/ArmTrngLib: Remove ASSERTs in ArmTrngLibConstructor()

Remove ASSERTs in ArmTrngLibConstructor() that prevent from
booting on DEBUG builds.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
17 months agopip-requirements.txt: Update to edk2-pytool-extensions 0.20.0 edk2-stable202211
Michael Kubacki [Fri, 11 Nov 2022 21:04:39 +0000 (16:04 -0500)]
pip-requirements.txt: Update to edk2-pytool-extensions 0.20.0

Updates edk2-pytool-extensions to pick up a major version release:

0.19.1 to 0.20.0 changes:

- .vscode/settings.json: Enable flake8 linting
- Add Pydocstyle
- Move dependabot.yml location
- Fix typos in robot files
- Pydocstyle Updates
- Plugin Loader Updates
- edk2_stuart_pr_eval: Improve robustness of path comparisons
- edk2_pr_eval.py: Build all packages on file change outside package
- Allow build wrappers

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
17 months agopip-requirements.txt: Update to edk2-pytool-library 0.12.1
Michael Kubacki [Fri, 11 Nov 2022 21:01:09 +0000 (16:01 -0500)]
pip-requirements.txt: Update to edk2-pytool-library 0.12.1

Updates edk2-pytool-library to pick up a minor bug fix release:

0.12.0 to 0.12.1 changes:

  - path_utilities.py: Prevent path case modification in
    GetContainingModules()

That change prevents the case of paths from being set to lower case
when returned from the function to avoid impacting case-sensitive
callers.

Release notes:

https://github.com/tianocore/edk2-pytool-library/releases/tag/v0.12.1

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
17 months agoArmPkg/ArmTrngLib: Remove ASSERT in GetArmTrngVersion()
Pierre Gondois [Mon, 14 Nov 2022 14:43:47 +0000 (22:43 +0800)]
ArmPkg/ArmTrngLib: Remove ASSERT in GetArmTrngVersion()

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

GetArmTrngVersion() is used to check the presence of an Arm
Trng. If not found, an ASSERT prevents from booting in DEBUG
builds.
Remove this ASSERT.

Reported-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
17 months agoMaintainers: Update the VmgExitLib to CcExitLib
Min M Xu [Fri, 28 Oct 2022 00:57:41 +0000 (08:57 +0800)]
Maintainers: Update the VmgExitLib to CcExitLib

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

VmgExitLib is renamed as CcExitLib. The related section in
Maintainers.txt should be updated as well.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
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>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
17 months agoOvmfPkg/UefiCpuPkg: Add CcExit prefix to the APIs of CcExitLib
Min M Xu [Mon, 7 Nov 2022 07:50:11 +0000 (15:50 +0800)]
OvmfPkg/UefiCpuPkg: Add CcExit prefix to the APIs of CcExitLib

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

APIs which are defined in CcExitLib.h are added with the CcExit prefix.
This is to make the APIs' name more meaningful.

This change impacts OvmfPkg/UefiCpuPkg.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
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: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
17 months agoOvmfPkg/UefiCpuPkg/UefiPayloadPkg: Rename VmgExitLib to CcExitLib
Min M Xu [Mon, 7 Nov 2022 06:30:26 +0000 (14:30 +0800)]
OvmfPkg/UefiCpuPkg/UefiPayloadPkg: Rename VmgExitLib to CcExitLib

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

VmgExitLib once was designed to provide interfaces to support #VC handler
and issue VMGEXIT instruction. After TDVF (enable TDX feature in OVMF) is
introduced, this library is updated to support #VE as well. Now the name
of VmgExitLib cannot reflect what the lib does.

This patch renames VmgExitLib to CcExitLib (Cc means Confidential
Computing). This is a simple renaming and there is no logic changes.
After renaming all the VmgExitLib related codes are updated with
CcExitLib. These changes are in OvmfPkg/UefiCpuPkg/UefiPayloadPkg.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
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: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
17 months agoUefiCpuPkg/ResetVector:Add Option to reserve 4K region at 4GB
Duggapu, Chinni B [Mon, 7 Nov 2022 06:47:31 +0000 (14:47 +0800)]
UefiCpuPkg/ResetVector:Add Option to reserve 4K region at 4GB

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

Some implementations may need to keep the initial Reset code to be
separated out from rest of the code.This request is to add padding at
lower 4K region below 4 GB which will result having only few jmp
instructions and data at that region.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Duggapu Chinni B <chinni.b.duggapu@intel.com>
17 months agoMdePkg/Test: Add port of BaseSafeIntLib unit tests to GoogleTest
Michael D Kinney [Tue, 21 Jun 2022 02:52:31 +0000 (19:52 -0700)]
MdePkg/Test: Add port of BaseSafeIntLib unit tests to GoogleTest

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

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
17 months agoBaseTools/Plugin/HostBaseUnitTestRunner: Enable gtest xml output
Michael D Kinney [Mon, 31 Oct 2022 17:09:09 +0000 (10:09 -0700)]
BaseTools/Plugin/HostBaseUnitTestRunner: Enable gtest xml output

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

Set environment variable GTEST_OUTPUT to specify the output
format of XML and the output file name.  Both CMOCKA_XML_FILE
and GTEST_OUTPUT are set for each host based unit test to
support both cmocka unit tests and gtest unit tests.

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: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
17 months ago.pytool: Add googletest submodule to CISettings.py
Michael D Kinney [Tue, 28 Jun 2022 17:33:02 +0000 (10:33 -0700)]
.pytool: Add googletest submodule to CISettings.py

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

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
17 months agoUnitTestFrameworkPkg/Library/CmockaLib: Generate symbol information
Michael D Kinney [Thu, 3 Nov 2022 22:38:25 +0000 (15:38 -0700)]
UnitTestFrameworkPkg/Library/CmockaLib: Generate symbol information

Add /Zi to CC_FLAGS in CmockaLib.inf to enable symbol information

Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
17 months agoUnitTestFrameworkPkg: Add googletest submodule and GoogleTestLib
Michael D Kinney [Tue, 21 Jun 2022 02:52:03 +0000 (19:52 -0700)]
UnitTestFrameworkPkg: Add googletest submodule and GoogleTestLib

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

Add submodule for googletest and add GoogleTestLib that is
required for GoogleTest based unit tests. Add GoogleTest
documentation to Readme.md along with a port of the sample
unit test to the GoogleTest style.

A few typos in Readme.md are also fixed.

Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
17 months agoMdePkg/Include/Library: Undefine _ASSERT() if already defined
Michael D Kinney [Tue, 11 Oct 2022 19:03:48 +0000 (12:03 -0700)]
MdePkg/Include/Library: Undefine _ASSERT() if already defined

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

When unit testing is enabled, make sure _ASSERT() is not already
defined by the host environment before defining _ASSERT().  This
avoids conflicts with VS20xx builds of GoogleTest based unit tests.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
17 months agoMdePkg/Include: Update Base.h to improve C++ compatibility
Michael D Kinney [Tue, 21 Jun 2022 19:30:07 +0000 (12:30 -0700)]
MdePkg/Include: Update Base.h to improve C++ compatibility

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

* Map NULL to nullptr or __null when c++ compiler is used.
* Map STATIC_ASSERT to static_assert when a c++ compiler is used.
* Typecast RETURN_SUCCESS to type RETURN_STATUS to match type used
  by all return error/warning status codes.  C++ has stricter type
  checking and found this inconsistency.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
17 months agoIntelFsp2Pkg: Improvement of supporting null UPD pointer in FSP-T
Kuo, Ted [Wed, 9 Nov 2022 11:30:57 +0000 (03:30 -0800)]
IntelFsp2Pkg: Improvement of supporting null UPD pointer in FSP-T

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

1.Use xmm5 slot 1 and xmm6 slot 3 to save ucode status and UPD pointer
  respectively in TempRamInitApi in IA32 FspSecCoreT.
2.Correct inappropriate description in the return value of
  AsmGetFspInfoHeader.
3.Replace hardcoded offset value 0x1C with FSP_HEADER_IMGBASE_OFFSET in
  FspHeler.nasm.

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>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>