]> xenbits.xensource.com Git - people/aperard/ovmf.git/log
people/aperard/ovmf.git
7 months agoCryptoPkg/OpensslLib: Create SM3-only version of the library master
Ard Biesheuvel [Fri, 13 Sep 2024 11:00:19 +0000 (13:00 +0200)]
CryptoPkg/OpensslLib: Create SM3-only version of the library

Create a special OpensslLib implementation that only exposes the SM3
routines that MbedTlsLib borrows from OpensslLib, to avoid having to
pull in other parts of OpenSSL that are not needed (e.g., via the
library constructor)

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoCryptoPkg: Add unit testcase for SM3
Ard Biesheuvel [Thu, 5 Sep 2024 08:29:18 +0000 (10:29 +0200)]
CryptoPkg: Add unit testcase for SM3

SM3 needs to be tested so we can verify that alternative implementations
(such as the one I will be contributing to BaseCryptLibMbedTls) as well
as the reference implementation produce the expected value.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoCryptoPkg/MbedTls CLANGDWARF: Replace outdated CLANG3x references
Ard Biesheuvel [Wed, 11 Sep 2024 10:40:18 +0000 (12:40 +0200)]
CryptoPkg/MbedTls CLANGDWARF: Replace outdated CLANG3x references

The CLANG35 and CLANG38 toolchain specifiers have been phased out, and
replaced with CLANGDWARF. Update the MbedTls library definitions
accordingly.

While at it, switch to the gnu99 C dialect, which is a better match with
GCC in C99 mode, which includes GCC specific GNU extensions.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoBaseTools: Fix multiple 'invalid escape sequence' warnings in tests
Mike Beaton [Wed, 18 Sep 2024 15:40:08 +0000 (16:40 +0100)]
BaseTools: Fix multiple 'invalid escape sequence' warnings in tests

In Python 3.12 invalid escape sequences in strings moved from
DeprecationWarning to SyntaxWarning
(ref https://docs.python.org/3/whatsnew/changelog.html#python-3-12-0-final
and search for gh-98401). In a future Python version this will become
SyntaxError.

Multiple instances of these SyntaxWarnings are currently printed when
running the BaseTools tests using Python 3.12 (though without actually
failing the affected tests).

This commit updates all lines which were causing this type of warning.

Typical examples which needed fixing are:

- "BaseTools\Source\Python" representing a path: "\S" and "\P" are invalid
escape sequences, therefore left unchanged, therefore the test works
(with a warning in Python 3.12). r"BaseTools\Source\Python" represents
the same string, but with escapes turned off completely thus no warning.

- Where '\t\s' is used as a regex pattern, then chr(9) + '\\s' is sent
to the regex parser (with a warning in Python 3.12) since '\s' is not a
valid Python escape sequence. This works correctly, though arguably for
the wrong reasons. r'\t\s' sends the same as '\\t\\s', as originally
intended and with no warning.

