]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
15 months agoMdeModulePkg/Include: Add IpmiCommandLib header file
Abner Chang [Mon, 26 Dec 2022 07:06:22 +0000 (15:06 +0800)]
MdeModulePkg/Include: Add IpmiCommandLib header file

Add IpmiCommandLib to MdeModulePkg. This header file is
copied from edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg\Include\Library. Having this header file in
edk2 to avoid the dependence of edk2 module with edk2-platfrom.
The NULL instance of IpmiCommandLib under MdeModulePkg has
to be implemented for the same reason.
IpmiCommandLib.h in edk2-platforms should be removed once
this patch set is merged. Expect no impacts on edk2-platforms
because MdeModulePkg is referred in INF file by all edk2
modules under edk2-platforms that use IpmiCommandLib.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
15 months agoRedfishPkg/Include: Redfish USB Interface V2 update
Abner Chang [Fri, 23 Dec 2022 06:40:15 +0000 (14:40 +0800)]
RedfishPkg/Include: Redfish USB Interface V2 update

Support USB_INTERFACE_DEVICE_DESCRIPTOR_V2 which
is updated in Redfish Host Interface spec v1.3.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
15 months agoRedfishPkg/Include: Add Redfish IPMI definitions
Abner Chang [Fri, 23 Dec 2022 06:33:48 +0000 (14:33 +0800)]
RedfishPkg/Include: Add Redfish IPMI definitions

Add the definitions of Redfish Host Interface
credential bootstrapping IPMI commands.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Igor Kulchytskyy<igork@ami.com>
Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>
15 months agoMdePkg/IndustryStandard: Update IPMI definitions
Abner Chang [Fri, 23 Dec 2022 06:20:06 +0000 (14:20 +0800)]
MdePkg/IndustryStandard: Update IPMI definitions

This change updates IPMI header files to support
build up SMBIOS 42 Redfish Host Interface record
using the information retrieved via IPMI App/Net
Function.

In IpmiNetFnApp.h, we also remove the duplicate
definition of IPMI_APP_GET_CHANNEL_INFO.

Signed-off-by: Abner Chang <abner.chang@amd.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: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
15 months agoOvmfPkg/CcExitLib: Initialize Status in IoExit
Min M Xu [Tue, 17 Jan 2023 23:53:01 +0000 (07:53 +0800)]
OvmfPkg/CcExitLib: Initialize Status in IoExit

Status should be initialized otherwise it may return unexpected value.

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>
Cc: Michael Roth <michael.roth@amd.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
15 months agoOvmfPkg/BaseMemEncryptTdxLib: Refactor error handle of SetOrClearSharedBit
Min M Xu [Tue, 17 Jan 2023 23:52:32 +0000 (07:52 +0800)]
OvmfPkg/BaseMemEncryptTdxLib: Refactor error handle of SetOrClearSharedBit

The previous implementation of SetOrClearSharedBit doesn't handle the
error correctly. In this patch SetOrClearSharedBit is changed to return
error code so that the caller can handle it.

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>
Cc: Michael Roth <michael.roth@amd.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
15 months agoSecurityPkg/TdTcg2Dxe: Extend EFI boot variable to PCR[1]
Min M Xu [Tue, 17 Jan 2023 23:53:26 +0000 (07:53 +0800)]
SecurityPkg/TdTcg2Dxe: Extend EFI boot variable to PCR[1]

According to TCG PC Client PFP spec 0021 Section 2.4.4.2 EFI boot variable
should be measured and extended to PCR[1], not PCR[5]. This patch is
proposed to fix this error.

Cc: Jiewen Yao <jiewen.yao@intel.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>
15 months agoOvmfPkg/CcExitLib: Refactor TDX MmioExit
Min M Xu [Tue, 17 Jan 2023 07:43:30 +0000 (15:43 +0800)]
OvmfPkg/CcExitLib: Refactor TDX MmioExit

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

The previous TDX MmioExit doesn't handle the Mmio instructions correctly
in some scenarios. This patch refactors the implementation to fix the
issues.

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>
Cc: Ryan Afranji <afranji@google.com>
Reported-by: Ryan Afranji <afranji@google.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>
15 months agoOvmfPkg/CcExitLib: Move common X86 instruction code to separate file
Min M Xu [Tue, 17 Jan 2023 07:43:29 +0000 (15:43 +0800)]
OvmfPkg/CcExitLib: Move common X86 instruction code to separate file

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

Move common X86 instruction codes from CcExitVcHandler.c to separate
files (CcInstruction.h / CcInstruction.c) so that these codes can be
re-used in TDX.

Cc: Gerd Hoffmann <kraxel@redhat.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>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
15 months agoOvmfPkg/PeilessStartupLib: Find NCCFV in non-td guest
Min M Xu [Mon, 16 Jan 2023 23:31:58 +0000 (07:31 +0800)]
OvmfPkg/PeilessStartupLib: Find NCCFV in non-td guest

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

As described in BZ#4152, NCCFV includes the DXE phase drivers for non-cc
guest. PeilessStartupLib is updated to find NCCFV for non-cc guest.

Cc: Gerd Hoffmann <kraxel@redhat.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>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
15 months agoOvmfPkg/IntelTdx: Enable separate-fv in IntelTdx/IntelTdxX64.fdf
Min M Xu [Mon, 16 Jan 2023 23:31:57 +0000 (07:31 +0800)]
OvmfPkg/IntelTdx: Enable separate-fv in IntelTdx/IntelTdxX64.fdf

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

In current DXE FV there are 100+ drivers. Some of the drivers are not
used in Td guest. (Such as USB support drivers, network related drivers,
etc).

From the security perspective if a driver is not used, we'd should prevent
it from being loaded / started. There are 2 benefits:
1. Reduce the attack surface
2. Improve the boot performance

So we separate DXEFV into 2 FVs: DXEFV and NCCFV. All the drivers which
are not needed by a Confidential Computing guest are moved from DXEFV
to NCCFV.

The following patch will find NCCFV for non-cc guest and build FVHob
so that NCCFV drivers can be loaded / started in DXE phase.

Cc: Gerd Hoffmann <kraxel@redhat.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>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
15 months agoOvmfPkg: Add PCDs/GUID for NCCFV
Min M Xu [Mon, 16 Jan 2023 23:31:56 +0000 (07:31 +0800)]
OvmfPkg: Add PCDs/GUID for NCCFV

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

NCCFV refers to Non-Confidential-Computing-FV. It includes the DXE phase
drivers which are only loaded/started in non-cc guest. Hence the
PCDs / GUID for NCCFV are defined in OvmfPkg.dec.

Cc: Gerd Hoffmann <kraxel@redhat.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>
Signed-off-by: Min Xu <min.m.xu@intel.com>
15 months agoEmbeddedPkg/PrePiLib: Add FFS_CHECK_SECTION_HOOK when finding section
Min M Xu [Mon, 16 Jan 2023 23:31:55 +0000 (07:31 +0800)]
EmbeddedPkg/PrePiLib: Add FFS_CHECK_SECTION_HOOK when finding section

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

EmbeddedPkg/PrePiLib provides the service of finding sections based on
the input SectionType. But sometimes there maybe multiple sections
with the same SectionType. FFS_CHECK_SECTION_HOOK is a hook which can
be called to do additional check.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Gerd Hoffmann <kraxel@redhat.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>
Acked-by: Ard Biesheuvel <ardb+tianocore@kernel.org>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
15 months agoShellPkg: Display SMBIOS Type38 fields in smbiosview in formatted view
Prakash.K [Thu, 24 Nov 2022 05:12:13 +0000 (10:42 +0530)]
ShellPkg: Display SMBIOS Type38 fields in smbiosview in formatted view