(Note that ' and " are not fundamentally different in Python.)

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoUefiPayloadPkg: Add LOCKBOX_SUPPORT in UPL and set it as FALSE in default
Zhou Jianfeng [Sun, 22 Sep 2024 01:27:08 +0000 (09:27 +0800)]
UefiPayloadPkg: Add LOCKBOX_SUPPORT in UPL and set it as FALSE in default

S3 performance table is saved to LockBox. Without LockBox, S3 performance
data will lost.

Add LOCKBOX_SUPPORT to optionally select LockBox libary instance,
default value is FALSE.

Signed-off-by: Zhou Jianfeng <jianfeng.zhou@intel.com>
7 months agoUefiPayloadPkg: Align relocation item with spec
Gua Guo [Sat, 21 Sep 2024 09:16:01 +0000 (17:16 +0800)]
UefiPayloadPkg: Align relocation item with spec

Currently, FIT Payload data relocation data has
some minor error with Universal Payload
Specification v0.9.1 section 2.4.3.

Signed-off-by: Gua Guo <gua.guo@intel.com>
7 months agoBaseTools: Update RETURN_ERROR Macro in BaseTypes.h
Abdul Lateef Attar [Thu, 19 Sep 2024 09:26:10 +0000 (09:26 +0000)]
BaseTools: Update RETURN_ERROR Macro in BaseTypes.h

This patch is to sync RETURN_ERROR macro with the
MdePkg/Include/Base.h

Ref: 1a89d9887f MdePkg:Update Return Error Macro in Base.h

Fixing RETURN_ERROR macro.
It is causing problem in Coverity Static analysis tool
as we are directly converting the UINT value to INTN.

Changing value from UINT to INTN might cause problema
Here we know that the values would not be in loss of data.
To increase the code quality and increase the static tool
analysis score we have to change it

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
7 months agoSet PcdSerialClockRate from SerialPortInfo in UefiPayloadEntry
Matt DeVillier [Mon, 31 Jul 2023 16:40:32 +0000 (11:40 -0500)]
Set PcdSerialClockRate from SerialPortInfo in UefiPayloadEntry

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
7 months agoUefiCpuPkg/MtrrLib: MtrrLibIsMtrrSupported always return FALSE in TD-Guest
Min M Xu [Mon, 9 Sep 2024 05:33:51 +0000 (13:33 +0800)]
UefiCpuPkg/MtrrLib: MtrrLibIsMtrrSupported always return FALSE in TD-Guest

Currently, TDX exposes MTRR CPUID bit to TDX VM. So based on the CPUID,
the guest software components (OVMF/TDVF and guest kernel) will access
MTRR MSRs. One problem for guest to use of MTRR is the change of MTRR
setting needs to set CR0.CD=1, which will case #VE for TDX.

For Linux kernel, there is a mechanism called SW defined MTRR introduced
by the patch https://lore.kernel.org/all/20230502120931.
20719-4-jgross@suse.com/. If this is integrated for TDX guest, then Linux
kernel will not access any MTRR MSRs.

So we update MtrrLibIsMtrrSupported() to always return false for TD-Guest,
then TDVF will not access MTRR MSRs at all.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Binbin Wu <binbin.wu@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
7 months agoMaintainers.txt: Add Sami Mujawar as maintainer for Arm modules
Sami Mujawar [Wed, 18 Sep 2024 19:53:04 +0000 (20:53 +0100)]
Maintainers.txt: Add Sami Mujawar as maintainer for Arm modules

I intend to help with maintenance of the following Arm modules:
  ArmPkg/
  ArmPlatformPkg/
  ArmVirtPkg/
  MdePkg/Include/Library/ArmLib.h

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
7 months agoDynamicTablesPkg: Adds ACPI SSDT HPET table generator
Abdul Lateef Attar [Fri, 6 Sep 2024 05:15:07 +0000 (05:15 +0000)]
DynamicTablesPkg: Adds ACPI SSDT HPET table generator

Adds X64 ACPI SSDT HPET table generator library.
Updates acpi standard table enum with hpet.
Generate ACPI HPET device as per specification.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
7 months agoDynamicTablesPkg: Adds ACPI HPET table generator
Abdul Lateef Attar [Tue, 3 Sep 2024 09:46:36 +0000 (09:46 +0000)]
DynamicTablesPkg: Adds ACPI HPET table generator

Adds X64 ACPI HPET table generator library.
Updates acpi standard table enum with hpet.
Updates X64 namespace object.
Updates the object parser.
Updates the Readme.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
7 months agoMdeModulePkg/TerminalDxe: Add VTUTF8 to Putty function key map
Phil Noh [Fri, 13 Sep 2024 20:43:57 +0000 (15:43 -0500)]
MdeModulePkg/TerminalDxe: Add VTUTF8 to Putty function key map

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

This patch is to support VTUTF8 type for Putty function key map.
In Putty, it is required for translating a stream of Unicode characters
for function keys on UTF8 correctly.

Signed-off-by: Phil Noh <Phil.Noh@amd.com>
7 months agoBaseTools/tools_def ARM: Disable stack protector with CLANGDWARF
Ard Biesheuvel [Mon, 16 Sep 2024 16:39:35 +0000 (18:39 +0200)]
BaseTools/tools_def ARM: Disable stack protector with CLANGDWARF

Clang insists on emitting a movt/movw pair into the function
pro/epilogues to load the stack protector reference value from memory,
and this movt/movw pair may turn out non-consecutively in the
instruction stream.

The resulting symbol reference cannot be fixed up by GenFw, as PE/COFF
always treats movt/movw as a pair, and the ELF-to-PE conversion will
therefore fail.

Just disable the stack protector when using CLANGDWARF.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoMaintainers: Remove Ard Biesheuvel from all packages
Ard Biesheuvel [Mon, 16 Sep 2024 08:33:17 +0000 (10:33 +0200)]
Maintainers: Remove Ard Biesheuvel from all packages

As a Tianocore maintainer, I am responsible for the packages that I
maintain, and am therefore expected to respond in a timely manner to
pull requests affecting those packages. With the updated GitHub-based
workflow, this now results in daily GitHub spam inviting me to respond
to each PR as they are created by the respective authors.

However, I strongly feel that with responsibility should come with
delegated authority as well, and this has been stripped away over the
past couple of years. When other maintainers fail to respond (which has
become more common recently), or when there are glitches in the CI, I no
longer have any means to take charge and correct the situation.

The upshot is that I am struggling to do my work as a maintainer,
spending 90% of my time dealing with GitHub CI technicalities, or being
blocked on other work that is completely ignored by the other
maintainers.

This is a waste of my time, and therefore, of my employer's money, so I
feel I can no longer justify my involvement. I am therefore stepping
down as a maintainer.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoUefiCpuPkg/AmdSmmCpuFeaturesLib: Skip SMBASE configuration
Phil Noh [Mon, 9 Sep 2024 22:14:03 +0000 (17:14 -0500)]
UefiCpuPkg/AmdSmmCpuFeaturesLib: Skip SMBASE configuration

This patch is to avoid configure SMBASE if SmBase relocation has been
done. If gSmmBaseHobGuid found, means SmBase info has been relocated
and recorded in the SmBase array. No need to do the relocation in
SmmCpuFeaturesInitializeProcessor().

Signed-off-by: Phil Noh <Phil.Noh@amd.com>
7 months agoUefiPayloadPkg: Move FADT check to consumer coode.
Chasel Chiu [Thu, 12 Sep 2024 22:42:41 +0000 (15:42 -0700)]
UefiPayloadPkg: Move FADT check to consumer coode.

ACPI FADT HW register interface fields are
optional but current UPL common entry code made it
as mandatory which caused compatibility issue on
some platforms.

Solution is to move those FADT HW register fields
check code to consumer code so only ASSERT when
those fields are consumed with error.

Currently only AcpiTimerLib and ResetSystemLib
consuming those register fields so if platforms
configured UPL to different library instances the
FADT HW register fields are not consumed thus will
not cause ASSERT.

Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
7 months agoRedfishPkg/Include: move protocol version definition to protocol header
Nickle Wang [Mon, 9 Sep 2024 03:18:44 +0000 (11:18 +0800)]
RedfishPkg/Include: move protocol version definition to protocol header

Move protocol interface version definition to public protocol header
file. So, driver can decide which version it is supported.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
7 months agoArmPkg: Avoid building ArmCrashDumpDxe on ARM
Ard Biesheuvel [Mon, 16 Sep 2024 06:20:07 +0000 (08:20 +0200)]
ArmPkg: Avoid building ArmCrashDumpDxe on ARM

For reasons that are unclear, the Linaro EDK2 CI is throwing errors when
building ArmCrashDumpDxe with CLANGDWARF, as the resulting build
contains non-adjacet MOVW/MOVT pairs, which cannot be relocated
correctly in PE/COFF.

Let's build it only for AARCH64 - its utility on ARM is doubtful anyway.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoNetworkPkg/HttpBootDxe: Correctly uninstall HttpBootCallbackProtocol
Mike Beaton [Fri, 13 Sep 2024 17:07:36 +0000 (18:07 +0100)]
NetworkPkg/HttpBootDxe: Correctly uninstall HttpBootCallbackProtocol

The existing HttpBootUninstallCallback was passing the wrong handle (the
PrivateData root controller handle, not the correct child IPv4 or IPv6
NIC controller handle; cf HttpBootInstallCallback for matching logic) and
was also passing the address of a pointer to the interface to be removed
rather than the pointer itself, so always failed with EFI_NOT_FOUND.

This resulted in the prior behaviour that if multiple HTTP boot attempts
were made, on the second and subsequent attempts the instance of this
protocol installed by the first attempt would be re-used. As long as only
one driver using the protocol is installed, this ends up producing the
same results as if the protocol had been uninstalled then reinstalled
correctly.

After this commit, the protocol is installed at the start of an HTTP boot
attempt and uninstalled it at the end of it (assuming nothing else has
accessed the protocol in a way which blocks the uninstall).

It might seem attractive to add an ASSERT to confirm when debugging
that the uninstall succeeds as expected, but this is recommended against
because uninstallation of protocol interfaces is allowed to fail under
the UEFI model:
https://edk2.groups.io/g/devel/message/117469.
An ASSERT could therefore arise from a sequence of events which is
perfectly valid - or at least is out of the control of this driver.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoUefiPayloadPkg: Handle simple reserved ranges from DT
Dhaval [Tue, 13 Aug 2024 14:44:40 +0000 (20:14 +0530)]
UefiPayloadPkg: Handle simple reserved ranges from DT

DT has a way to provide reserved images in a simpler tabular
manner. UPL should be able to support that.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoMdePkg: Add reserved mem fdt helpers
Dhaval [Wed, 5 Jun 2024 04:30:32 +0000 (10:00 +0530)]
MdePkg: Add reserved mem fdt helpers

Devicetree defines a short hand way of defining reserved memory
ranges. Add APIs to access such nodes

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoUefiPayloadPkg: Add support for Root bridge parser
Dhaval [Tue, 13 Aug 2024 07:03:58 +0000 (12:33 +0530)]
UefiPayloadPkg: Add support for Root bridge parser

In order to properly enable multisegment RB, we need
to grab ecam data from the FDT for each bridge.
Current UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES struct from
MdeModulePkg does not include definition for ecam. In
order to maintain backward compatibility and also avoid
diverging too much from core, we are going to define a
new HOB for UPL segment information and pass it to
GetPciSegmentInfo function. Ths function then grabs specifically
ecam info from the segment hob along with other rb specific
information to create final RB info required by multi segment
PCI driver.

Additionally we would like to support legacy implementations which
rely on ACPIBoard HOB to fill up segment info. So if UplSegmentInfo Hob
is not found we try and look for other hob.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
7 months agoUefiPayloadPkg: Add support for Special Purpose memory
Dhaval [Thu, 29 Aug 2024 05:06:59 +0000 (10:36 +0530)]
UefiPayloadPkg: Add support for Special Purpose memory

We need to let UEFI know that there are cetain memory types
which are special purpose (CXL/HBM) etc and we may want to
avoid using them for UEFI purposes. Hence UPL needs to know
about such memory types.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoUefiPayloadPkg: Remove unnecessary ACPI checks
Dhaval [Mon, 12 Aug 2024 16:51:20 +0000 (22:21 +0530)]
UefiPayloadPkg: Remove unnecessary ACPI checks

We do not need to go deep into verifying all ACPI tables
at this stage. TODO: Just a simple ACPI header signature
check should be good enough. For now just commenting out
asserts that mandate one to have various tables which is
not applicable to all platforms.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoUefiPayloadPkg: Enable RiscV64 entry point to UPL
Dhaval [Mon, 12 Aug 2024 12:38:46 +0000 (18:08 +0530)]
UefiPayloadPkg: Enable RiscV64 entry point to UPL

As per specification we are going to accept only one argument
at the entry point which is FDT pointer. Grab that and call
the entry point.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoUniversalPayload: Add RISC-V support for UPL PCDs
Dhaval [Tue, 11 Jun 2024 02:53:13 +0000 (08:23 +0530)]
UniversalPayload: Add RISC-V support for UPL PCDs

Expose UPL required PCDs for RISC-V Arch

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoUefiPayloadPkg: Parse fdt and create smbios table
Dhaval [Thu, 29 Aug 2024 09:20:55 +0000 (14:50 +0530)]
UefiPayloadPkg: Parse fdt and create smbios table

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoUefiPayloadPkg: Bugfix: Do not parse NULL nodes
Dhaval [Thu, 29 Aug 2024 09:09:26 +0000 (14:39 +0530)]
UefiPayloadPkg: Bugfix: Do not parse NULL nodes

Not every node has compatible property; avoid parsing nodes
which return NULL.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoUefiPayloadPkg: Handle ordering issue with option node
Dhaval [Fri, 30 Aug 2024 14:56:34 +0000 (20:26 +0530)]
UefiPayloadPkg: Handle ordering issue with option node

Option node provides info that is to be consumed by during
metadata creation for other nodes like root bridge; pci-enum-done
etc. Handle that dependency by storing option values in a variable
and then apply it during post processing. Ideally such cross node
dependency should be avoided in design. Scope for futher improvements.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
7 months agoOvmfPkg/CpuHotplugSmm: delay SMM exit
Gerd Hoffmann [Thu, 29 Aug 2024 07:20:29 +0000 (09:20 +0200)]
OvmfPkg/CpuHotplugSmm: delay SMM exit

Let APs wait until the BSP has completed the register updates to remove
the CPU.  This makes sure all APs stay in SMM mode until the CPU
hot-unplug operation is complete, which in turn makes sure the ACPI lock
is released only after the CPU hot-unplug operation is complete.

Some background:  The CPU hotplug SMI is triggered from an ACPI function
which is protected by an ACPI lock.  The ACPI function is in the ACPI
tables generated by qemu.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 months agoOvmfPkg: Use TdInfo instead of fw_cfg to get cpu count in TDVF
Ceping Sun [Wed, 28 Aug 2024 23:34:47 +0000 (07:34 +0800)]
OvmfPkg: Use TdInfo instead of fw_cfg to get cpu count in TDVF

Currently TDVF gets cpu count information via fw_cfg, but
this information can also be retrieved by calling of TdCall.TdInfo.

And TdCall is responded by tdx-module which is trust.
So, from the security perspective we shall use TdCall.Tdinfo instead
of fw_cfg.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
7 months agoOvmfPkg/RiscVVirtQemu: Remove non-needed !include line
Mike Beaton [Fri, 13 Sep 2024 07:23:17 +0000 (08:23 +0100)]
OvmfPkg/RiscVVirtQemu: Remove non-needed !include line

RiscVVirt.dsc.inc includes NetworkPkg/NetworkLibs.dsc.inc. However
RiscVVirt.dsc.inc is only ever included by RiscVVirtQemu.dsc, which
has already included NetworkPkg/Network.dsc.inc, a general include
file which brings in all the required includes for Network features
at once, including NetworkPkg/NetworkLibs.dsc.inc.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoMdePkg/DxeRngLib: Add gEfiRngAlgorithmArmRndr to the secure algorithms
Pierre Gondois [Fri, 30 Aug 2024 11:42:52 +0000 (13:42 +0200)]
MdePkg/DxeRngLib: Add gEfiRngAlgorithmArmRndr to the secure algorithms

DxeRngLib iterates over a list of secure algorithms before trying
to use the default algorithm provided by the Rng protocol. Add
gEfiRngAlgorithmArmRndr to this list. The algorithm represented by
this GUID is a secure DRBG of an unknown type, implemented by the
aarch64 RNDR instruction.
On AARCH64 platform, use the RNDR instruction as the first option
if it is available.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
7 months agoMdePkg/DxeRngLib: Use PcdEnforceSecureRngAlgorithms for default algorithm
Pierre Gondois [Thu, 29 Aug 2024 14:42:33 +0000 (16:42 +0200)]
MdePkg/DxeRngLib: Use PcdEnforceSecureRngAlgorithms for default algorithm

Use PcdEnforceSecureRngAlgorithms to allow using the Rng protocol
with the default algorithm. All previous call to the Rng protocol
are requesting a secure Rng algorithm.
Not specifying the Rng algorithm GUID to use is considered unsecure.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
7 months agoMdePkg/DxeRngLib: Refactor Rng algorithm selection
Pierre Gondois [Tue, 3 Sep 2024 16:04:39 +0000 (18:04 +0200)]
MdePkg/DxeRngLib: Refactor Rng algorithm selection

Add a library constructor which:
- locate the RNG prototocol and keep a reference to it in order to avoid
  locating it multiple times (for each random number generation)
- check which secure algorithm is available on the platform.
  This avoids to try each secure algorithm until finding one
  available for each random number generation call.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
7 months agoMdePkg: Move PcdEnforceSecureRngAlgorithms from NetworkPkg
Pierre Gondois [Thu, 29 Aug 2024 14:31:45 +0000 (16:31 +0200)]
MdePkg: Move PcdEnforceSecureRngAlgorithms from NetworkPkg

The PcdEnforceSecureRngAlgorithms Pcd enforces the use of RNG
algorithms defined by the UEFI spec. To re-use the Pcd in other
packages and have a generic mean to control the usage of unsecure
algorithms, move the Pcd to the MdePkg.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
7 months agoMdePkg DebugLib: Enable FILE NAME as DEBUG ASSERT for GCC12
Chun-Yi Lee [Thu, 12 Sep 2024 06:32:05 +0000 (14:32 +0800)]
MdePkg DebugLib: Enable FILE NAME as DEBUG ASSERT for GCC12

Using __FILE_NAME__ is useful for reducing the size of debug image and
it's also good for reproducable builds. The gcc-12 also supported this
macro.

Ref: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1a9b3f04c11eb467a8dc504a37dad57a371a0d4c

This patch removed the checking of __clang__ when using __FILE_NAME__.

References: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42579
Signed-off-by: Chun-Yi Lee <jlee@suse.com>
7 months agoNetworkPkg/HttpBootDxe: Resume an interrupted boot file download.
Leandro Becker [Tue, 27 Aug 2024 15:17:10 +0000 (12:17 -0300)]
NetworkPkg/HttpBootDxe: Resume an interrupted boot file download.

When the boot file download operation is interrupted for some reason,
HttpBootDxe will use HTTP Range header to try resume the download
operation reusing the bytes downloaded so far.

Signed-off-by: Leandro Gustavo Biss Becker <lbecker@positivo.com.br>
7 months agoMdePkg/Http11.h: Add HTTP header definitions.
Leandro Becker [Tue, 27 Aug 2024 15:16:00 +0000 (12:16 -0300)]
MdePkg/Http11.h: Add HTTP header definitions.

Added HTTP header definitions for the following headers:
"Content-Range", "Last-Modified" and "If-Unmodified-Since"

Signed-off-by: Leandro Gustavo Biss Becker <lbecker@positivo.com.br>
7 months agoMdeModulePkg: Fix buffer overflow in MergeMemoryMap
Ken Lautner [Wed, 28 Aug 2024 17:55:09 +0000 (10:55 -0700)]
MdeModulePkg: Fix buffer overflow in MergeMemoryMap

Check that the next map entry is valid before dereferencing to merge the
guard pages. If the final entry is at the end of a page with no valid page
following it, then this can cause an access violation.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
7 months agoMdePkg: Remove Old Stack Check Lib Implementation
Oliver Smith-Denny [Tue, 23 Jul 2024 23:07:25 +0000 (16:07 -0700)]
MdePkg: Remove Old Stack Check Lib Implementation

Now that the new stack check lib implementation is being used
everywhere, remove the old one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoBaseTools: Add Stack Cookie Support to MSVC and GCC IA32/X64/ARM/AARCH64
Taylor Beebe [Fri, 14 Jun 2024 21:09:54 +0000 (14:09 -0700)]
BaseTools: Add Stack Cookie Support to MSVC and GCC IA32/X64/ARM/AARCH64

This patch directs MSVC and GCC to build stack cookie support into
binaries.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoBaseTools: Update Stack Cookie Logic
Taylor Beebe [Fri, 14 Jun 2024 21:07:33 +0000 (14:07 -0700)]
BaseTools: Update Stack Cookie Logic

This patch updates the GenC logic to generate a random stack cookie value
for the stack check libraries. These random values improve security
for modules which cannot update the global intrinsics.

If the stack cookie value is randomized in the AutoGen.h file each
build, the build system will determine the module/library must be
rebuilt causing effectively a clean build every time. This also makes
binary reproducibility impossible.

This patch updates the early build scripts to create 32 and 64-bit JSON
files in the build output directory which each contain 100 randomized
stack cookie values for each bitwidth. If the JSON files are already
present, then they are not recreated which allows them to be stored and
moved to other builds for binary reproducibility. Because they are in
the build directory, a clean build will cause the values to be
regenerated.

The logic which creates AutoGen.h will read these JSON files and use a
hash of the module GUID (the hash seed is fixed in Basetools) to index
into the array of stack cookie values for the module bitwidth. This
model is necessary because there isn't thread-consistent data so we
cannot use a locking mechanism to ensure only one thread is writing to
the stack cookie files at a time. With this model, the build threads
only need to read from the files.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoUnitTestFrameworkPkg: Add StackCheckLib
Oliver Smith-Denny [Fri, 14 Jun 2024 21:05:14 +0000 (14:05 -0700)]
UnitTestFrameworkPkg: Add StackCheckLib

Add StackCheckLib for Target and Host based unit tests. Host
based unit tests are treated specially, because MSVC built
host based unit tests use the MSVC C runtime lib to provide
the stack cookie definitions, but GCC built host based unit
tests use our implementation, as we do not link against a
C runtime lib that provides the definitions.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoUefiPayloadPkg: Add StackCheckLib
Oliver Smith-Denny [Mon, 29 Jul 2024 23:57:18 +0000 (16:57 -0700)]
UefiPayloadPkg: Add StackCheckLib

Add null implementation of StackCheckLib

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoUefiCpuPkg: Add StackCheckLib
Oliver Smith-Denny [Mon, 29 Jul 2024 21:52:19 +0000 (14:52 -0700)]
UefiCpuPkg: Add StackCheckLib

SecCore and SecCoreNative require StackCheckLib and so the NULL
instance is linked against them here.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoStandaloneMmPkg: Add StackCheckLib
Oliver Smith-Denny [Fri, 14 Jun 2024 21:03:47 +0000 (14:03 -0700)]
StandaloneMmPkg: Add StackCheckLib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoSourceLevelDebugPkg: Add StackCheckLib
Oliver Smith-Denny [Mon, 29 Jul 2024 23:56:31 +0000 (16:56 -0700)]
SourceLevelDebugPkg: Add StackCheckLib

Add null implementation of StackCheckLib

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoShellPkg: Add StackCheckLib
Oliver Smith-Denny [Fri, 14 Jun 2024 21:03:11 +0000 (14:03 -0700)]
ShellPkg: Add StackCheckLib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoSignedCapsulePkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:29:27 +0000 (15:29 -0700)]
SignedCapsulePkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoSecurityPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:28:43 +0000 (15:28 -0700)]
SecurityPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoRedfishPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:27:48 +0000 (15:27 -0700)]
RedfishPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoPrmPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:24:54 +0000 (15:24 -0700)]
PrmPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoPcAtChipsetPkg: Add StackCheckLib
Oliver Smith-Denny [Mon, 29 Jul 2024 23:55:41 +0000 (16:55 -0700)]
PcAtChipsetPkg: Add StackCheckLib

Add Null implementation of StackCheckLib.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoOvmfPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:23:21 +0000 (15:23 -0700)]
OvmfPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoNetworkPkg: Add StackCheckLib
Taylor Beebe [Fri, 14 Jun 2024 21:00:18 +0000 (14:00 -0700)]
NetworkPkg: Add StackCheckLib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoMdeModulePkg: Add StackCheckLib
Oliver Smith-Denny [Fri, 14 Jun 2024 20:58:54 +0000 (13:58 -0700)]
MdeModulePkg: Add StackCheckLib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoIntelFsp2WrapperPkg: Add StackCheckLib
Oliver Smith-Denny [Mon, 29 Jul 2024 23:07:48 +0000 (16:07 -0700)]
IntelFsp2WrapperPkg: Add StackCheckLib

Adds null version of StackCheckLib to SEC modules.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoIntelFsp2Pkg: Add StackCheckLibNull
Oliver Smith-Denny [Mon, 29 Jul 2024 23:06:38 +0000 (16:06 -0700)]
IntelFsp2Pkg: Add StackCheckLibNull

Adds the null instance of StackCheckLib to SEC modules

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoFmpDevicePkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:35:58 +0000 (15:35 -0700)]
FmpDevicePkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoFatPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:35:18 +0000 (15:35 -0700)]
FatPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoEmulatorPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:34:37 +0000 (15:34 -0700)]
EmulatorPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoEmbeddedPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:33:51 +0000 (15:33 -0700)]
EmbeddedPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoDynamicTablesPkg: Add StackCheckLibNull
Oliver Smith-Denny [Tue, 23 Jul 2024 22:33:05 +0000 (15:33 -0700)]
DynamicTablesPkg: Add StackCheckLibNull

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoCryptoPkg: Add StackCheckLib
Oliver Smith-Denny [Fri, 14 Jun 2024 20:59:37 +0000 (13:59 -0700)]
CryptoPkg: Add StackCheckLib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoArmVirtPkg: Add Null Stack Check Lib
Oliver Smith-Denny [Tue, 23 Jul 2024 22:21:07 +0000 (15:21 -0700)]
ArmVirtPkg: Add Null Stack Check Lib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoArmPlatformPkg: Add Null Stack Check Lib
Oliver Smith-Denny [Tue, 23 Jul 2024 22:19:46 +0000 (15:19 -0700)]
ArmPlatformPkg: Add Null Stack Check Lib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoArmPkg: Remove Deprecated Stack Check Lib
Oliver Smith-Denny [Tue, 23 Jul 2024 22:18:41 +0000 (15:18 -0700)]
ArmPkg: Remove Deprecated Stack Check Lib

Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoMdePkg: Create Stack Check Lib
Taylor Beebe [Tue, 27 Aug 2024 21:34:35 +0000 (14:34 -0700)]
MdePkg: Create Stack Check Lib