In smbiosview command in shell, below are the fields of SMBIOS
Type38 table which can be displayed in formatted manner.
1. Base Address
1. IPMI Specification Version.
2. NV Storage Device Address.
Base Address:
As per spec, the value in Base Address field of SMBIOS type38 table
should be right shifted by 1 if the interface type is SSIF.
IPMI Specification Version:
If the value in IPMI Specification Version field is 15H,
it should be displayed 1.5.
NV Storage Device Address:
If the value in NV Storage Device Address field is 0xFF,
it should be displayed as "No storage device is Present".

Cc: Vasudevan Sambandan <vasudevans@ami.com>
Cc: Sundaresan Selvaraj <sundaresans@ami.com>
Cc: Gayathri Thunuguntla <gayathrit@ami.com>
Signed-off-by: Prakash K <prakashk@ami.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
15 months agoCI: use ubuntu-22.04 image (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:43 +0000 (18:40 +0100)]
CI: use ubuntu-22.04 image (Linux only)

Use the same vm_image as the other Linux CIs in ArmVirtPkg, EmulatorPkg,
and OvmfPkg.  Switch over to ubuntu-22.04 from ubuntu-latest.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoOvmfPkg: CI: use ubuntu-22.04 vm_image (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:42 +0000 (18:40 +0100)]
OvmfPkg: CI: use ubuntu-22.04 vm_image (Linux only)

Switch over to ubuntu-22.04 as the vm_image for Linux CI jobs.  The
previously used ubuntu-18.04 which is not available anymore since
Dec 1st 2022.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoEmulatorPkg: CI: use ubuntu-22.04 vm_image (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:41 +0000 (18:40 +0100)]
EmulatorPkg: CI: use ubuntu-22.04 vm_image (Linux only)

Switch over to ubuntu-22.04 as the vm_image for Linux CI jobs.  The
previously used ubuntu-18.04 which is not available anymore since
Dec 1st 2022.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoArmVirtPkg: CI: use ubuntu-22.04 vm_image (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:40 +0000 (18:40 +0100)]
ArmVirtPkg: CI: use ubuntu-22.04 vm_image (Linux only)

Switch over to ubuntu-22.04 as the vm_image for Linux CI jobs.  The
previously used ubuntu-18.04 which is not available anymore since
Dec 1st 2022.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoBaseTools: remove ext_dep files for gcc
Oliver Steffen [Mon, 16 Jan 2023 17:40:39 +0000 (18:40 +0100)]
BaseTools: remove ext_dep files for gcc

Remove BaseTools/Bin/gcc_*_ext_dep.yaml to stop downloading gcc from
external locations; use the gcc provided by the container image instead.
The container image sets the variable GCC5_*_PREFIX accordingly.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months ago.pytool: CISettings.py: don't add scopes for GCC
Oliver Steffen [Mon, 16 Jan 2023 17:40:38 +0000 (18:40 +0100)]
.pytool: CISettings.py: don't add scopes for GCC

All ext_dep.yml files for gcc have been removed and gcc is expected to
be installed on the system (GCC5_*_PREFIX may indicate the location).
No need to adjust the toolchain scopes for Linux builds anymore.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoOvmfPkg: CI: Use Fedora 35 container (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:37 +0000 (18:40 +0100)]
OvmfPkg: CI: Use Fedora 35 container (Linux only)

Run the Linux jobs of the OvmfPkg platform CI inside a container,
in the same way the general CI does now. Make use of the default image
specified in the defaults.yml template.

Do not run apt-get in CI jobs to install qemu and gcc dependencies.
Assume the container image provides these.

Use Python from the container image, do not download at runtime.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoEmulatorPkg: CI: Use Fedora 35 container (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:36 +0000 (18:40 +0100)]
EmulatorPkg: CI: Use Fedora 35 container (Linux only)

Run the Linux jobs of the EmulatorPkg platform CI inside a container,
in the same way the general CI does now. Make use of the default image
specified in the defaults.yml template.

Use Python from the container image, do not download at runtime.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoArmVirtPkg: CI: Use Fedora 35 container (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:35 +0000 (18:40 +0100)]
ArmVirtPkg: CI: Use Fedora 35 container (Linux only)

Run the Linux jobs of the ArmVirtPkg platform CI inside a container,
in the same way the general CI does now. Make use of the default image
specified in the defaults.yml template.

Do not run apt-get in CI jobs to install qemu and gcc dependencies.
Assume the container image provides these.

Use Python from the container image, do not download at runtime.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoCI: Use Fedora 35 container (Linux only)
Ard Biesheuvel [Tue, 17 Jan 2023 18:09:09 +0000 (19:09 +0100)]
CI: Use Fedora 35 container (Linux only)

Run all Linux based jobs in a container, using a custom Fedora 35 image
(gcc 11).  The image URL specified in the defaults.yml template, so that
all CI jobs can use it. The image is hosted on ghcr.io and the
Dockerfiles are here: https://github.com/tianocore/containers The
version numbers of gcc, iasl, and nasm are pinned to avoid unintended
upgrades during image rebuild.

Do not run apt-get in CI jobs to install qemu and gcc dependencies.
Assume the container image provides these.

Use Python from the container image, do not download at runtime.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoCI: Allow running in a container.
Oliver Steffen [Mon, 16 Jan 2023 17:40:33 +0000 (18:40 +0100)]
CI: Allow running in a container.

Add a parameter of the pr-gate-build-job template to specify a
container image URL.  If the value is not '' (default), then the
jobs will be run inside a container based on that image.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoCI: add ~/.local/bin to PATH (Linux only)
Oliver Steffen [Mon, 16 Jan 2023 17:40:32 +0000 (18:40 +0100)]
CI: add ~/.local/bin to PATH (Linux only)

Without adding ~/.local/bin to PATH, `pip install` will throw
an error when running inside a container.
Containers will be introduced to the CI in the following commits.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoOvmfPkg: CI: use Python version from defaults template
Oliver Steffen [Mon, 16 Jan 2023 17:40:31 +0000 (18:40 +0100)]
OvmfPkg: CI: use Python version from defaults template

Use the default Python version from the defaults template
(.azurepipelines/templates/defaults.yml) in the Windows and
Linux CI jobs.

Previous changes to the CI job templates make it necessary
to specify a version number, if Python shall be pulled
at CI runtime.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoEmulatorPkg: CI: use Python version from defaults template
Oliver Steffen [Mon, 16 Jan 2023 17:40:30 +0000 (18:40 +0100)]
EmulatorPkg: CI: use Python version from defaults template

Use the default Python version from the defaults template
(.azurepipelines/templates/defaults.yml) in the Windows and
Linux CI jobs.

Previous changes to the CI job templates make it necessary
to specify a version number, if Python shall be pulled
at CI runtime.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoArmVirtPkg: CI: use Python version from defaults template
Oliver Steffen [Mon, 16 Jan 2023 17:40:29 +0000 (18:40 +0100)]
ArmVirtPkg: CI: use Python version from defaults template

Use the default Python version from the defaults template
(.azurepipelines/templates/defaults.yml) in the Windows and
Linux CI jobs.

Previous changes to the CI job templates make it necessary
to specify a version number, if Python shall be pulled
at CI runtime.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoCI: make Python version configurable
Oliver Steffen [Mon, 16 Jan 2023 17:40:28 +0000 (18:40 +0100)]
CI: make Python version configurable

Add a new parameter "usePythonVersion" to the CI job templates.
This makes it possible to specify the version of Python to use.
The default value is '', in which case Python will not be downloaded
at runtime and the one provided by the VM/container image will be used.