StackCheckLib contains the required functionality for initializing
the stack cookie value, checking the value, and triggering an interrupt
when a mismatch occurs. The stack cookie is a random value placed on the
stack between the stack variables and the return address so that
continuously writing past the stack variables will cause the stack cookie
to be overwritten. Before the function returns, the stack cookie value
will be checked and if there is a mismatch then StackCheckLib handles the
failure.

Because UEFI doesn't use the C runtime libraries provided by MSVC, the
stack check code is written in assembly within this library. GCC and
Clang compilers have built-in support for stack cookie checking, so this
library only handles failures.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoMdePkg: Create Stack Check Null Libs
Taylor Beebe [Tue, 27 Aug 2024 21:31:48 +0000 (14:31 -0700)]
MdePkg: Create Stack Check Null Libs

Add Null libs for Stack Check and Stack Check Failure Hook Lib that
allow a platform to opt out of stack checks and the stack check failure
hook lib.

StackCheckLib allows implementation (or in this case null implementation)
of stack checks on binaries. There is a Host Application specific version
of this null lib because MSVC host applications must not be linked against
our lib (so the file here is a no-op but that doesn't cause the build
system to fail the build for not building a file for MSVC) as it links
against the MSVC C runtime lib that provides the stack cookie definitions.
GCC host applications do not link against such a C runtime lib and must
be linked against our version.

StackCheckFailureHookLib lets a platform do custom functionality when a
stack check failure occurs (such as log it to a platform defined
mechanism). The null lib simply returns.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoMdePkg: Add Stack Cookie Interrupt Vector PCD
Oliver Smith-Denny [Fri, 14 Jun 2024 20:20:29 +0000 (13:20 -0700)]
MdePkg: Add Stack Cookie Interrupt Vector PCD

This patch adds a PCD allowing a platform to specify
the interrupt vector to trigger on a stack check
failure. On x86, this is an offset into the IDT.
On ARM/AARCH64, this triggers a software interrupt
that can be decoded to indicate this was a stack
check failure.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoUnitTestFrameworkPkg: Move common includes to their own file
Bret Barkelew [Thu, 28 Jan 2021 03:33:13 +0000 (03:33 +0000)]
UnitTestFrameworkPkg: Move common includes to their own file

Previously, the UnitTestFrameworkPkgHost.dsc.inc included the entire
UnitTestFrameworkPkgTarget.dsc.inc file. This is unnecessary for
most configurations, so copy the relevant common components to a
separate file.

This is required for stack cookies so that we can have stack
cookies on target based test apps but not on host base test apps.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoNetworkPkg: PxeBcDhcp6GoogleTest: Fix Stack Smashing Unit Test
Oliver Smith-Denny [Wed, 28 Aug 2024 16:39:45 +0000 (09:39 -0700)]
NetworkPkg: PxeBcDhcp6GoogleTest: Fix Stack Smashing Unit Test