Additionally, add a template .azurepipelines/templates/defaults.yml,
from which the default Pyhton version string can be obtained.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
15 months agoOvmfPkg/PlatformInitLib: reorder PlatformQemuUc32BaseInitialization
Gerd Hoffmann [Tue, 17 Jan 2023 12:16:29 +0000 (13:16 +0100)]
OvmfPkg/PlatformInitLib: reorder PlatformQemuUc32BaseInitialization

First handle the cases which do not need know the value of
PlatformInfoHob->LowMemory (microvm and cloudhv).  Then call
PlatformGetSystemMemorySizeBelow4gb() to get LowMemory.  Finally handle
the cases (q35 and pc) which need to look at LowMemory,

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
15 months agoOvmfPkg/PlatformInitLib: Add PlatformReservationConflictCB
Gerd Hoffmann [Tue, 17 Jan 2023 12:16:28 +0000 (13:16 +0100)]
OvmfPkg/PlatformInitLib: Add PlatformReservationConflictCB

Add PlatformReservationConflictCB() callback function for use with
PlatformScanE820().  It checks whenever the 64bit PCI MMIO window
overlaps with a reservation from qemu.  If so move down the MMIO window
to resolve the conflict.

Write any actions done (moving mmio window) to the firmware log with
INFO loglevel.

This happens on (virtual) AMD machines with 1TB address space,
because the AMD IOMMU uses an address window just below 1TB.

Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4251
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
15 months agoOvmfPkg/PlatformInitLib: Add PlatformAddHobCB
Gerd Hoffmann [Tue, 17 Jan 2023 12:16:27 +0000 (13:16 +0100)]
OvmfPkg/PlatformInitLib: Add PlatformAddHobCB

Add PlatformAddHobCB() callback function for use with
PlatformScanE820().  It adds HOBs for high memory and reservations (low
memory is handled elsewhere because there are some special cases to
consider).  This replaces calls to PlatformScanOrAdd64BitE820Ram() with
AddHighHobs = TRUE.

Write any actions done (adding HOBs, skip unknown types) to the firmware
log with INFO loglevel.

Also remove PlatformScanOrAdd64BitE820Ram() which is not used any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
15 months agoOvmfPkg/PlatformInitLib: Add PlatformGetLowMemoryCB
Gerd Hoffmann [Tue, 17 Jan 2023 12:16:26 +0000 (13:16 +0100)]
OvmfPkg/PlatformInitLib: Add PlatformGetLowMemoryCB

Add PlatformGetLowMemoryCB() callback function for use with
PlatformScanE820().  It stores the low memory size in
PlatformInfoHob->LowMemory.  This replaces calls to
PlatformScanOrAdd64BitE820Ram() with non-NULL LowMemory.

Write any actions done (setting LowMemory) to the firmware log
with INFO loglevel.

Also change PlatformGetSystemMemorySizeBelow4gb() to likewise set
PlatformInfoHob->LowMemory instead of returning the value.  Update
all Callers to the new convention.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
15 months agoOvmfPkg/PlatformInitLib: Add PlatformScanE820 and GetFirstNonAddressCB
Gerd Hoffmann [Tue, 17 Jan 2023 12:16:25 +0000 (13:16 +0100)]
OvmfPkg/PlatformInitLib: Add PlatformScanE820 and GetFirstNonAddressCB

First step replacing the PlatformScanOrAdd64BitE820Ram() function.

Add a PlatformScanE820() function which loops over the e280 entries
from FwCfg and calls a callback for each of them.

Add a GetFirstNonAddressCB() function which will store the first free
address (right after the last RAM block) in
PlatformInfoHob->FirstNonAddress.  This replaces calls to
PlatformScanOrAdd64BitE820Ram() with non-NULL MaxAddress.

Write any actions done (setting FirstNonAddress) to the firmware log
with INFO loglevel.

Also drop local FirstNonAddress variables and use
PlatformInfoHob->FirstNonAddress instead everywhere.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
15 months agoBaseTools/tools_def CLANG38: Suppress unaligned access warning
Ard Biesheuvel [Thu, 5 Jan 2023 15:53:33 +0000 (16:53 +0100)]
BaseTools/tools_def CLANG38: Suppress unaligned access warning

Even though the presence of the 'packed' pragma should be a strong hint
that the misaligned placement of a GUID in a struct is intentional,
recent Clang versions will object nonetheless, and break the build due
to the presence of such GUIDs in the FPDT ACPI tables.

This is obviously not something we can fix in the code, so let's just
suppress the warning/error instead.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoBaseTools/tools_def ARM: Make choice for soft float ABI explicit
Ard Biesheuvel [Thu, 5 Jan 2023 15:43:54 +0000 (16:43 +0100)]
BaseTools/tools_def ARM: Make choice for soft float ABI explicit

Recent GCC for ARM will complain when selecting the hard float ABI
without specifying the FPU implementation, even when just running the
preprocessor.

This all happens under the hood, and we never bothered in the past,
given that we don't emit floating point code anyway. However, to placate
newer compilers, make it explicit that the floating point ABI is always the
softfloat one, by moving the -msoft-float compiler option to
PLATFORM_FLAGS.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoBaseTools/tools_def ARM AARCH64: Get rid of ARCHCC and ARCHASM flags
Ard Biesheuvel [Thu, 5 Jan 2023 14:20:16 +0000 (15:20 +0100)]
BaseTools/tools_def ARM AARCH64: Get rid of ARCHCC and ARCHASM flags

ARCHCC_FLAGS and ARCHASM_FLAGS no longer serve a useful purpose so drop
all the definitions and references.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoBaseTools/tools_def RISCV: Make OpenSBI references RISCV-only
Ard Biesheuvel [Thu, 5 Jan 2023 14:29:39 +0000 (15:29 +0100)]
BaseTools/tools_def RISCV: Make OpenSBI references RISCV-only

The global GCC_PP_FLAGS tools_def variable now contains a reference to
OpenSBI specific C preprocessor variables, which means they are added to
the command line on every architecture, not just RISC-V.

This does not currently result in any issues, but it is a bit sloppy so
let's clean this up. Given that the GCC_PP_FLAGS definition appears
twice, drop the one that carries the OpenSBI reference, and move that
reference to a new RISC-V specific variable.

Acked-by: Abner Chang <abner.chang@amd.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoFix cyclic dependency error on OptionROM build
Konstantin Aladyshev [Tue, 13 Dec 2022 16:22:22 +0000 (00:22 +0800)]
Fix cyclic dependency error on OptionROM build

EDKII build system supports OptionROM generation if particular PCI_*
defines are present in the module INF file:
```
[Defines]
  ...
  PCI_VENDOR_ID                  = <...>
  PCI_DEVICE_ID                  = <...>
  PCI_CLASS_CODE                 = <...>
  PCI_REVISION                   = <...>
```
Although after the commit d372ab585a2cdc5348af5f701c56c631235fe698
("BaseTools/Conf: Fix Dynamic-Library-File template") it is no longer
possible.
The build system fails with the error:
```
Cyclic dependency detected while generating rule for
"<...>/DEBUG/<...>.efi" file
```
Remove "$(DEBUG_DIR)(+)$(MODULE_NAME).efi" from the 'dll' output files
to fix the cyclic dependency.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
15 months agoArmVirt: don't use unaligned CopyMem () on NOR flash
Gerd Hoffmann [Mon, 16 Jan 2023 09:46:39 +0000 (10:46 +0100)]
ArmVirt: don't use unaligned CopyMem () on NOR flash

Commit 789a72328553 reclassified the NOR flash region as EFI_MEMORY_WC
in the OS visible EFI memory map, and dropped the explicit aligned
CopyMem() implementation, in the assumption that EFI_MEMORY_WC will be
honored by the OS, and that the region will be mapped in a way that
tolerates misaligned accesseses. However, Linux today uses device
attributes for all EFI MMIO regions, in spite of the memory type
attributes, and so using misaligned accesses is never safe.