PxeBcDhcp6GoogleTest's MultipleDnsEntries test started to fail
with stack cookies added for host applications. Debugging this
showed that the test was attempting to copy two UINT16s to a
UINT8 Data[1] array allocated on the stack. This was moved to
a heap based allocation for a UINT32 to accommodate the proper
size. After this fix, the unit test passed with stack cookies
enabled.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoArmPkg/ArmLib: Drop set/way Dcache operations
Ard Biesheuvel [Thu, 12 Sep 2024 08:36:29 +0000 (10:36 +0200)]
ArmPkg/ArmLib: Drop set/way Dcache operations

Cache maintenance operations by set/way are not broadcast, and operate
on individual architected caches, making them suitable only for
en/disabling cache levels, which is the job of secure firmware, to be
carried out while the CPU in question is not taking part in the
cache coherency protocol.

Managing the clean/dirty state of a memory range can only be done using
cache maintenance by virtual address.

So drop the set/way handling from ArmLib for ARM and AARCH64, as there
is no context where it can be used correctly from EDK2.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoMdePkg/ArmLib: Drop routines that maintain the entire D-cache
Ard Biesheuvel [Thu, 12 Sep 2024 09:22:00 +0000 (11:22 +0200)]
MdePkg/ArmLib: Drop routines that maintain the entire D-cache

Cache maintenance on the D-cache hierarchy as a whole is not supported
by the ARM architecture, so drop the routines from ArmLib that pretend
to implement it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
7 months agoArmVirtPkg: Fix unable to build with -D NETWORK_ENABLE=0
Mike Beaton [Sat, 24 Aug 2024 08:25:09 +0000 (09:25 +0100)]
ArmVirtPkg: Fix unable to build with -D NETWORK_ENABLE=0

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

7f17a15 (2024/02/22)
"OvmfPkg: Shell*.inc: allow building without network support"
breaks building OVMF with `-D NETWORK_ENABLE=0`.

Before this commit we could build OVMF e.g. with the following
command in the OvmfPkg directory:

./build.sh -D NETWORK_ENABLE=0

After the commit the same command fails early with:

/home/user/OpenSource/edk2/OvmfPkg/OvmfPkgX64.dsc(15):
error F001: Pcd (gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections)
defined in DSC is not declared in DEC files referenced in INF files in
FDF. Arch: ['X64']

This problem also applies in the ArmVirtPkg
platforms which are modified here, but is currently
masked by another issue, namely that these platforms
incorrectly still include some network packages when
most are disabled. (A fix for this was previously applied,
for OvmfPkg Intel platforms only, by
d933ec1 followed by
7f17a15 .)

This commit was created at the same time as the
commits resolving this issue in NetworkPkg and
OvmfPkg. It makes conditional the Pcd references
in ArmVirtPkg platforms which will become references to
undefined Pcds as and when the other issue mentioned
above is fixed.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoOvmfPkg: Fix unable to build OVMF with -D NETWORK_ENABLE=0
Mike Beaton [Sat, 24 Aug 2024 08:18:10 +0000 (09:18 +0100)]
OvmfPkg: Fix unable to build OVMF with -D NETWORK_ENABLE=0

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

7f17a15 (2024/02/22)
"OvmfPkg: Shell*.inc: allow building without network support"
breaks building OVMF with `-D NETWORK_ENABLE=0`.

Before this commit we could build OVMF e.g. with the following
command in the OvmfPkg directory:

./build.sh -D NETWORK_ENABLE=0

After the commit the same command fails early with:

/home/user/OpenSource/edk2/OvmfPkg/OvmfPkgX64.dsc(15):
error F001: Pcd (gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections)
defined in DSC is not declared in DEC files referenced in INF files in
FDF. Arch: ['X64']

The problem applies in Intel OvmfPkg platforms.
Additionally, it applies in various other OvmfPkg
platforms, but is masked buy another issue; namely
that these platforms incorrectly still include some
network packages when most are disabled.
(A fix for that issue has previously been
made, in OvmfPkg Intel platforms only, by
d933ec1 followed by
7f17a15 .)

This commit conditionally removes the undefined Pcd references
in all OvmfPkg platforms which are now affected by this
issue, and in all those which would be affected as and
when the other issue mentioned above is fixed.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoNetworkPkg: Fix unable to build OVMF with -D NETWORK_ENABLE=0
Mike Beaton [Sat, 24 Aug 2024 08:13:37 +0000 (09:13 +0100)]
NetworkPkg: Fix unable to build OVMF with -D NETWORK_ENABLE=0

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

7f17a15 (2024/02/22)
"OvmfPkg: Shell*.inc: allow building without network support"
breaks building OVMF with `-D NETWORK_ENABLE=0`.

Before this commit we could build OVMF e.g. with the following
command in the OvmfPkg directory:

./build.sh -D NETWORK_ENABLE=0

After the commit the same command fails early with:

/home/user/OpenSource/edk2/OvmfPkg/OvmfPkgX64.dsc(15):
error F001: Pcd (gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections)
defined in DSC is not declared in DEC files referenced in INF files in
FDF. Arch: ['X64']

This commit conditionally removes the undefined Pcd reference in
NetworkPkg which is part of this issue.

Similar changes are needed in separate commits for
OvmfPkg (and for ArmVirtPkg, since the issue also
exists there, although masked by another issue).

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoMdePkg: Move CompilerIntrinsicsLib from ArmPkg
Oliver Smith-Denny [Mon, 5 Aug 2024 17:25:07 +0000 (10:25 -0700)]
MdePkg: Move CompilerIntrinsicsLib from ArmPkg

As per the emailed RFC in
https://edk2.groups.io/g/devel/topic/rfc_move/107675828,
this patch moves CompilerIntrinsicsLib from ArmPkg to
MdePkg as this library provides compiler intrinsics, which
are industry standard.

This aligns with the goal of integrating ArmPkg into existing
packages: https://bugzilla.tianocore.org/show_bug.cgi?id=4121.

The newly placed CompilerIntrinsicsLib is added to MdeLibs.dsc.inc
as every DSC that builds ARM/AARCH64 needs this library added. The
old location is removed from every DSC in edk2 in this commit also
to not break bisectability with minimal hoop jumping.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoMdePkg: Move AsmMacroIoLib*.h from ArmPkg
Oliver Smith-Denny [Tue, 6 Aug 2024 22:19:23 +0000 (15:19 -0700)]
MdePkg: Move AsmMacroIoLib*.h from ArmPkg

AsmMacroIoLib.h and AsmMacroIoLibV8.h are used by the
CompilerIntrinsicsLib, which is moving to MdePkg. These
functions provide standard definitions for ARM/AARCH64
assembly code, respectively, and so are moved to the arch
directories in MdePkg to avoid MdePkg having a
dependency on ArmPkg.

Now that the files are in Arm/ and AArch64/ directories,
the filenames are changed to AsmMacroLib.h as we can
distinguish the architecture from the path.

AsmMacroIoLib.inc is unused and so is removed.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoArmPkg: CompilerIntrinsicsLib: Use AsmMacroIoLibV8.h for AARCH64 ASM
Oliver Smith-Denny [Tue, 6 Aug 2024 22:22:34 +0000 (15:22 -0700)]
ArmPkg: CompilerIntrinsicsLib: Use AsmMacroIoLibV8.h for AARCH64 ASM

AArch64/ashlti3.S was using AsmMacroIoLib.h which is the ARM version
of these definitions. AsmMacroIoLibV8.h is the AARCH64 version of
these defintions. This patch moves that file to use the proper arch
file.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoOvmfPkg/LoongArchVirt: Modify loongarch uefi firmware size
Xianglai Li [Wed, 11 Sep 2024 08:58:53 +0000 (16:58 +0800)]
OvmfPkg/LoongArchVirt: Modify loongarch uefi firmware size

After the loongarch flash block size is changed from 128K to 256K,
qemu requires that the UEFI firmware size be aligned with the flash block size(256K).
Otherwise, the firmware cannot be loaded,
Use the following code to resolve the old firmware loading problem:
mv QEMU_EFI.fd  QEMU_EFI.fd-bak
cat QEMU_EFI.fd-bak  /dev/zero | head -c 16m > ./QEMU_EFI.fd
mv QEMU_VARS.fd  QEMU_VARS.fd-bak
cat QEMU_VARS.fd-bak /dev/zero | head -c 16m > ./QEMU_VARS.fd

For the new firmware, we refer to other architecture UEFI and
set the UEFI firmware size to align with the flash block size(256K).

So for this patch, we set the UEFI firmware size to 256K alignment.

Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Chao Li <lichao@loongson.cn>
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
7 months agoShellPkg/AcpiView: RAS2 Parser
Carsten Haitzler [Thu, 29 Aug 2024 14:06:08 +0000 (15:06 +0100)]
ShellPkg/AcpiView: RAS2 Parser

Add a new parser for the RAS2 Table as specified in ACPI6.5

Signed-off-by: Carsten Haitzler <carsten.haitzler@foss.arm.com>
7 months agoMdePkg/Acpi65.h: Add RAS2 table defs and signature as in ACPI 6.5
Carsten Haitzler [Thu, 5 Sep 2024 09:03:59 +0000 (10:03 +0100)]
MdePkg/Acpi65.h: Add RAS2 table defs and signature as in ACPI 6.5

Add EFI_ACPI_RAS2_PCC_DESCRIPTOR, EFI_ACPI_6_5_RAS2_FEATURE_TABLE and
EFI_ACPI_6_5_ACPI_RAS2_FEATURE_TABLE_SIGNATURE.

Signed-off-by: Carsten Haitzler <carsten.haitzler@foss.arm.com>
7 months agoMdeModulePkg: Enable Data Terminal at end of serial
Ken Lautner [Sat, 24 Aug 2024 00:41:49 +0000 (17:41 -0700)]
MdeModulePkg: Enable Data Terminal at end of serial

When a Serial device resets, the Modem Control Register Data Terminal
Ready and Request to Send need to be cleared also. Otherwise the
registers will be left in their previous state, and the connected device
will not be able to transmit data.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
7 months agoMdePkg/IpmiNetFnGroupExtension.h: Enforce structure alignment
Nhi Pham [Mon, 9 Sep 2024 07:22:22 +0000 (14:22 +0700)]
MdePkg/IpmiNetFnGroupExtension.h: Enforce structure alignment

The natural aligmenent seems to be failed on some cases. So, this patch
intends to add the pack(1) to ensure the structure aligned with a
one-byte boundary.

Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
7 months agoRefactor SetMemWrapper to reduce binary size
Ashraf Ali [Fri, 6 Sep 2024 15:12:42 +0000 (20:42 +0530)]
Refactor SetMemWrapper to reduce binary size

Moved SetMemN API to a separate file to eliminate unnecessary inclusion
of InternalMemSetMem64 and InternalMemSetMem32 APIs in driver binary.

When the compiler linking the Object files it may not remove all the
unused from NASM OBJs. This change is to reorganize the C files to
minimize the impact of the NASM behavior resulting is code size
reduction.

Signed-off-by: Ashraf Ali <ashraf.ali.s@intel.com>
7 months agoMdeModulePkg/DxeCapsuleLibFmp: Check BootService Status to Use ESRT Cache
Jason1 Lin [Wed, 28 Aug 2024 09:36:11 +0000 (17:36 +0800)]
MdeModulePkg/DxeCapsuleLibFmp: Check BootService Status to Use ESRT Cache

- In c36414b131dfd0a1ca51f10f87a18955bc110ff2 change, it was introduced
  the ReadyToBoot event check to prevent the boot service got called
  in runtime to cause the issue.

- In this patch introduced the ExitBootService event to replace it.
  It would be better to base on the BootService status to decide
  the source of ESRT table.

- Based on the BootService availability to decide,
  - Exit    : Use cache ESRT table in IF-condition
  - Not Exit: Use boot service to locate protocol in ELSE-condition

Co-authored-by: Dakota Chiang <dakota.chiang@intel.com>
Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
7 months agoMdeModulePkg/DxeCapsuleLibFmp: Change the Event Notify to Cache ESRT Table
Jason1 Lin [Thu, 15 Aug 2024 10:05:32 +0000 (18:05 +0800)]
MdeModulePkg/DxeCapsuleLibFmp: Change the Event Notify to Cache ESRT Table

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

In this patch introduced the below changes,

[1] Add the event of system resource table installed callback.
      - Register the event in DxeRuntimeCapsuleLibConstructor ()
      - Unregister the event in DxeRuntimeCapsuleLibDestructor ()

[2] Migrate the event to update the module variable to cache ESRT table
    from ReadyToBoot to system resource table installed.

[3] Add the condition to free the pool of buffer when the "mEsrtTable"
    is not NULL.