So instead, switch to the generic CopyMem() implementation entirely,
just like we already did for VariableRuntimeDxe.

Fixes: 789a72328553 ("OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoMdeModulePkg/XhciPei: Unlinked XhciPei memory block
Abner Chang [Wed, 11 Jan 2023 03:10:08 +0000 (11:10 +0800)]
MdeModulePkg/XhciPei: Unlinked XhciPei memory block

Unlink the XhciPei memory block when it has been freed.

Signed-off-by: Jiangang He <jiangang.he@amd.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Kuei-Hung Lin <Kuei-Hung.Lin@amd.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
15 months agoMdeModulePkg/Usb: Read a large number of blocks
Abner Chang [Wed, 11 Jan 2023 03:10:07 +0000 (11:10 +0800)]
MdeModulePkg/Usb: Read a large number of blocks

Changes to allow reading blocks that greater than 65535 sectors.

Signed-off-by: Jiangang He <jiangang.he@amd.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Kuei-Hung Lin <Kuei-Hung.Lin@amd.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
15 months agoMdeModulePkg/Xhci: Initial XHCI DCI slot's Context value
Abner Chang [Wed, 11 Jan 2023 03:10:06 +0000 (11:10 +0800)]
MdeModulePkg/Xhci: Initial XHCI DCI slot's Context value

Initialize XHCI DCI slot's context entries value.

Signed-off-by: Jiangang He <jiangang.he@amd.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Kuei-Hung Lin <Kuei-Hung.Lin@amd.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
15 months agoOvmfPkg/AcpiPlatformDxe: Return error if installing NotifyProtocol failed
Min M Xu [Wed, 11 Jan 2023 01:22:35 +0000 (09:22 +0800)]
OvmfPkg/AcpiPlatformDxe: Return error if installing NotifyProtocol failed

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

Installation of gQemuAcpiTableNotifyProtocol may fail. The error code
should be returned so that the caller can handle it.

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>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Message-Id: <20230111012235.189-7-min.m.xu@intel.com>
Reviewed-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
15 months agoOvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol
Min M Xu [Wed, 11 Jan 2023 01:22:34 +0000 (09:22 +0800)]
OvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol

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

Commit 9fdc70af6ba8 install the QemuAcpiTableNotifyProtocol at a
wrong positioin. It should be called before TransferS3ContextToBootScript
because TransferS3ContextToBootScript is the last operation in
InstallQemuFwCfgTables(). Another error is that we should check the
returned value after installing the QemuAcpiTableNotifyProtocol.

This patch refactors the installation and error handling of
QemuAcpiTableNotifyProtocol in InstallQemuFwCfgTables ().

Cc: Laszlo Ersek <lersek@redhat.com>
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>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Message-Id: <20230111012235.189-6-min.m.xu@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
15 months agoOvmfPkg/AcpiPlatformDxe: Add log to show the installed tables
Min M Xu [Wed, 11 Jan 2023 01:22:33 +0000 (09:22 +0800)]
OvmfPkg/AcpiPlatformDxe: Add log to show the installed tables

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

Commit 9fdc70af6ba8 wrongly removed the log from InstallQemuFwCfgTables
after ACPI tables are successfully installed. This patch add the log
back after all operations succeed.

Cc: Laszlo Ersek <lersek@redhat.com>
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>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Message-Id: <20230111012235.189-5-min.m.xu@intel.com>

15 months agoOvmfPkg/AcpiPlatformDxe: Use local variable in QemuFwCfgAcpi.c
Min M Xu [Wed, 11 Jan 2023 01:22:32 +0000 (09:22 +0800)]
OvmfPkg/AcpiPlatformDxe: Use local variable in QemuFwCfgAcpi.c

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

The handle of mQemuAcpiHandle is not needed for anything, beyond the
scope of the InstallQemuFwCfgTables(). So a local variable will
suffice for storing the handle.

Cc: Laszlo Ersek <lersek@redhat.com>
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>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Message-Id: <20230111012235.189-4-min.m.xu@intel.com>

15 months agoOvmfPkg/AcpiPlatformDxe: Use local variable in CloudHvAcpi.c
Min M Xu [Wed, 11 Jan 2023 01:22:31 +0000 (09:22 +0800)]
OvmfPkg/AcpiPlatformDxe: Use local variable in CloudHvAcpi.c

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

The handle of mChAcpiHandle is not needed for anything, beyond the
scope of the InstallCloudHvTablesTdx (). A local variable (ChAcpiHandle)
suffices for storing the handle.

Cc: Laszlo Ersek <lersek@redhat.com>
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>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Message-Id: <20230111012235.189-3-min.m.xu@intel.com>
Reviewed-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
15 months agoOvmfPkg/AcpiPlatformDxe: Remove QEMU_ACPI_TABLE_NOTIFY_PROTOCOL
Min M Xu [Wed, 11 Jan 2023 01:22:30 +0000 (09:22 +0800)]
OvmfPkg/AcpiPlatformDxe: Remove QEMU_ACPI_TABLE_NOTIFY_PROTOCOL

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

The QEMU_ACPI_TABLE_NOTIFY_PROTOCOL structure is superfluous because NULL
protocol interfaces have been used in edk2 repeatedly. A protocol instance
can exist in the protocol database with a NULL associated interface.
Therefore the QEMU_ACPI_TABLE_NOTIFY_PROTOCOL type, the
"QemuAcpiTableNotify.h" header, and the "mAcpiNotifyProtocol" global
variable can be removed.

Cc: Laszlo Ersek <lersek@redhat.com>
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>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Message-Id: <20230111012235.189-2-min.m.xu@intel.com>
Reviewed-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
15 months agoOvmfPkg: fix OvmfTpmSecurityStub.dsc.inc include
Gerd Hoffmann [Thu, 12 Jan 2023 15:41:02 +0000 (23:41 +0800)]
OvmfPkg: fix OvmfTpmSecurityStub.dsc.inc include

TPM support is independent from secure boot support.  Move the TPM
include snipped out of the secure boot !if block.

Fixes: b47575801e19 ("OvmfPkg: move tcg configuration to dsc and fdf include files")
Bugzilla: https://bugzilla.tianocore.org//show_bug.cgi?id=4290
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
15 months agoMdeModulePkg: Notify BeforeExitBootServices in CoreExitBootServices
Dionna Glaze [Tue, 8 Nov 2022 16:46:16 +0000 (16:46 +0000)]
MdeModulePkg: Notify BeforeExitBootServices in CoreExitBootServices

Location of notification is has been specified in UEFI v2.9.

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>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: "Min M. Xu" <min.m.xu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: "Michael D. Kinney" <michael.d.kinney@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
Message-Id: <20221108164616.3251967-4-dionnaglaze@google.com>

15 months agoMdePkg: Add EFI_EVENT_BEFORE_EXIT_BOOT_SERVICES_GUID
Dionna Glaze [Tue, 8 Nov 2022 16:46:15 +0000 (16:46 +0000)]
MdePkg: Add EFI_EVENT_BEFORE_EXIT_BOOT_SERVICES_GUID

Event group as defined in UEFI standard v2.9.

Cc: Ard Biescheuvel <ardb@kernel.org>
Cc: "Min M. Xu" <min.m.xu@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
Message-Id: <20221108164616.3251967-3-dionnaglaze@google.com>

15 months agoOvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe
Sophia Wolf [Tue, 8 Nov 2022 16:46:14 +0000 (16:46 +0000)]
OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe

When a guest OS does not support unaccepted memory, the unaccepted
memory must be accepted before returning a memory map to the caller.

EfiMemoryAcceptProtocol is defined in MdePkg and is implemented /
Installed in AmdSevDxe for AMD SEV-SNP memory acceptance.

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: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
Message-Id: <20221108164616.3251967-2-dionnaglaze@google.com>

15 months agoOvmfPkg/VirtNorFlashDxe: map flash memory as uncacheable
Gerd Hoffmann [Wed, 11 Jan 2023 18:00:23 +0000 (19:00 +0100)]
OvmfPkg/VirtNorFlashDxe: map flash memory as uncacheable

Switching from the ArmPlatformPkg/NorFlashDxe driver to the
OvmfPkg/VirtNorFlashDxe driver had the side effect that flash address
space got registered as EFI_MEMORY_WC instead of EFI_MEMORY_UC.

That confuses the linux kernel's numa code, seems this makes kernel
consider the flash being node memory.  "lsmem" changes from ...

    RANGE                                 SIZE  STATE REMOVABLE BLOCK
    0x0000000040000000-0x000000013fffffff   4G online       yes  8-39

... to ...

    RANGE                                  SIZE  STATE REMOVABLE BLOCK
    0x0000000000000000-0x0000000007ffffff  128M online       yes     0
    0x0000000040000000-0x000000013fffffff    4G online       yes  8-39

... and in the kernel log got new error lines:

    NUMA: Warning: invalid memblk node 512 [mem 0x0000000004000000-0x0000000007ffffff]
    NUMA: Faking a node at [mem 0x0000000004000000-0x000000013fffffff]

Changing the attributes back to EFI_MEMORY_UC fixes this.

Fixes: b92298af8218 ("ArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoOvmfPkg/PlatformInitLib: fix comment about uncacheable MTRRs
Laszlo Ersek [Thu, 12 Jan 2023 07:45:29 +0000 (08:45 +0100)]
OvmfPkg/PlatformInitLib: fix comment about uncacheable MTRRs

In commit 49edde15230a ("OvmfPkg/PlatformPei: set 32-bit UC area at
PciBase / PciExBarBase (pc/q35)", 2019-06-03), I forgot to update the
comment. Do it now.

Fixes: 49edde15230a5bfd6746225eb95535eaa2ec1ba4
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoNetworkPkg: Add WiFi profile sync protocol support
Zachary Clark-Williams [Wed, 10 Aug 2022 22:32:11 +0000 (15:32 -0700)]
NetworkPkg: Add WiFi profile sync protocol support

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

Enables KVM and One Click Recovery WLAN capability with WiFi Profile
Sync feature and protocol. Adding WiFiProfileSyncProtocol, which
supports the profilesync driver operations for transferring WiFi profiles
from AMT to the Supplicant. WiFiConnectionManager will check for the
WifiProfileSyncProtocol and if found will operate on the premise of a
One Click Recovery, or KVM flow with a Wifi profile provided by AMT.

Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
15 months agoArmVirtPkg/ArmVirtQemu: Avoid early ID map on ThunderX
Ard Biesheuvel [Wed, 4 Jan 2023 15:51:35 +0000 (16:51 +0100)]
ArmVirtPkg/ArmVirtQemu: Avoid early ID map on ThunderX

The early ID map used by ArmVirtQemu uses ASID scoped non-global
mappings, as this allows us to switch to the permanent ID map seamlessly
without the need for explicit TLB maintenance.

However, this triggers a known erratum on ThunderX, which does not
tolerate non-global mappings that are executable at EL1, as this appears
to result in I-cache corruption. (Linux disables the KPTI based Meltdown
mitigation on ThunderX for the same reason)

So work around this, by detecting the CPU implementor and part number,
and proceeding without the early ID map if a ThunderX CPU is detected.

Note that this requires the C code to be built with strict alignment
again, as we may end up executing it with the MMU and caches off.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: dann frazier <dann.frazier@canonical.com>
15 months agoArmVirtPkg/ArmPlatformLibQemu: Ensure that VFP is on before running C code
Ard Biesheuvel [Thu, 5 Jan 2023 13:43:14 +0000 (14:43 +0100)]
ArmVirtPkg/ArmPlatformLibQemu: Ensure that VFP is on before running C code

Now that we build the early code without strict alignment and without
suppressing the use of SIMD registers, ensure that the VFP unit is on
before entering C code.

While at it, simplyify the mov_i macro, which is only used for 32-bit
quantities.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: dann frazier <dann.frazier@canonical.com>
15 months agoDynamicTablesPkg: FdtHwInfoParserLib: Fix compatible string
Moritz Fischer [Mon, 9 Jan 2023 16:42:18 +0000 (08:42 -0800)]
DynamicTablesPkg: FdtHwInfoParserLib: Fix compatible string

Linux's cpu DT bindings call out arm,armv8 while the code previously
used arm,arm-v8, add second entry to support the arm,armv8 case.

Cc: Sami Mujawar <sami.mujawar@arm.com>
Fixes: e366a41ef0 ("DynamicTablesPkg: FdtHwInfoParser: Add GICC parser")
Signed-off-by: Moritz Fischer <moritzf@google.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
15 months agoBaseTools: Reduce the LoongArch64 compiler size
Chao Li [Fri, 30 Dec 2022 08:17:58 +0000 (16:17 +0800)]
BaseTools: Reduce the LoongArch64 compiler size

The LoongArch64 cross compiler size is too large after decompression,
using the new compiler, there is no system library and glibc.

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

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
15 months agoUefiPayloadPkg: Fix debug print error level hob not save correct
Ning Feng [Mon, 9 Jan 2023 12:28:09 +0000 (07:28 -0500)]
UefiPayloadPkg: Fix debug print error level hob not save correct

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4264
Fix debug print error level hob not save correct DebugPrintErrorlevel
Should cover the case:
Header.Length == UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD ()
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Ning Feng <ning.feng@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
15 months agoRevert "UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd"
Yuanhao Xie [Mon, 9 Jan 2023 03:37:24 +0000 (11:37 +0800)]
Revert "UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd"

This reverts commit 7bda8c648192d76f7b3f7cee54bd7b1c86a6a84f.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4234
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
15 months agoRevert "OvmfPkg: Add CpuPageTableLib required by MpInitLib."
Yuanhao Xie [Mon, 9 Jan 2023 03:37:23 +0000 (11:37 +0800)]
Revert "OvmfPkg: Add CpuPageTableLib required by MpInitLib."

This reverts commit 4a8642422460635462d315defe4ca84bf6d33351 as the
commit 73ccde8 introduced CpuPageTableLib dependency which resolved
for OvmfPkg is to be reverted.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4234
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>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
15 months agoRevert "UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib."
Yuanhao Xie [Mon, 9 Jan 2023 03:37:22 +0000 (11:37 +0800)]
Revert "UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib."

This reverts commit 3f378450dfafc11754bfdb64af28060ec8466acb, since the
commit 73ccde8 introduced CpuPageTableLib dependency which resolved
for UefiPayloadPkg need to be reverted.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4234
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
15 months agoRevert "UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS."
Yuanhao Xie [Mon, 9 Jan 2023 03:37:21 +0000 (11:37 +0800)]
Revert "UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS."

This reverts commit 73ccde8f6d04a246377cabaed2875e69d4b6b719 since it
results in a hang of the IA32 processor and needs further clean-up.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4234
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
15 months agoUefiPayloadPkg: Move RTC PCD to dynamic PCD
KasimX Liu [Wed, 28 Dec 2022 07:57:23 +0000 (15:57 +0800)]
UefiPayloadPkg: Move RTC PCD to dynamic PCD

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

In order to remove RTC_INDEX/RTC_TARGET from
the UplBuild macro list,change the RTC_INDEX
/RTC_TARGET type from PcdsFixedAtBuild to PcdsDynamicEx

Reviewed-by: Guo Dong <guo.dong@intel.com>
Cc: 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>
15 months agoMaintainers.txt: Update reviewers for OVMF/Confidential Computing
Michael Roth [Wed, 21 Dec 2022 17:24:05 +0000 (01:24 +0800)]
Maintainers.txt: Update reviewers for OVMF/Confidential Computing

Add myself as a reviewer for OVMF/Confidential Computing patches.

Remove Brijesh while at it, since he is no longer at AMD, and the email
is no longer valid.

Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
15 months agoSecurityPkg: Move TdTcg2Dxe from OvmfPkg to SecurityPkg
Min M Xu [Wed, 4 Jan 2023 13:14:05 +0000 (21:14 +0800)]
SecurityPkg: Move TdTcg2Dxe from OvmfPkg to SecurityPkg

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

The TdTcg2Dxe lives in the OvmfPkg instead of the SecurityPkg. Having
the TdTcg2Dxe at the same place as Tcg2Dxe will be easier for platforms to
consume.

Definition of PcdCcEventlogAcpiTableLaml and PcdCcEventlogAcpiTableLasa
are also moved from OvmfPkg.dec to SecurityPkg.dec.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
15 months agoMaintainers.txt: designate Gerd Hoffmann as UefiCpuPkg reviewer
Laszlo Ersek [Tue, 3 Jan 2023 16:05:39 +0000 (17:05 +0100)]
Maintainers.txt: designate Gerd Hoffmann as UefiCpuPkg reviewer

I suggest that Gerd be notified about all UefiCpuPkg patches, so he may
take a quick look at, or (by his preference) even test, the proposed
change, in a genuine QEMU/KVM environment.

Assuming this patch is accepted -- subsequently, please *wait* for Gerd's
approval on UefiCpuPkg patches, before merging them.

Notes:

- It's perfectly fine for a reviewer to give an A-b just so the review
  process be unblocked, if they don't have anything to add, or don't have
  time to review or test in detail. The point is that someone outside of
  Intel should *consistently get a chance* to raise concerns about
  UefiCpuPkg patches before they are merged.

- My A-b's and R-b's on UefiCpuPkg patches were never supposed to be
  "sufficient", only "necessary", for merging. The intent is the same
  here, with Gerd's designation as a reviewer.

Cc: Andrew Fish <afish@apple.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230103160539.87830-1-lersek@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
15 months ago.azurepipelines: Skip CodeCoverage if coverage.xml not found
Gua Guo [Thu, 5 Jan 2023 01:50:20 +0000 (09:50 +0800)]
.azurepipelines: Skip CodeCoverage if coverage.xml not found

Skip CodeCoverage if coverage.xml not found

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
15 months agoMaintainers.txt: Update NetworkPkg & MM modules Reviewer
Wu, Jiaxin [Thu, 15 Dec 2022 09:41:00 +0000 (17:41 +0800)]
Maintainers.txt: Update NetworkPkg & MM modules Reviewer

This is to change NetworkPkg & MM modules Reviewer.

Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
15 months agoOvmfPkg/SmmCpuFeaturesLib: drop obsolete API implementation
Laszlo Ersek [Tue, 3 Jan 2023 15:02:44 +0000 (16:02 +0100)]
OvmfPkg/SmmCpuFeaturesLib: drop obsolete API implementation

Commit 0426115b6738 ("UefiCpuPkg: Remove unused API in
SmmCpuFeaturesLib.h", 2022-12-21) removed the declaration of the function
SmmCpuFeaturesAllocatePageTableMemory() from the "SmmCpuFeaturesLib.h"
library class header.

Remove the API's (null-)implementation from OvmfPkg/SmmCpuFeaturesLib as
well.

Testing: OVMF builds, boots, and suspends/resumes (see earlier in this
series).

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4235
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoUefiCpuPkg/SmmCpuFeaturesLib: drop obsolete API implementation
Laszlo Ersek [Tue, 3 Jan 2023 15:02:43 +0000 (16:02 +0100)]
UefiCpuPkg/SmmCpuFeaturesLib: drop obsolete API implementation

Commit 0426115b6738 ("UefiCpuPkg: Remove unused API in
SmmCpuFeaturesLib.h", 2022-12-21) removed the declaration of the function
SmmCpuFeaturesAllocatePageTableMemory() from the "SmmCpuFeaturesLib.h"
library class header.

Remove the API's (null-)implementation from UefiCpuPkg/SmmCpuFeaturesLib
as well.

Build-tested with:

  build -a IA32 -a X64 -b NOOPT -p UefiCpuPkg/UefiCpuPkg.dsc -t GCC5

Cc: Eric Dong <eric.dong@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4235
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Dun Tan <dun.tan@intel.com>
15 months agoOvmfPkg: raise DXEFV size to 13 MB in the traditional platform FDFs
Laszlo Ersek [Tue, 3 Jan 2023 15:02:42 +0000 (16:02 +0100)]
OvmfPkg: raise DXEFV size to 13 MB in the traditional platform FDFs

Similarly to the "cadence" mentioned in commit d272449d9e1e ("OvmfPkg:
raise DXEFV size to 11 MB", 2018-05-29), it's been ~1.75 years since
commit 5e75c4d1fe4f ("OvmfPkg: raise DXEFV size to 12 MB", 2020-03-11),
and we've outgrown DXEFV again (with NOOPT builds).  Increase the DXEFV
size to 13MB now.

Do not modify all platform FDF files under OvmfPkg.  "BhyveX64.fdf" is
still at 11MB, "OvmfXen.fdf" at 10MB.  The "AmdSevX64.fdf",
"CloudHvX64.fdf", "IntelTdxX64.fdf" and "MicrovmX64.fdf" flash devices
could be modified similarly (from 12MB to 13MB), but I don't use or build
those platforms.

Tested on:
- IA32, q35, SMM_REQUIRE, Fedora 30 guest
- X64, pc (i440fx), no SMM, RHEL-7.9 guest
- IA32X64, q35, SMM_REQUIRE, RHEL-7.9 guest

Test steps:
- configure 3 VCPUs
- boot
- run "taskset -c $I efibootmgr" with $I covering 0..2
- systemctl suspend
- resume from virt-manager
- run "taskset -c $I efibootmgr" with $I covering 0..2

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>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4236
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoOvmfPkg/QemuVideoDxe/VbeShim.sh: remove end-of-options delimiter for nasm
Laszlo Ersek [Tue, 3 Jan 2023 15:02:41 +0000 (16:02 +0100)]
OvmfPkg/QemuVideoDxe/VbeShim.sh: remove end-of-options delimiter for nasm

Per my bisection: nasm broke the parsing of the "--" end-of-options
delimiter in commit 55568c1193df ("nasm: scan the command line twice",
2016-10-03), part of the nasm-2.13 release. The parsing remains broken in
at least nasm-2.15.03. The (invalid) error message is: "more than one
input file specified". I've filed the following ticket for upstream nasm
(and ndisasm): <https://bugzilla.nasm.us/show_bug.cgi?id=3392829>.

Since the delimiter is not necessary in practice (due to $STEM being
"VbeShim", i.e., not starting with a hyphen), simply remove the delimiter.

Tested by enabling DEBUG in "VbeShim.asm", running the script, building
OVMF, booting Windows 7, and checking the firmware log (debug console).

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3876
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoMdeModulePkg/Bus/Pci/XhciDxe: Reset port if status change returns an error
Sean Rhodes [Fri, 16 Dec 2022 12:24:18 +0000 (12:24 +0000)]
MdeModulePkg/Bus/Pci/XhciDxe: Reset port if status change returns an error

Force resetting the port by clearing the USB_PORT_STAT_C_RESET bit in
PortChangeStatus when XhcPollPortStatusChange fails

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
15 months ago.azurepipelines: Install code coverage tool
Gua Guo [Tue, 8 Nov 2022 08:38:49 +0000 (16:38 +0800)]
.azurepipelines: Install code coverage tool

For Windows add below tool for code coverage
1. OpenCppCoverage: parsing pdb file to generate coverage
data
2. pycobertura: show up html format data for coverage data

For Linux add below tool for code coverage
1. lcov: parsing gcda gcno file to generate coverage data
2. lcov-cobertura: convert coverage data to cobertura format
3. pycobertura: show up html format data for coverage data

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
15 months agoBaseTools/Plugin: Add coverage support for Unit Test
Gua Guo [Tue, 27 Sep 2022 04:25:17 +0000 (12:25 +0800)]
BaseTools/Plugin: Add coverage support for Unit Test

For GCC, use lcov to generate Unit Test code coverage
report

For VS2019, use OpenCppCoverage to generate code
coverage report

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Liming Gao <gaoliming@bysoft.com.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
15 months agoUnitTestFrameworkPkg: Add code coverage support for GCC
Gua Guo [Tue, 27 Sep 2022 04:24:18 +0000 (12:24 +0800)]
UnitTestFrameworkPkg: Add code coverage support for GCC

In order to collect code coverage after running executable
file, generate *.gcda and *.gcno file that require by lcov tool
to generate code coverage report.

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
15 months agoUefiCpuPkg/PiSmmCpuDxeSmm:Fix PF issue caused by smm page table code
Tan, Dun [Tue, 3 Jan 2023 05:56:17 +0000 (13:56 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm:Fix PF issue caused by smm page table code

When setting new page table pool to RO, only disable/enable WP when
Cr0.WP has been set to 1 to fix potential PF caused by b822be1a20
(UefiCpuPkg/PiSmmCpuDxeSmm: Introduce page table pool mechanism).
With previous code, if someone want to modify the page table and
Cr0.WP has been cleared before modify page table, Cr0.WP may be set
to 1 again since new pool may be generated during this process
Then PF fault may happens.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
16 months agoBaseTools: Generate deps for Arm targets
Jake Garver via groups.io [Thu, 8 Dec 2022 16:22:11 +0000 (00:22 +0800)]
BaseTools: Generate deps for Arm targets

Prior to this change, deps were not generated for Arm and AARCH64
libraries when MODULE_TYPE was BASE, SEC, PEI_CORE, or PIEM. That
resulted in bad incremental builds.

Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
16 months agoBaseTools: Use BUILD_CC when checking gcc version in DevicePath
Jake Garver [Tue, 20 Dec 2022 13:14:12 +0000 (21:14 +0800)]
BaseTools: Use BUILD_CC when checking gcc version in DevicePath

When checking the version in DevicePath's Makefile, use BUILD_CC instead
of assuming "gcc".  BUILD_CC is set in header.makefile and is the
compiler that will actually be used to build DevicePath.  It defaults to
"gcc", but may be overridden.

Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
16 months agoBaseTools: Fix IA32 UINT64 alignment for CLANG toolchains
Pedro Falcato [Fri, 16 Dec 2022 19:50:20 +0000 (03:50 +0800)]
BaseTools: Fix IA32 UINT64 alignment for CLANG toolchains

Currently, UINT64 is not 8-byte aligned for CLANG* toolchains on IA32,
which causes ABI differences between IA32 and X64 in such simple examples as:

struct S {UINT32 A; UINT64 B;};

Pass -malign-double to align it to 8 bytes, as is done for GCC already.

Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Marvin H?user <mhaeuser@posteo.de>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
16 months agoOvmfPkg: Use NestedInterruptTplLib in nested interrupt handlers
Michael Brown [Fri, 9 Dec 2022 10:20:27 +0000 (10:20 +0000)]
OvmfPkg: Use NestedInterruptTplLib in nested interrupt handlers

Prevent stack underrun in the event of a timer interrupt storm in
LocalApicTimerDxe and 8254TimerDxe interrupt handlers by using the
helper functions provided by NestedInterruptTplLib.

This fixes the same problem as addressed in commit 239b50a86
("OvmfPkg: End timer interrupt later to avoid stack overflow under
load"), but does so without breaking nested timer interrupts.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2815
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
16 months agoOvmfPkg: Add library to handle TPL from within nested interrupt handlers
Michael Brown [Fri, 9 Dec 2022 10:20:24 +0000 (10:20 +0000)]
OvmfPkg: Add library to handle TPL from within nested interrupt handlers

UEFI requires us to support nested interrupts, but provides no way for
an interrupt handler to call RestoreTPL() without implicitly
re-enabling interrupts.  In a virtual machine, it is possible for a
large burst of interrupts to arrive.  We must prevent such a burst
from leading to stack underrun, while continuing to allow nested
interrupts to occur.

This can be achieved by allowing, when provably safe to do so, an
inner interrupt handler to return from the interrupt without restoring
the TPL and with interrupts remaining disabled after IRET, with the
deferred call to RestoreTPL() then being issued from the outer
interrupt handler.  This is necessarily messy and involves direct
manipulation of the interrupt stack frame, and so should not be
implemented as open-coded logic within each interrupt handler.

Add the Nested Interrupt TPL Library (NestedInterruptTplLib) to
provide helper functions that can be used by nested interrupt handlers
in place of RaiseTPL()/RestoreTPL().

Example call tree for a timer interrupt occurring at TPL_APPLICATION
with a nested timer interrupt that makes its own call to RestoreTPL():

  outer TimerInterruptHandler()
    InterruptedTPL == TPL_APPLICATION
    ...
    IsrState->InProgressRestoreTPL = TPL_APPLICATION;
    gBS->RestoreTPL (TPL_APPLICATION);
      EnableInterrupts();
      dispatch a TPL_CALLBACK event
        gEfiCurrentTpl = TPL_CALLBACK;
        nested timer interrupt occurs
        inner TimerInterruptHandler()
          InterruptedTPL == TPL_CALLBACK
          ...
          IsrState->InProgressRestoreTPL = TPL_CALLBACK;
          gBS->RestoreTPL (TPL_CALLBACK);
            EnableInterrupts();
          DisableInterrupts();
          IsrState->InProgressRestoreTPL = TPL_APPLICATION;
          IRET re-enables interrupts
      ... finish dispatching TPL_CALLBACK events ...
      gEfiCurrentTpl = TPL_APPLICATION;
    DisableInterrupts();
    IsrState->InProgressRestoreTPL = 0;
    sees IsrState->DeferredRestoreTPL == FALSE and returns
    IRET re-enables interrupts

Example call tree for a timer interrupt occurring at TPL_APPLICATION
with a nested timer interrupt that defers its call to RestoreTPL() to
the outer instance of the interrupt handler:

  outer TimerInterruptHandler()
    InterruptedTPL == TPL_APPLICATION
    ...
    IsrState->InProgressRestoreTPL = TPL_APPLICATION;
    gBS->RestoreTPL (TPL_APPLICATION);
      EnableInterrupts();
      dispatch a TPL_CALLBACK event
      ... finish dispatching TPL_CALLBACK events ...
      gEfiCurrentTpl = TPL_APPLICATION;
      nested timer interrupt occurs
      inner TimerInterruptHandler()
        InterruptedTPL == TPL_APPLICATION;
        ...
        sees InterruptedTPL == IsrState->InProgressRestoreTPL
        IsrState->DeferredRestoreTPL = TRUE;
        DisableInterruptsOnIret();
        IRET returns without re-enabling interrupts
    DisableInterrupts();
    IsrState->InProgressRestoreTPL = 0;
    sees IsrState->DeferredRestoreTPL == TRUE and loops
    IsrState->InProgressRestoreTPL = TPL_APPLICATION;
    gBS->RestoreTPL (TPL_APPLICATION);  <-- deferred call
      EnableInterrupts();
    DisableInterrupts();
    IsrState->InProgressRestoreTPL = 0;
    sees IsrState->DeferredRestoreTPL == FALSE and returns
    IRET re-enables interrupts

Cc: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
16 months agoOvmfPkg: Send EOI before RestoreTPL() in timer interrupt handlers
Michael Brown [Fri, 9 Dec 2022 10:20:21 +0000 (10:20 +0000)]
OvmfPkg: Send EOI before RestoreTPL() in timer interrupt handlers

Deferring the EOI until after the call to RestoreTPL() means that any
callbacks invoked by RestoreTPL() will run with timer interrupt
delivery disabled.  If any such callbacks themselves rely on timers to
implement timeout loops, then the callbacks will get stuck in an
infinite loop from which the system will never recover.

This reverts commit 239b50a86 ("OvmfPkg: End timer interrupt later to
avoid stack overflow under load").

Cc: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
16 months agoOvmfPkg/PlatformInitLib: pass through reservations from qemu
Gerd Hoffmann [Wed, 7 Dec 2022 05:32:15 +0000 (06:32 +0100)]
OvmfPkg/PlatformInitLib: pass through reservations from qemu

qemu uses the etc/e820 fw_cfg file not only for memory, but
also for reservations.  Handle reservations by adding resource
descriptor hobs for them.

A typical qemu configuration has a small reservation between
lapic and flash:

  # sudo cat /proc/iomem
  [ ... ]
  fee00000-fee00fff : Local APIC
  feffc000-feffffff : Reserved          <= HERE
  ffc00000-ffffffff : Reserved
  [ ... ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoOvmfPkg: fix PlatformConfig
Gerd Hoffmann [Fri, 9 Dec 2022 11:22:44 +0000 (12:22 +0100)]
OvmfPkg: fix PlatformConfig

The Hii form is named "MainFormState" and the EFI variable is named
"PlatformConfig".  Take into account the different names.

Fixes: aefcc91805fd ("OvmfPkg/PlatformDxe: Handle all requests in ExtractConfig and RouteConfig")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoUefiPayloadPkg: Fix boot issue for non-universal payload
Guo Dong [Wed, 21 Dec 2022 18:36:37 +0000 (11:36 -0700)]
UefiPayloadPkg: Fix boot issue for non-universal payload

BDS module was moved from DXEFV to newly created BDSFV recently.
Non-universal UEFI payload doesn't support multiple FV, so it failed
to boot since BDS module could not be found.
This patch add BDS back to DXEFV when UNIVERSAL_PAYLOAD is not set.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
16 months agoArmVirtPkg: Remove CcProbeLib from ArmVirtQemu.dsc
Min M Xu [Thu, 22 Dec 2022 13:11:56 +0000 (21:11 +0800)]
ArmVirtPkg: Remove CcProbeLib from ArmVirtQemu.dsc

Since CcProbeLib is not used in AcpiPlatformDxe, CcProbeLib can be removed
from ArmVirtQemu.dsc.

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>
Signed-off-by: Min Xu <min.m.xu@intel.com>
16 months agoOvmfPkg/AcpiPlatformDxe: Check PcdConfidentialComputingGuestAttr
Min M Xu [Thu, 22 Dec 2022 13:11:55 +0000 (21:11 +0800)]
OvmfPkg/AcpiPlatformDxe: Check PcdConfidentialComputingGuestAttr

PcdConfidentialComputingGuestAttr can be used to check the cc guest
type, including td-guest or sev-guest. CcProbe() can do the same
thing but CcProbeLib should be included in the dsc which uses
AcpiPlatformDxe. The difference between PcdConfidentialComputingGuestAttr
and CcProbe() is that PcdConfidentialComputingGuestAttr cannot be used
in multi-processor scenario but CcProbe() can. But there is no such
issue in AcpiPlatformDxe.

So we use PcdConfidentialComputingGuestAttr instead of CcProbeLib so that
it is simpler.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
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>
16 months agoPcAtChipsetPkg: Move RTC PCD to dynamic PCD
KasimX Liu [Wed, 14 Dec 2022 07:56:23 +0000 (15:56 +0800)]
PcAtChipsetPkg: Move RTC PCD to dynamic PCD

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

In order to remove RTC_INDEX/RTC_TARGET from
the UplBuild macro list,change the RTC_INDEX
/RTC_TARGET type from PcdsFixedAtBuild to PcdsDynamicEx

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>
16 months agotools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS
Gerd Hoffmann [Wed, 30 Nov 2022 09:44:14 +0000 (17:44 +0800)]
tools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS

Fixes problems due to code assuming it runs with frame pointers and thus
updates rbp / ebp registers when switching stacks.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Liming Gao <gaoliming@byosoft.com.cn>
16 months agotools_def: remove GCC_IA32_CC_FLAGS/GCC_X64_CC_FLAGS
Gerd Hoffmann [Wed, 30 Nov 2022 09:44:13 +0000 (17:44 +0800)]
tools_def: remove GCC_IA32_CC_FLAGS/GCC_X64_CC_FLAGS

They are not used anywhere.  Remove them.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
16 months agoCryptoPkg: Need to enable crypto functions
Judah Vang [Wed, 21 Dec 2022 03:04:18 +0000 (11:04 +0800)]
CryptoPkg: Need to enable crypto functions

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

V2: Update Readme and CryptoPkg.dsc to reflect changes and be in sync.

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: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoUefiCpuPkg: Simplify the code to set smm page table as RO
Tan, Dun [Wed, 21 Dec 2022 04:21:56 +0000 (12:21 +0800)]
UefiCpuPkg: Simplify the code to set smm page table as RO

Simplify the code to set memory used by smm page table as RO.
Since memory used by smm page table are in PageTablePool list,
we only need to set all PageTablePool as ReadOnly in smm page
table itself. Also, we only need to flush tlb once after
setting all page table pool as Read Only.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
16 months agoUefiCpuPkg: Remove unused API in SmmCpuFeaturesLib.h
Tan, Dun [Wed, 21 Dec 2022 04:21:55 +0000 (12:21 +0800)]
UefiCpuPkg: Remove unused API in SmmCpuFeaturesLib.h

Remove SmmCpuFeaturesAllocatePageTableMemory in this headfile.
This API is not used by PiSmmCpuDxeSmm driver any more. Also
no other files use this API.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
16 months agoUefiCpuPkg/PiSmmCpuDxeSmm: Introduce page table pool mechanism
duntan [Wed, 21 Dec 2022 04:21:54 +0000 (12:21 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm: Introduce page table pool mechanism

Introduce page table pool mechanism for smm page table to simplify
page table memory management and protection. This mechanism has been
used in DxeIpl. The basic idea is to allocate a bunch of continuous
pages of memory in advance, and all future page tables consumption
will happen in those pool instead of system memory.
Since we have centralized page tables, we only need to mark all page
table pools as RO, instead of searching page table memory layer by
layer in smm page table. Once current page table pool has been used
up, another memory pool will be allocated and the new pool will also
be set as RO if current page table memory has been marked as RO.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
16 months agoOvmfPkg/OvmfXen: Build platform info HOB in XenPlatformPei
Anthony PERARD [Mon, 19 Dec 2022 16:36:20 +0000 (00:36 +0800)]
OvmfPkg/OvmfXen: Build platform info HOB in XenPlatformPei

Copy the function BuildPlatformInfoHob() from OvmfPkg/PlatformPei.

QemuFwCfgLib expect this HOB to be present, or fails to do anything.
InternalQemuFwCfgIsAvailable() from QemuFwCfgPeiLib module will not
check if the HOB is actually present for example and try to use a NULL
pointer.

Fixes: cda98df16228 ("OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported")
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>