Co-authored-by: Dakota Chiang <dakota.chiang@intel.com>
Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
7 months agoNetworkPkg/MnpDxe: Convert TX buffer allocation messages to DEBUG_VERBOSE
Mike Beaton [Mon, 9 Sep 2024 11:53:23 +0000 (12:53 +0100)]
NetworkPkg/MnpDxe: Convert TX buffer allocation messages to DEBUG_VERBOSE

Under normal operation, some 30 or so of these lines logged as DEBUG_INFO
on first transmit.

This is not relevant information for users of the driver, so convert these
messages to VERBOSE.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoSupport Report Status Code in the UefiPxe driver.
yhsu3 [Sun, 8 Sep 2024 09:45:54 +0000 (17:45 +0800)]
Support Report Status Code in the UefiPxe driver.

Report PXE error status via Status Code, with this design,
it will be flexible to register a status code handler
via gEfiRscHandlerProtocolGuid to output the customized error code
to other telemetry service.

The subclass code is `EFI_IO_BUS_IP_NETWORK`

Signed-off-by: Ethan Hsu <Eathonhsu@gmail.com>
7 months agoStandaloneMmPkg/MmIpl: Correct unblocked memory regions attribute
Hongbin1 Zhang [Thu, 29 Aug 2024 01:52:05 +0000 (09:52 +0800)]
StandaloneMmPkg/MmIpl: Correct unblocked memory regions attribute

When CPU smm profile feature was enabled, unblocked memory should
not set logging attribute when building resource HOB.

Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
7 months agoIntelFsp2Pkg: Support FSP API to save and restore page table
Zhiguang Liu [Tue, 18 Jun 2024 08:13:12 +0000 (16:13 +0800)]
IntelFsp2Pkg: Support FSP API to save and restore page table

A potential issue may happen when FSP creates/changes page table while
bootloader doesn't expect page table being changed in FSP.
Current, FSP API support to save/restore stack, IDT and general purpose
registers. Following the same pattern, add save/restore page table
support to solve this issue.
Note that this feature only impacts FSP API mode, and is controlled
by PCD PcdFspSaveRestorePageTableEnable. For compatibility, the PCD
default value is set as FALSE.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
7 months ago.pytool/EccCheck: Trim leading path to modified directory
Abdul Lateef Attar [Sat, 31 Aug 2024 09:19:30 +0000 (09:19 +0000)]
.pytool/EccCheck: Trim leading path to modified directory

The code changes in the patch is for trimming the leading path
to the modified directory in the .pytool/EccCheck script.
This is necessary when running Ecc on other repositories,
such as edk2-platforms, where the platform package is located
in a subfolder, like Platform/AMD/AmdPlatformPkg.

The EccCheck script checks for modified directories and expects them to start with the package name.
        #
        # Skip directory names that do not start with the package being scanned.
        #
        if file_dir.split('/')[0] != pkg:
                continue

However, if the package name is in a subfolder,
the "git diff" command gives a relative path,
like Platform/AMD, which causes the condition to be false.
"M       Platform/AMD/AmdPlatformPkg/Universal/LogoDxe/Logo.c"
As a result, EccCheck does not happen on modified files.

To fix this issue, the leading path needs to be trimmed
so that it starts from the directory name.
This change will not affect the existing check for the edk2 repository,
where all package names are at the first level directory.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Joey Vagedes <joey.vagedes@gmail.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
7 months agoMdeModulePkg/VariableRuntimeDxe: Fix VariablePolicyProtocol PRODUCES
Mike Beaton [Mon, 9 Sep 2024 15:55:23 +0000 (16:55 +0100)]
MdeModulePkg/VariableRuntimeDxe: Fix VariablePolicyProtocol PRODUCES

If we search the codebase for &gEdkiiVariablePolicyProtocolGuid
we can find two drivers which install this policy:
VariableRuntimeDxe (installed in VariableDxe.c) and
VariableSmmRuntimeDxe (installed in VariablePolicySmmDxe.c).

The .inf file for VariableRuntimeDxe incorrectly lists the protocol
as CONSUMES in the comment, so change this to PRODUCES.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoArmPkg/ArmPsciMpServices: GetProcessorInfo copies incorrect structure
Vishal Oliyil Kunnil [Tue, 10 Sep 2024 00:21:14 +0000 (17:21 -0700)]
ArmPkg/ArmPsciMpServices: GetProcessorInfo copies incorrect structure

GetProcessorInfo copies CpuData instead of CpuData.Info. The OUT parameter
ProcessorInfoBuffer is of type EFI_PROCESSOR_INFORMATION, not CPU_AP_DATA.

Fix it to copy the correct member CpuData.Info.

Signed-off-by: Vishal Oliyil Kunnil <quic_vishalo@quicinc.com>
7 months agoBaseTools: Remove Pip BaseTools
Oliver Smith-Denny [Wed, 4 Sep 2024 17:02:09 +0000 (10:02 -0700)]
BaseTools: Remove Pip BaseTools

BaseTools was moved out to a separate repo and consumed as a pip
module by edk2 CI. This process has not led to the desired goals
of doing so, so this patch removes the pip based BaseTools from
edk2 CI.

The original goal of moving BaseTools to a pip module was
primarily to speed up the development process, as the old edk2
mailing list was slow. However, with edk2 moving to PRs, it now
actually slows the BaseTools development process to have to do
a PR in another repo, publish the module, and then make a PR
in edk2 to consume the new BaseTools. It also holds up using
the features in a new BaseTools in other PRs.

There were other goals of moving, such as allowing projects to
use the BaseTools outside of edk2. This can still be accomplished
outside of this PR, this PR simply stops edk2 CI from using the
pip module.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
7 months agoNetworkPkg/DxeNetLib: Update misleading comment
Mike Beaton [Sun, 8 Sep 2024 10:33:43 +0000 (11:33 +0100)]
NetworkPkg/DxeNetLib: Update misleading comment

Commit 6862b9d538d96363635677198899e1669e591259 makes
more explicit the previous logic of the code anyway, which is that
it is (and was) only a fatal error if all secure algorithms fail.

However the comment updated by this commit seems somewhat
incompatible with that change, and even with the previous code
(which operated as now, just logging different error messages).

This updates the comment to be more compatible with how the
code operates.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
7 months agoOvmfPkg/QemuFwCfgS3Lib: Disable S3 detection in TDVF
Ceping Sun [Mon, 6 May 2024 22:33:57 +0000 (06:33 +0800)]
OvmfPkg/QemuFwCfgS3Lib: Disable S3 detection in TDVF

Refer to the section 2.1 of tdx-virtual-firmware-design-guide spec,
APCI S3 is not supported in TDVF.

Therefore, TDVF should not read the S3 status via fw_cfg and always
set it as unsupported.

spec: https://cdrdv2.intel.com/v1/dl/getContent/733585

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>