]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
18 months agoRedfishPkg/RedfishDiscoverDxe: Fix memory free issue
Abner Chang [Fri, 28 Oct 2022 10:16:55 +0000 (18:16 +0800)]
RedfishPkg/RedfishDiscoverDxe: Fix memory free issue

Check the memory block pointer before freeing it.

Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
18 months agoMaintainers.txt: Add 'Pierre Gondois' as DynamicTablesPkg reviewer
Pierre Gondois [Fri, 23 Sep 2022 13:35:01 +0000 (15:35 +0200)]
Maintainers.txt: Add 'Pierre Gondois' as DynamicTablesPkg reviewer

Add myself as reviewer for the DynamicTablesPkg.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoShellPkg/AcpiView: Update PCCT fields for ACPI 6.5
Pierre Gondois [Mon, 10 Oct 2022 09:20:58 +0000 (11:20 +0200)]
ShellPkg/AcpiView: Update PCCT fields for ACPI 6.5

The ACPI specification updated some terms in accordance with:
s1.1.1 Principle of Inclusive Terminology

Update the PCCT parser accordincly with these new terms.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Readme.md: Update available tables for generation
Pierre Gondois [Mon, 10 Oct 2022 09:20:57 +0000 (11:20 +0200)]
DynamicTablesPkg: Readme.md: Update available tables for generation

The following tables can now be generated by the DynamicTablesPkg:
 - PCCT
 - PPTT
 - SRAT

Update the documentation accordingly.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg/AmlLib: Allow larger AccessSize for Pcc address space
Pierre Gondois [Mon, 10 Oct 2022 09:20:56 +0000 (11:20 +0200)]
DynamicTablesPkg/AmlLib: Allow larger AccessSize for Pcc address space

For Pcc address space, the AccessSize field of a Register is
used to delcare the Pcc Subspace Id. This Id can be up to 256.

Cf. ACPI 6.4, s14.7 Referencing the PCC address space

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Add PCCT Generator
Pierre Gondois [Mon, 10 Oct 2022 09:20:55 +0000 (11:20 +0200)]
DynamicTablesPkg: Add PCCT Generator

The Platform Communication Channel Table (PCCT) generator collates
the relevant information required for generating a PCCT table from
configuration manager using the configuration manager protocol.
The DynamicTablesManager then install the PCCT table.

From ACPI 6.4, s14 PLATFORM COMMUNICATIONS CHANNEL (PCC):
  The platform communication channel (PCC) is a generic mechanism
  for OSPM to communicate with an entity in the platform.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Add PCCT related objects
Pierre Gondois [Mon, 10 Oct 2022 09:20:54 +0000 (11:20 +0200)]
DynamicTablesPkg: Add PCCT related objects

Introduce the following CmObj in the ArmNameSpaceObjects:
 - CM_ARM_MAILBOX_REGISTER_INFO
 - CM_ARM_PCC_SUBSPACE_CHANNEL_TIMING_INFO
 - CM_ARM_PCC_SUBSPACE_GENERIC_INFO
 - CM_ARM_PCC_SUBPSACE_TYPE0_INFO
 - CM_ARM_PCC_SUBPSACE_TYPE1_INFO
 - CM_ARM_PCC_SUBPSACE_TYPE2_INFO
 - CM_ARM_PCC_SUBPSACE_TYPE3_INFO
 - CM_ARM_PCC_SUBPSACE_TYPE4_INFO
 - CM_ARM_PCC_SUBPSACE_TYPE5_INFO

These objects allow to describe mailbox registers, pcc timings
and PCCT subspaces. They prepare the enablement of a PCCT generator.

Also add the CmObjParsers associated to each object.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Fix Ssdt PCI generation comments
Pierre Gondois [Mon, 10 Oct 2022 09:20:53 +0000 (11:20 +0200)]
DynamicTablesPkg: Fix Ssdt PCI generation comments

The second model of the _PRT object is used. Indeed:
- the interrupts described are not re-configurable
- OSes are aware of the polarity of PCI legacy interrupts,
  so there is no need to accurately describe the polarity.

Also, fix a comment for the CM_ARM_PCI_INTERRUPT_MAP_INFO obj.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: FdtHwInfoParserLib: Remove wrong comment
Pierre Gondois [Mon, 10 Oct 2022 09:20:52 +0000 (11:20 +0200)]
DynamicTablesPkg: FdtHwInfoParserLib: Remove wrong comment

commit 13136cc3111f ("DynamicTablesPkg: FdtHwInfoParserLib:
Parse Pmu info")
adds support for pmu parsing. Thus, remove the wrong comment.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Remove deprecated APIs
Pierre Gondois [Mon, 10 Oct 2022 09:20:51 +0000 (11:20 +0200)]
DynamicTablesPkg: Remove deprecated APIs

commit 691c5f776274 ("DynamicTablesPkg: Deprecate Crs specific methods
in AmlLib")
deprecates some APIs. Finally remove them.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Fix wrong/missing fields in CmObjParser
Pierre Gondois [Mon, 10 Oct 2022 09:20:50 +0000 (11:20 +0200)]
DynamicTablesPkg: Fix wrong/missing fields in CmObjParser

Add missing fields to the following CmObjParser objects:
- EArmObjGicDInfo
- EArmObjCacheInfo
and fix wrong formatting of:
- EArmObjLpiInfo

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Fix GTBlock and GTBlockTimerFrame CmObjParsers
Pierre Gondois [Mon, 10 Oct 2022 09:20:49 +0000 (11:20 +0200)]
DynamicTablesPkg: Fix GTBlock and GTBlockTimerFrame CmObjParsers

The CmObjParsers of the following objects was inverted, probably
due to a wrong ordering placement in the file defining the structures:
-EArmObjGTBlockTimerFrameInfo
-EArmObjPlatformGTBlockInfo

Assign the correct parser for each object, and re-order the
structures in the file defining them.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Update CmObjParser for MinorRevision
Pierre Gondois [Mon, 10 Oct 2022 09:20:48 +0000 (11:20 +0200)]
DynamicTablesPkg: Update CmObjParser for MinorRevision

commit 0d23c447d6f5 ("DynamicTablesPkg: Add support to specify FADT
minor revision")
adds new 'MinorRevision' field to CM_STD_OBJ_ACPI_TABLE_INFO.
Reflect the change in this patch to the CmObjectParser.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Update CmObjParser for IORT Rev E.d
Pierre Gondois [Mon, 10 Oct 2022 09:20:47 +0000 (11:20 +0200)]
DynamicTablesPkg: Update CmObjParser for IORT Rev E.d

commit de200b7e2c3c ("DynamicTablesPkg: Update ArmNameSpaceObjects for
IORT Rev E.d")
adds new CmObj structures and fields to the ArmNameSpaceObjects.
Update the CmObjectParser accordingly.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Add PrintString to CmObjParser
Pierre Gondois [Mon, 10 Oct 2022 09:20:46 +0000 (11:20 +0200)]
DynamicTablesPkg: Add PrintString to CmObjParser

Add a PrintString to print strings in the CmObjParser.
String must be NULL terminated and no buffer overrun check
is done by this function.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoDynamicTablesPkg: Use correct print formatter
Pierre Gondois [Mon, 10 Oct 2022 09:20:45 +0000 (11:20 +0200)]
DynamicTablesPkg: Use correct print formatter

In C, the 'long long' types are 64-bits. The 'll' printf length
specifier should be used to pring these values. Just '%x' allows to
print values that are on 16-bits or more. Use that instead.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
18 months agoMdeModulePkg/ScsiDiskDxe: Update proper device name for ScsiDisk drive
Cheripally Gopi [Wed, 26 Oct 2022 12:07:25 +0000 (17:37 +0530)]
MdeModulePkg/ScsiDiskDxe: Update proper device name for ScsiDisk drive

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

ScsiDiskDxe driver updates ControllerNameTable with common string
"SCSI Disk Device" for all SCSI disks. Due to this, when multiple
SCSI disk devices connected, facing difficulty in identifying correct SCSI
disk device. As per SCSI spec, standard Inquiry Data is having the fields
to know Vendor and Product information. Updated "ControllerNameTable" with
Vendor and Product information. So that, device specific name can be
retrieved using ComponentName protocol.

Cc: Vasudevan Sambandan <vasudevans@ami.com>
Cc: Sundaresan Selvaraj <sundaresans@ami.com>
Signed-off-by: Cheripally Gopi <gopic@ami.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
18 months agoUefiCpuPkg: Restore HpetTimer after CpuExceptionHandlerLib test
Tan, Dun [Fri, 28 Oct 2022 03:51:18 +0000 (11:51 +0800)]
UefiCpuPkg: Restore HpetTimer after CpuExceptionHandlerLib test

Disable/Restore HpetTimer before and after running the Dxe
CpuExceptionHandlerLib unit test module. During the UnitTest, a
new Idt is initialized for the test. There is no handler for timer
intrrupt in this new idt. After the test module, HpetTimer does
not work any more since the comparator value register and main
counter value register for timer does not match. To fix this issue,
disable/restore HpetTimer before and after Unit Test if HpetTimer
driver has been dispatched. We don't need to send Apic Eoi in this
unit test module.When disabling timer, after RaiseTPL(), if there
is a pending timer interrupt, bit64 of Interrupt Request Register
(IRR) will be set to 1 to indicate there is a pending timer
interrupt. After RestoreTPL(), CPU will handle the pending
interrupt in IRR.Then TimerInterruptHandler calls SendApicEoi().

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>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
18 months agoArmVirtPkg/ArmVirtKvmTool: Migrate to OVMF's VirtNorFlashDxe
Ard Biesheuvel [Mon, 24 Oct 2022 16:51:43 +0000 (18:51 +0200)]
ArmVirtPkg/ArmVirtKvmTool: Migrate to OVMF's VirtNorFlashDxe

Migrate to the virt specific NOR flash driver as the ArmPlatformPkg is
going away.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe
Ard Biesheuvel [Mon, 24 Oct 2022 16:41:22 +0000 (18:41 +0200)]
ArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe

Switch to the virt specific NorFlashDxe driver implementation that was
added recently.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()
Ard Biesheuvel [Mon, 24 Oct 2022 16:16:18 +0000 (18:16 +0200)]
OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()

NOR flash emulation under KVM involves switching between two modes,
where array mode is backed by a read-only memslot, and programming mode
is fully emulated, i.e., the memory region is not backed by anything,
and the faulting accesses are forwarded to the VMM by the hypervisor,
which translates them into NOR flash programming commands.

Normally, we are limited to the use of device attributes when mapping
such regions, given that the programming mode has MMIO semantics.
However, when running under KVM, the chosen memory attributes only take
effect when in array mode, since no memory mapping exists otherwise.

This means we can tune the memory mapping so it behaves a bit more like
a ROM, by switching to EFI_MEMORY_WC attributes. This means we no longer
need a special CopyMem() implementation that avoids unaligned accesses
at all cost.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg/VirtNorFlashDxe: avoid switching between modes in a tight loop
Ard Biesheuvel [Mon, 24 Oct 2022 15:58:07 +0000 (17:58 +0200)]
OvmfPkg/VirtNorFlashDxe: avoid switching between modes in a tight loop

Currently, when dealing with small updates that can be written out
directly (i.e., if they only involve clearing bits and not setting bits,
as the latter requires a block level erase), we iterate over the data
one word at a time, read the old value, compare it, write the new value,
and repeat, unless we encountered a value that we cannot write (0->1
transition), in which case we fall back to a block level operation.

This is inefficient for two reasons:
- reading and writing a word at a time involves switching between array
and programming mode for every word of data, which is
disproportionately costly when running under KVM;
- we end up writing some data twice, as we may not notice that a block
erase is needed until after some data has been written to flash.

So replace this sequence with a single read of up to twice the buffered
write maximum size, followed by one or two buffered writes if the data
can be written directly. Otherwise, fall back to the existing block
level sequence, but without writing out part of the data twice.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg/VirtNorFlashDxe: avoid array mode switch after each word write
Ard Biesheuvel [Mon, 24 Oct 2022 15:34:09 +0000 (17:34 +0200)]
OvmfPkg/VirtNorFlashDxe: avoid array mode switch after each word write

NorFlashWriteSingleWord() switches into programming mode and back into
array mode for every single word that it writes. Under KVM, this
involves tearing down the read-only memslot, and setting it up again,
which is costly and unnecessary.

Instead, move the array mode switch into the callers, and only make the
switch when the writing is done.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg/VirtNorFlashDxe: drop block I/O protocol implementation
Ard Biesheuvel [Mon, 24 Oct 2022 15:12:08 +0000 (17:12 +0200)]
OvmfPkg/VirtNorFlashDxe: drop block I/O protocol implementation

We never boot from NOR flash, and generally rely on the firmware volume
PI protocols to expose the contents. So drop the block I/O protocol
implementation from VirtNorFlashDxe.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg/VirtNorFlashDxe: remove disk I/O protocol implementation
Ard Biesheuvel [Mon, 24 Oct 2022 14:50:05 +0000 (16:50 +0200)]
OvmfPkg/VirtNorFlashDxe: remove disk I/O protocol implementation

We only use NOR flash for firmware volumes, either for executable images
or for the variable store. So we have no need for exposing disk I/O on
top of the NOR flash partitions so let's remove it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg/VirtNorFlashDxe: remove CheckBlockLocked feature
Ard Biesheuvel [Mon, 24 Oct 2022 14:45:02 +0000 (16:45 +0200)]
OvmfPkg/VirtNorFlashDxe: remove CheckBlockLocked feature

We inherited a feature from the ArmPlatformPkg version of this driver
that never gets enabled. Let's remove it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg/VirtNorFlashDxe: clone ArmPlatformPkg's NOR flash driver
Ard Biesheuvel [Mon, 24 Oct 2022 14:41:43 +0000 (16:41 +0200)]
OvmfPkg/VirtNorFlashDxe: clone ArmPlatformPkg's NOR flash driver

QEMU's mach-virt is loosely based on ARM Versatile Express, and inherits
its NOR flash driver, which is now being used on other QEMU emulated
architectures as well.

In order to permit ourselves the freedom to optimize this driver for
use under KVM emulation, let's clone it into OvmfPkg, so we have a
version we can hack without the risk of regressing bare metal platforms.

The cloned version is mostly identical to the original, but it depends
on the newly added VirtNorFlashPlatformLib library class instead of the
original one from ArmPlatformPkg. Beyond that, only cosmetic changes
related to #include order etc were made.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoOvmfPkg: clone NorFlashPlatformLib into VirtNorFlashPlatformLib
Ard Biesheuvel [Mon, 24 Oct 2022 16:35:10 +0000 (18:35 +0200)]
OvmfPkg: clone NorFlashPlatformLib into VirtNorFlashPlatformLib

Create a new library class in Ovmf that duplicates the existing
NorFlashPlatformLib, but which will be tied to the VirtNorFlashDxe
driver that will be introduced in a subsequent patch. This allows us to
retire the original from ArmPlatformPkg.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
18 months agoArmVirtPkg/ArmVirtQemu: Clear XIP flags instead of overriding them
Ard Biesheuvel [Wed, 26 Oct 2022 19:51:38 +0000 (21:51 +0200)]
ArmVirtPkg/ArmVirtQemu: Clear XIP flags instead of overriding them

Clang does not support undoing the effects of -mstrict-align by passing
the -mno-strict-align counterpart, so appending the latter to the
compiler's XIPFLAGS does not work. Instead, clear the flags entirely.

This also removes -mgeneral-regs-only, but this is fine - we can
tolerate SIMD codegen in PEIMs or BASE libraries as they run with the
MMU and caches enabled.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/ArmVirtQemu: omit PCD PEIM unless TPM support is enabled
Ard Biesheuvel [Sun, 25 Sep 2022 15:22:04 +0000 (17:22 +0200)]
ArmVirtPkg/ArmVirtQemu: omit PCD PEIM unless TPM support is enabled

The TPM discovery code relies on a dynamic PCD to communicate the TPM
base address to other components. But no other code relies on dynamic
PCDs in the PEI phase so let's drop the PCD PEIM when TPM support is not
enabled.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to record the memory size
Ard Biesheuvel [Sun, 25 Sep 2022 14:53:27 +0000 (16:53 +0200)]
ArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to record the memory size

Due to the way we inherited the formerly fixed PCDs to describe the
system memory base and size from ArmPlatformPkg, we ended up with a
MemoryInit PEIM that relies on dynamic PCDs to communicate the size of
system memory between the constructor of one of its library dependencies
and the core module. This is unnecessary, and forces us to incorporate
the PCD PEIM as well, for no good reason. So instead, let's use a HOB.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/ArmVirtQemu: avoid shadowing PEIMs unless necessary
Ard Biesheuvel [Sun, 25 Sep 2022 15:24:41 +0000 (17:24 +0200)]
ArmVirtPkg/ArmVirtQemu: avoid shadowing PEIMs unless necessary

Some PEIMs register for shadow execution explicitly, but others exist
that don't care and can happily execute in place. Since the emulated NOR
flash is just RAM, shadowing has no performance benefits so let's only
do this if needed.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/ArmVirtQemu: Drop unused variable PEIM
Ard Biesheuvel [Sun, 25 Sep 2022 14:02:36 +0000 (16:02 +0200)]
ArmVirtPkg/ArmVirtQemu: Drop unused variable PEIM

The variable PEIM is included in the build but its runtime prerequisites
are absent so it is never dispatched. Just drop it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/ArmVirtQemu: enable initial ID map at early boot
Ard Biesheuvel [Sat, 2 Jul 2022 17:27:37 +0000 (19:27 +0200)]
ArmVirtPkg/ArmVirtQemu: enable initial ID map at early boot

Now that we have all the pieces in place, switch the AArch64 version of
ArmVirtQemu to a mode where the first thing it does out of reset is
enable a preliminary ID map that covers the NOR flash and sufficient
DRAM to create the UEFI page tables as usual.

The advantage of this is that no manipulation of memory occurs any
longer before the MMU is enabled, which removes the need for explicit
coherency management, which is cumbersome and bad for performance.

It also means we no longer need to build all components that may execute
with the MMU off (including BASE libraries) with strict alignment.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/ArmVirtQemu: use first 128 MiB as permanent PEI memory
Ard Biesheuvel [Sat, 2 Jul 2022 17:24:13 +0000 (19:24 +0200)]
ArmVirtPkg/ArmVirtQemu: use first 128 MiB as permanent PEI memory

In order to allow booting with the MMU and caches enabled really early,
we need to ensure that the code that populates the page tables can
access those page tables with the statically defined ID map active.

So let's put the permanent PEI RAM in the first 128 MiB of memory, which
we will cover with this initial ID map (as it is the minimum supported
DRAM size for ArmVirtQemu).

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/ArmVirtQemu: implement ArmPlatformLib with static ID map
Ard Biesheuvel [Sat, 2 Jul 2022 17:19:05 +0000 (19:19 +0200)]
ArmVirtPkg/ArmVirtQemu: implement ArmPlatformLib with static ID map

To substantially reduce the amount of processing that takes place with
the MMU and caches off, implement a version of ArmPlatformLib specific
for QEMU/mach-virt in AArch64 mode that carries a statically allocated
and populated ID map that covers the NOR flash and device region, and
128 MiB of DRAM at the base of memory (0x4000_0000).

Note that 128 MiB has always been the minimum amount of DRAM we support
for this configuration, and the existing code already ASSERT()s in DEBUG
mode when booting with less.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg/ArmVirtQemu: wire up timeout PCD to Timeout variable
Ard Biesheuvel [Tue, 2 Aug 2022 16:53:51 +0000 (18:53 +0200)]
ArmVirtPkg/ArmVirtQemu: wire up timeout PCD to Timeout variable

Use the appropriate PCD definition in the ArmVirtQemu DSC so that the
boot timeout is taken from the Timeout variable automatically, which is
what Linux tools such as efibootmgr expect.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoArmVirtPkg: make EFI_LOADER_DATA non-executable
Ard Biesheuvel [Tue, 2 Aug 2022 09:48:04 +0000 (11:48 +0200)]
ArmVirtPkg: make EFI_LOADER_DATA non-executable

When the memory protections were implemented and enabled on ArmVirtQemu
5+ years ago, we had to work around the fact that GRUB at the time
expected EFI_LOADER_DATA to be executable, as that is the memory type it
allocates when loading its modules.

This has been fixed in GRUB in August 2017, so by now, we should be able
to tighten this, and remove execute permissions from EFI_LOADER_DATA
allocations.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 months agoMaintainers.txt: Update maintainers and reviewers for LoongArch64
Chao Li [Thu, 20 Oct 2022 14:43:14 +0000 (22:43 +0800)]
Maintainers.txt: Update maintainers and reviewers for LoongArch64

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Baoqi Zhang <zhangbaoqi@loongson.cn>
Cc: Dongyan Qian <qiandongyan@loongson.cn>
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
18 months agoMaintainers.txt: Update maintainers list
Abner Chang [Tue, 25 Oct 2022 16:13:08 +0000 (00:13 +0800)]
Maintainers.txt: Update maintainers list

Update maintainers.txt to add Igor from AMI
as the reviewer of RedfishPkg.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nickle Wang <nickle@csie.io>
Cc: Igor Kulchytskyy <igork@ami.com>
18 months agoIntelFsp2WrapperPkg: Check header revision for MultiPhase support.
Chasel Chiu [Tue, 25 Oct 2022 18:43:49 +0000 (11:43 -0700)]
IntelFsp2WrapperPkg: Check header revision for MultiPhase support.

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

Earlier version of FSP header may not have MultiPhase fields present in
the FspInfoHeader so the handler should verify header revision before
accessing the MultiPhase fields from the header.

Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
18 months agoMdeModulePkg: Fix spelling error in PciSioSerialDxe
Nate DeSimone [Tue, 25 Oct 2022 21:38:29 +0000 (14:38 -0700)]
MdeModulePkg: Fix spelling error in PciSioSerialDxe

gSerialDevTempate should be gSerialDevTemplate

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
18 months agoArmPlatformPkg/PrePeiCore: Print the firmware version early in boot
Rebecca Cran [Tue, 11 Oct 2022 20:59:52 +0000 (14:59 -0600)]
ArmPlatformPkg/PrePeiCore: Print the firmware version early in boot

Copy code from PrePi to PrePeiCore that prints the firmware version
and build date early in the boot process.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoPs2KbdCtrller: Make wait for SUCCESS after BAT non-fatal
Matt DeVillier [Wed, 26 May 2021 22:33:29 +0000 (17:33 -0500)]
Ps2KbdCtrller: Make wait for SUCCESS after BAT non-fatal

Recent model Chromebooks only return ACK, but not
BAT_SUCCESS, which causes hanging and failed ps2k init.
To mitigate this, make the absence of BAT_SUCCESS reply
non-fatal, and reduce the no-reply timeout from 4s to 1s.

Tested on google/dracia and purism/librem_14

Acked-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
18 months agoArmPlatformPkg/PrePeiCore: permit entry with the MMU enabled
Ard Biesheuvel [Fri, 1 Jul 2022 18:24:26 +0000 (20:24 +0200)]
ArmPlatformPkg/PrePeiCore: permit entry with the MMU enabled

Some platforms may set up a preliminary ID map in flash and enter EFI
with the MMU and caches enabled, as this removes a lot of the complexity
around cache coherency. Let's take this into account, and avoid touching
the MMU controls or perform cache invalidation when the MMU is enabled
at entry.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoArmVirtPkg: do not enable iSCSI driver by default
Ard Biesheuvel [Tue, 28 Jun 2022 10:58:43 +0000 (12:58 +0200)]
ArmVirtPkg: do not enable iSCSI driver by default

The iSCSI driver slows down the boot on a pristine variable store flash
image, as it creates a couple of large EFI non-volatile variables to
preserve state between boots.

Since iSCSI boot for VMs is kind of niche anyway, let's default to
disabled. If someone needs it in their build, they can use the -D build
command option to re-enable it on the fly.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoArmVirtPkg: remove EbcDxe from all platforms
Ard Biesheuvel [Sun, 25 Sep 2022 16:05:02 +0000 (18:05 +0200)]
ArmVirtPkg: remove EbcDxe from all platforms

The EBC interpreter is rarely, if ever, used on ARM, and is especially
pointless on virtual machines. So let's drop it from the builds.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoBaseTools/Tests: Use quotes around PYTHON_COMMAND
Ard Biesheuvel [Mon, 24 Oct 2022 06:11:22 +0000 (08:11 +0200)]
BaseTools/Tests: Use quotes around PYTHON_COMMAND

Commit ("2355f0c09c52 BaseTools: Fix check for ${PYTHON_COMMAND} in
Tests/GNUmakefile") fixed a latent issue in the BaseTools/Tests
Makefile, but inadvertently broke the BaseTools build for cases where
PYTHON_COMMAND is not set. As it turns out, running 'command' without a
command argument makes the invocation succeed, causing the empty
variable to be evaluated and called later.

Let's put double quotes around PYTHON_COMMAND in the invocation of
'command' and force it to fail when PYTHON_COMMAND is not set.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoCryptoPkg/Library/OpensslLib: update auto-generated files
Yi Li [Thu, 20 Oct 2022 07:44:42 +0000 (15:44 +0800)]
CryptoPkg/Library/OpensslLib: update auto-generated files

Update OpensslLib INF files to match results from running
process_files.pl to auto-generate the INF files.
* OpensslLib.inf
* OpensslLibAccel.inf
* OpensslLibCrypto.inf
* OpensslLibFull.inf
* OpensslLibFullAccel.inf

These INF files are generated by running the following
perl scripts:
* process_files.pl
* process_files.pl X64
* process_files.pl X64Gcc
* process_files.pl IA32
* process_files.pl IA32Gcc

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Yi Li <yi1.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library/OpensslLib: Add generated flag to Accel INF
Yi Li [Thu, 20 Oct 2022 06:46:56 +0000 (14:46 +0800)]
CryptoPkg/Library/OpensslLib: Add generated flag to Accel INF

Update OpensslLibAccel.inf and OpensslLibFullAccel.inf to include
flags used by process_files.pl to generate OpensslLib INF files.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Yi Li <yi1.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library/OpensslLib: Update process_files.pl INF generation
Yi Li [Tue, 18 Oct 2022 05:10:55 +0000 (13:10 +0800)]
CryptoPkg/Library/OpensslLib: Update process_files.pl INF generation

Update process_files.pl to generate all OpensslLib INF files.
* OpensslLib.inf
* OpensslLibAccel.inf
* OpensslLibCrypto.inf
* OpensslLibFull.inf
* OpensslLibFullAccel.inf

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Yi Li <yi1.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoRevert "CryptoPkg: Update process_files.pl to auto add PCD config option"
Yi Li [Mon, 17 Oct 2022 07:53:12 +0000 (15:53 +0800)]
Revert "CryptoPkg: Update process_files.pl to auto add PCD config option"

This reverts commit 499b0d5fa57dafe47b260aaf0cea6c6b0286e656.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Yi Li <yi1.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg: Add Readme.md
Michael D Kinney [Tue, 11 Oct 2022 06:50:33 +0000 (23:50 -0700)]
CryptoPkg: Add Readme.md

Add Readme.md that provides an overview of the CryptoPkg
and how to configure the use of cryptographic services in
a platform.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg: Fixed host-based unit tests
Michael D Kinney [Mon, 3 Oct 2022 23:27:26 +0000 (16:27 -0700)]
CryptoPkg: Fixed host-based unit tests

* Build host-based tests using OpensslLib instance with all services
  enabled.
* Build host-based tests using performance optimized OpensslLib instance
  with all services enabled.
* Remove unused PCD gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
* Remove redundant and unnecessary [BuildOptions]
* Limit host-based unit tests to only IA32/X64

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg: Update DSC to improve CI test coverage
Michael D Kinney [Wed, 5 Oct 2022 00:36:41 +0000 (17:36 -0700)]
CryptoPkg: Update DSC to improve CI test coverage

With the addition of EC services and performance optimized versions
of the OpensslLib for IA32/X64, the CryptoPkg.dsc file is updated
to make sure all combinations are covered in CI builds.

* Use different output directory for each CRYPTO_SERVICES profile.
* Add FILE_GUID define names for CryptoPei, CryptoDxe, and CryptoSmm
  when they are linked with different OpensslLib instances.
* Update CryptoPei, CryptoDxe, CryptoSmm builds to include all
  combinations of OpensslLib library instances supported by each
  CPU architecture.
* Add TARGET_UINT_TESTS profile to CryptoPkg.dsc to build only
  the target-based unit tests. This reduces the size of CryptoPkg
  components not related to unit testing by removing unit test
  specific assert handlers. Build target-based unit tests using
  OpensslLibFull.inf and OpensslLibFullAccel.inf.
* Remove the PACKAGE profile and instead make the ALL profile
  the default for CI testing that enables all services for all
  modules.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg: Remove PcdOpensslEcEnabled from CryptoPkg.dec
Michael D Kinney [Wed, 5 Oct 2022 00:57:18 +0000 (17:57 -0700)]
CryptoPkg: Remove PcdOpensslEcEnabled from CryptoPkg.dec

Remove the PcdOpensslEcEnabled PCD that is no longer used.
The EC feature is selected by using one of the OpensslLib
instances that includes the EC features which are either
OpensslLibFull.inf or OpensslLibFullAccel.inf.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library/OpensslLib: Remove PrintLib from INF files
Michael D Kinney [Tue, 4 Oct 2022 23:48:24 +0000 (16:48 -0700)]
CryptoPkg/Library/OpensslLib: Remove PrintLib from INF files

The OpensslLib instances do not directly use any PrintLib services.
Remove PrintLib from [LibraryClasses] sections of all OpensslLib
INF files.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library/OpensslLib: Produce consistent set of APIs
Michael D Kinney [Fri, 30 Sep 2022 21:05:21 +0000 (14:05 -0700)]
CryptoPkg/Library/OpensslLib: Produce consistent set of APIs

Update all OpensslLib instances so they produce all the APIs used
by the BaseCryptLib instances. Not producing the same set of APIs
for a library class does not follow the EDK II library class rules
and breaks the assumptions that consumers of the OpensslLib may
make about which services are present.

* Add missing declaration of the private library class OpensslLib
  to CryptoPkg.dec.
* Add SslNull.c with NULL implementations of SSL functions
* Add EcSm2Null.c with NULL implementations of EC/SM2 functions.
* Update OpensslLibCrypto.inf to include both SslNull.c and
  EcSm2Null.c so this library instance produces all the opensll
  APIs used by the BaseCryptLib instances.
* Update OpensslLib.inf and OpensslLibAccel.inf to include
  EcSm2Null.c so these library instances produce all the opensll
  APIs used by the BaseCryptLib instances.
* Add missing declaration of the private library class IntrinsicLib
  to CryptoPkg.dec

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library/OpensslLib: Combine all performance optimized INFs
Michael D Kinney [Sat, 24 Sep 2022 20:40:26 +0000 (13:40 -0700)]
CryptoPkg/Library/OpensslLib: Combine all performance optimized INFs

* Remove IA32/X64 specific INF files for performance
  optimized OpensslLib and combine into OpensslLibAccel.inf
  and OpensslLibFullAccel.inf.
* Remove use of PcdOpensslEcEnabled and let the platform
  select the EC feature by using either OpensslLibFull.inf
  or OpensslLibFullAccel.inf.
* With PcdOpensslEcEnabled removed, roll back style of opensslconf.h
  and remove  opensslconf_generated.h. Move the choice to disable
  EC/SM2 into OpensslLib INF files using OPENSSL_FLAGS define.
* Update OpensslLibContructor() API to be compatible with all
  FW phases by using types from Base.h and using RETURN_STATUS
  type and values instead of EFI_STATUS type and values.
* Add /wd4718 to VS2015x86 for IA32 and X64 to disable warning
  for recursive call with no side effects.  This is a false
  positive warning that is not produced with VS2017 or VS2019.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library: Cleanup BaseCryptLib and TlsLib
Michael D Kinney [Mon, 3 Oct 2022 21:38:13 +0000 (14:38 -0700)]
CryptoPkg/Library: Cleanup BaseCryptLib and TlsLib

* Move SysCall/inet_pton.c from BaseCryptLib to TlsLib.  The functions
  in this file are only used by TlsLib instances and not any CryptLib
  instances.
* Fix type mismatch in call to FreePool() in TlsConfig.c
* Remove use of gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled from
  TslLib and CryptLib instances
* Add missing *Null.c files to SecCryptLib.inf and RuntimeCryptLib.inf.
* Remove ARM and AARCH64 sections from SmmCryptLib.inf that does not
  support those architectures.
* Add missing PrintLib dependencies to [LibraryClasses] sections of
  CryptLib INF files
* Remove extra library classes from [LibraryClasses] sections of
  CryptLib INF files
* Remove unnecessary warning disables from [BuildOptions] sections of
  TlsLib and CryptLib INF files
* Remove RVCT support from SecCryptLib.inf

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Cc: Rebecca Cran <quic_rcran@quicinc.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes
Michael D Kinney [Fri, 30 Sep 2022 20:59:30 +0000 (13:59 -0700)]
CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes

* Update ImageTimeStampTest to return UNIT_TEST_PASSED instead of
  Status.  On success Status is TRUE(1), which was returning a unit
  test status of UNIT_TEST_ERROR_PREREQUISITE_NOT_MET.
* Update HmacTests to use the *Free() service from the HMAC family
  instead of FreePool().  Using FreePool() generates ASSERT() because
  the context being freed was not allocated using AllocatePool().

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library/BaseCryptLib: Update internal functions/variables
Michael D Kinney [Tue, 4 Oct 2022 03:45:20 +0000 (20:45 -0700)]
CryptoPkg/Library/BaseCryptLib: Update internal functions/variables

* Update BaseCryptLib internal worker functions to be 'STATIC'
* Update BaseCryptLib internal working functions to not use EFIAPI
* Add GLOBAL_REMOVE_IF_UNREFERENCED to BaseCryptLib global variables

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg/Library/BaseCryptLib: Add missing UNI file and fix format
Michael D Kinney [Tue, 4 Oct 2022 23:34:25 +0000 (16:34 -0700)]
CryptoPkg/Library/BaseCryptLib: Add missing UNI file and fix format

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoCryptoPkg: Document and disable deprecated crypto services
Michael D Kinney [Thu, 29 Sep 2022 16:32:54 +0000 (09:32 -0700)]
CryptoPkg: Document and disable deprecated crypto services

Also note services that are recommended to be disabled and
update CryptoPkg.dsc PcdCryptoServiceFamilyEnable settings
to disable all deprecated services.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
18 months agoremove GCC build warning
Wu, JessyX [Tue, 4 Oct 2022 02:03:54 +0000 (10:03 +0800)]
remove GCC build warning

Fix gcc: warning:
 -x c after last input file has no effect

These kind of flag can only affect the source code after them.
For the build command in build_rule.template, we have no other source code or object after these two flag.
It seems we don't need them here.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: JessyX Wu <jessyx.wu@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools: Fixed the multiple pairs brackets issue in GenFv
Chao Li [Thu, 20 Oct 2022 09:25:01 +0000 (17:25 +0800)]
BaseTools: Fixed the multiple pairs brackets issue in GenFv

If operation Werro is turned on when compiling BaseTools, the
multi-brackets warning will be reported. This issue is comes from on of
the LoongArch enabled patche. Removed extra pairs brackets to fix it.

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

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools: Fix check for ${PYTHON_COMMAND} in Tests/GNUmakefile
Rebecca Cran [Mon, 19 Sep 2022 21:39:10 +0000 (05:39 +0800)]
BaseTools: Fix check for ${PYTHON_COMMAND} in Tests/GNUmakefile

When checking if $PYTHON_COMMAND exists, curly braces should
be used instead of parentheses.

Also, "1" causes an error on FreeBSD: it's likely supposed to
be 2>&1 like other scripts.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools/Scripts/PatchCheck.py: Allow tab in Makefile
Bob Feng [Sun, 16 Oct 2022 03:41:05 +0000 (11:41 +0800)]
BaseTools/Scripts/PatchCheck.py: Allow tab in Makefile

The syntax for Makefiles requires that indented lines s
tart with a tab, but not a space.

This change of PatchCheck.py make the patch for Makefile/GNUmakefile
pass the PatchCheck.py.

Signed-off-by: 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>
18 months agoMdeModulePkg/XhciDxe: Add boundary check for TRB ring allocation
jdzhang [Tue, 18 Oct 2022 02:56:02 +0000 (10:56 +0800)]
MdeModulePkg/XhciDxe: Add boundary check for TRB ring allocation

According the Xhci Spec, TRB Rings may be larger than a Page, however they
shall not cross a 64K byte boundary, so add a parameter to indicate
whether the memory allocation is for TRB Rings or not. It will ensure the
allocation not crossing 64K boundary in UsbHcAllocMemFromBlock if the
memory is allocated for TRB Rings.

Signed-off-by: jdzhang <jdzhang@kunluntech.com.cn>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
18 months agoArmPkg/ArmMmuLib: Reuse XIP MMU routines when splitting entries
Ard Biesheuvel [Sat, 24 Sep 2022 20:31:44 +0000 (22:31 +0200)]
ArmPkg/ArmMmuLib: Reuse XIP MMU routines when splitting entries

In order to reduce the likelihood that we will need to rely on the logic
that disables and re-enables the MMU for updating a page table entry
safely, expose the XIP version of the helper routine via a HOB and use
it instead of the one that is copied into DRAM. Since the XIP copy is
already clean to the PoC, and will never end up getting unmapped during
a block entry split, we can use it safely without any cache maintenance,
and without running the risk of pulling the rug from under our feet when
updating an entry by going through an invalid mapping.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoArmPkg/ArmMmuLib: permit initial configuration with MMU enabled
Ard Biesheuvel [Sat, 2 Jul 2022 13:14:28 +0000 (15:14 +0200)]
ArmPkg/ArmMmuLib: permit initial configuration with MMU enabled

Permit the use of this library with the MMU and caches already enabled.
This removes the need for any cache maintenance for coherency, and is
generally better for robustness and performance, especially when running
under virtualization.

Note that this means we have to defer assignment of TTBR0 until the
page tables are ready to be used, and so UpdateRegionMapping() can no
longer read back TTBR0 directly to discover the root table address.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoArmPkg/ArmMmuLib: Disable and re-enable MMU only when needed
Ard Biesheuvel [Sat, 24 Sep 2022 16:26:19 +0000 (18:26 +0200)]
ArmPkg/ArmMmuLib: Disable and re-enable MMU only when needed

When updating a page table descriptor in a way that requires break
before make, we temporarily disable the MMU to ensure that we don't
unmap the memory region that the code itself is executing from.

However, this is a condition we can check in a straight-forward manner,
and if the regions are disjoint, we don't have to bother with the MMU
controls, and we can just perform an ordinary break before make.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoArmPkg/ArmMmuLib: don't replace table entries with block entries
Ard Biesheuvel [Sun, 3 Jul 2022 07:29:26 +0000 (09:29 +0200)]
ArmPkg/ArmMmuLib: don't replace table entries with block entries

Drop the optimization that replaces table entries with block entries and
frees the page tables in the subhierarchy that is being replaced. This
rarely occurs in practice anyway, and will require more elaborate TLB
maintenance once we switch to a different approach where we no longer
disable the MMU and nuke the TLB entirely every time we update a
descriptor in a way that requires break-before-make (BBM).

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
18 months agoBaseTools: Add missing spaces for PCD expression values in AutoGenC
Konstantin Aladyshev [Tue, 30 Aug 2022 10:20:27 +0000 (18:20 +0800)]
BaseTools: Add missing spaces for PCD expression values in AutoGenC

Currently the PCD values calculated from the expressions have different
formating from the simple byte arrays in AutoGenC.

Example:
The following definition in DEC:
gTokenSpaceGuid.PcdArray|{0x44, 0x33, 0x22, 0x11}|VOID*|0x55555555
gTokenSpaceGuid.PcdArrayByExpression|{UINT32(0x11223344)}|VOID*|0x66666666

Produces these strings in AutoGenC:
<...> _gPcd_<...>_PcdArray[4] = {0x44, 0x33, 0x22, 0x11};
<...> _gPcd_<...>_PcdArrayByExpression[4] = {0x44,0x33,0x22,0x11};

Add missing space character between the array elements to unify PCD value
formatting.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools: Correct initialization data size check for array PCDs
Konstantin Aladyshev [Tue, 30 Aug 2022 10:20:54 +0000 (18:20 +0800)]
BaseTools: Correct initialization data size check for array PCDs

Currently it is not possible to initialize all elements in the
array PCD.

For example, this PCD would result to a build failure:
gTokenSpaceGuid.PcdArray|{0x11, 0x22}|UINT8[2]|0x4C4CB9A3

Correct logical operator in the initialization data size checks to
fix the issue.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools/GenFds: Correct file type set for the PIC section
Konstantin Aladyshev [Tue, 30 Aug 2022 10:18:31 +0000 (18:18 +0800)]
BaseTools/GenFds: Correct file type set for the PIC section

Corrently the set of file types for the PIC section contains two
duplicate values.
Replace the duplicate value with the correct one to fix the issue.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools: Support COMPAT16 section generation
Konstantin Aladyshev [Tue, 30 Aug 2022 10:19:57 +0000 (18:19 +0800)]
BaseTools: Support COMPAT16 section generation

Currently COMPAT16 section type is not recognized and GenSec is called
without the "-s [SectionType]" argument.
Add COMPAT16 type to the SectionType dictionary to fix the issue.

Now this syntax works correctly:
```
FILE FREEFORM = <GUID>  {
  SECTION COMPAT16 = <FILE>
}
```

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools: Add support for SUBTYPE_GUID section generation
Konstantin Aladyshev [Wed, 20 Jul 2022 14:01:17 +0000 (22:01 +0800)]
BaseTools: Add support for SUBTYPE_GUID section generation

EFI_SECTION_FREEFORM_SUBTYPE_GUID is a leaf section type that contains
a single EFI_GUID in the header to describe the raw data.
Currently is is not possible to generate such section.
This patch adds initial support for the generation of such sections.
The added syntax for this type of section corresponds to EDKII
"[FV] section" documentation from the FDF Specification:
```
SECTION SUBTYPE_GUID <GUID> = <File>
```

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools: Correct BPDG tool error prints
Konstantin Aladyshev [Mon, 5 Sep 2022 09:19:23 +0000 (17:19 +0800)]
BaseTools: Correct BPDG tool error prints

Popen communication returns bytestrings. It is necessary to perform
decode on these strings before passing them to the EdkLogger that
works with ordinary strings.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools/FMMT: Add Shrink Fv function
Chen, Christine [Fri, 16 Sep 2022 01:51:18 +0000 (09:51 +0800)]
BaseTools/FMMT: Add Shrink Fv function

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

This function is used to remove the useless FV free space.
Usage: FMMT -s Inputfile Outputfile

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools/FMMT: Add Extract FV function
Chen, Christine [Fri, 16 Sep 2022 01:50:56 +0000 (09:50 +0800)]
BaseTools/FMMT: Add Extract FV function

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

With this patch "-e" parameter supports extract FV function.
Usage: FMMT -e Inputfile TargetFv Outputfile

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
18 months agoBaseTools: Remove duplicated words in Python tools
Pierre Gondois [Mon, 3 Oct 2022 07:47:32 +0000 (15:47 +0800)]
BaseTools: Remove duplicated words in Python tools

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

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
18 months agopip-requirement: Upgrade the edk2-basetools version from 0.1.29 to 0.1.39
Bob Feng [Sun, 16 Oct 2022 06:46:10 +0000 (14:46 +0800)]
pip-requirement: Upgrade the edk2-basetools version from 0.1.29 to 0.1.39

features and bug fixes:
1. Revert "BaseTools: Fix DSC LibraryClass precedence rule"
2. BaseTools: Correct BPDG tool error prints
3. BaseTools: Remove duplicated words in Python tools
4. BaseTools/FMMT: Add Extract FV function
5. BaseTools/FMMT: Add Shrink Fv function
6. BaseTools: Add support for SUBTYPE_GUID section generation
7. BaseTools: Support COMPAT16 section generation
8. BaseTools/GenFds: Correct file type set for the PIC section
9. BaseTools: Correct initialization data size check for array PCDs
10. BaseTools: Add missing spaces for PCD expression values in AutoGenC

Signed-off-by: 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: Yuwei Chen <yuwei.chen@intel.com>
18 months agoUefiCpuPkg/Test: Add unit tests for MP service PPI and Protocol
Jason Lou [Mon, 10 Oct 2022 13:52:42 +0000 (21:52 +0800)]
UefiCpuPkg/Test: Add unit tests for MP service PPI and Protocol

The code changes add unit tests based on current UnitTestFramework.
EdkiiPeiMpServices2PpiPeiUnitTest PEI module is used to test
EdkiiPeiMpServices2Ppi and EfiMpServiceProtocolDxeUnitTest DXE driver is
used to test EfiMpServiceProtocol.

Signed-off-by: Jason Lou <yun.lou@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
18 months agoUefiCpuPkg: Add R8/R9 etc in EccCheck ExceptionList
Tan, Dun [Mon, 17 Oct 2022 06:35:42 +0000 (14:35 +0800)]
UefiCpuPkg: Add R8/R9 etc in EccCheck ExceptionList

Add GENERAL_REGISTER.R8/R9 etc in EccCheck ExceptionList
of UefiCpuPkg/UefiCpuPkg.ci.yaml to pass CI EccCheck.R8/R9
in structure GENERAL_REGISTER of CpuExceptionHandlerTest.h
lead to EccCheck failure since no lower case characters in
R8/R9/R10 etc.

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>
18 months agoUefiCpuPkg: Add Pei/DxeCpuExceptionHandlerLibUnitTest in dsc
Tan, Dun [Mon, 17 Oct 2022 06:35:41 +0000 (14:35 +0800)]
UefiCpuPkg: Add Pei/DxeCpuExceptionHandlerLibUnitTest in dsc

Add Pei/DxeCpuExceptionHandlerLibUnitTest module in UefiCpuPkg.dsc

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>
18 months agoUefiCpuPkg: Add Unit tests for PeiCpuExceptionHandlerLib
Tan, Dun [Mon, 17 Oct 2022 06:35:40 +0000 (14:35 +0800)]
UefiCpuPkg: Add Unit tests for PeiCpuExceptionHandlerLib

The previous change adds unit test for DxeCpuExeptionHandlerLib
in 64bit mode. This change create a PEIM to add unit test for
PeiCpuExceptionHandlerLib based on previous change.It can run
in both 32bit and 64bit modes.

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>
18 months agoUefiCpuPkg: Add Unit tests for DxeCpuExceptionHandlerLib
Tan, Dun [Mon, 17 Oct 2022 06:35:39 +0000 (14:35 +0800)]
UefiCpuPkg: Add Unit tests for DxeCpuExceptionHandlerLib

Add target based unit tests for the DxeCpuExceptionHandlerLib.
A DXE driver is created to test DxeCpuExceptionHandlerLib.

Four test cases are created in this Unit Test module:
a.Test if exception handler can be registered/unregistered
for no error code exception.In the test case, only no error
code exception is triggered and tested by INTn instruction.

b.Test if exception handler can be registered/unregistered
for GP and PF. In the test case, GP exception is triggered
and tested by setting CR4_RESERVED_BIT to 1. PF exception
is triggered by writting to not-present or RO address.

c.Test if CpuContext is consistent before and after exception.
In this test case:
1.Set Cpu register to mExpectedContextInHandler before
exception. 2.Trigger exception specified by ExceptionType.
3.Store SystemContext in mActualContextInHandler and set
SystemContext to mExpectedContextAfterException in handler.
4.After return from exception, store Cpu registers in
mActualContextAfterException.
The expectation is:
1.Register values in mActualContextInHandler are the same
with register values in mExpectedContextInHandler.
2.Register values in mActualContextAfterException are the
same with register values mActualContextAfterException.

d.Test if stack overflow can be captured by CpuStackGuard
in both Bsp and AP. In this test case, stack overflow is
triggered by a funtion which calls itself continuously.
This test case triggers stack overflow in both BSP and AP.
All AP use same Idt with Bsp. The expectation is:
1. PF exception is triggered (leading to a DF if sepereated
stack is not prepared for PF) when Rsp<=StackBase+SIZE_4KB
since [StackBase, StackBase + SIZE_4KB] is marked as not
present in page table when PcdCpuStackGuard is TRUE.
2. Stack for PF/DF exception handler in both Bsp and AP is
succussfully switched by InitializeSeparateExceptionStacks.

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>
18 months agoUefiCpuPkg/CpuPageTableLib:Support PAE paging for PageTableParse
Tan, Dun [Tue, 11 Oct 2022 05:59:35 +0000 (13:59 +0800)]
UefiCpuPkg/CpuPageTableLib:Support PAE paging for PageTableParse

Support PAE paging for PageTableParse API in CpuPageTableLib.

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>
18 months agoUefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib
Liu, Zhiguang [Wed, 12 Oct 2022 07:27:45 +0000 (15:27 +0800)]
UefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib

The PEI instance of the CpuExceptionHandlerLib didn't implement the
RegisterCpuInterruptHandler() API. This patch adds the missing API.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
18 months agoBaseTools: Remove duplicated words in C tools
Pierre Gondois [Mon, 3 Oct 2022 07:47:31 +0000 (15:47 +0800)]
BaseTools: Remove duplicated words in C tools

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

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
18 months agoFix bug on SRIOV ReservedBusNum when ARI enable.
Foster Nong [Wed, 12 Oct 2022 02:36:56 +0000 (10:36 +0800)]
Fix bug on SRIOV ReservedBusNum when ARI enable.

If a device which support both features SR-IOV/ARI  has multi
functions, which maybe support 8-255. After enable ARI forwarding in
the root port and ARI Capable Hierarchy in the SR-IOV PF0.
The device will support and expose multi functions(0-255) with ARI ID routing.
In next device loop in below for() code, actually it still be in the
same SR-IOV device, and just some PF which is over 8 or higher
one(n*8), PciAllocateBusNumber() will allocate bus
number(ReservedBusNum - TempReservedBusNum)) for this PF. if reset
TempReservedBusNum as 0 in this case,it will allocate wrong bus number
for this PF because TempReservedBusNum should be total previous PF's
reserved bus numbers.

code:
  for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) {
    TempReservedBusNum = 0;
    for (Func = 0; Func <= PCI_MAX_FUNC; Func++) {
    //
    // Check to see whether a pci device is present
    //
    Status = PciDevicePresent (
                 PciRootBridgeIo,
                 &Pci,
                 StartBusNumber,
                 Device,
                 Func
                 );
    ...
    Status = PciAllocateBusNumber (PciDevice, *SubBusNumber,
    (UINT8)(PciDevice->ReservedBusNum - TempReservedBusNum), SubBusNumber);

The solution is add a new flag IsAriEnabled to help handle this case.
if ARI is enabled, then TempReservedBusNum will not be reset again
during all functions(1-255) scan with checking flag IsAriEnabled.

Signed-off-by: Foster Nong <foster.nong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
18 months agoMdeModulePkg: Fixed extra 1 SR-IOV reserved bus
Foster Nong [Wed, 12 Oct 2022 02:36:55 +0000 (10:36 +0800)]
MdeModulePkg: Fixed extra 1 SR-IOV reserved bus

Below code will calculate the reserved bus number for the each PF.

Based on the VF routing ID algorithm, PFRid and LastVF in below code
already sure that "All VFs and PFs must have distinct Routing IDs".
PF will be assigned Routing ID based on secBusNumber, ReservedBusNum
will add into SubBusNumber directly. So the SR-IOV device will be
assigned bus range as SecBusNumber ~ (SubBusNumber=(SecBusNumber +
ReservedBusNum)).
Thus "+1" in below code will cause extra 1 bus, and introduce a bus hole.

 PFRid  = EFI_PCI_RID (Bus, Device, Func);
 LastVF = PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStride;
 PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) -
 Bus + 1);

In SR-IOV spec, there is a note in section 2.1.2:
Note: Bus Numbers are a constrained resource. Devices are strongly
encouraged to avoid leaving ?holes? in their Bus Number usage to avoid
wasting Bus Numbers

So the issue can be fixed with below code change.
  PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) -
  Bus);

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

Signed-off-by: Foster Nong <foster.nong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
18 months agoNetworkPkg: Add LoongArch64 architecture.
Chao Li [Fri, 12 Nov 2021 07:27:29 +0000 (15:27 +0800)]
NetworkPkg: Add LoongArch64 architecture.

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

Add LoongArch64 architecture in to NetworkPkg.

Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
18 months agoMdeModulePkg/DxeIplPeim : LoongArch DxeIPL implementation.
Chao Li [Fri, 12 Nov 2021 07:19:30 +0000 (15:19 +0800)]
MdeModulePkg/DxeIplPeim : LoongArch DxeIPL implementation.

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

Implement LoongArch DxeIPL instance.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Co-authored-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
18 months agoMdeModulePkg/CapsuleRuntimeDxe: Add LoongArch64 architecture.
Chao Li [Fri, 12 Nov 2021 06:48:25 +0000 (14:48 +0800)]
MdeModulePkg/CapsuleRuntimeDxe: Add LoongArch64 architecture.

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

Add LoongArch in INF for building CapsuleRuntimeDxe LoongArch64 image.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
18 months agoMdeModulePkg/Logo: Add LoongArch64 architecture.
Chao Li [Fri, 12 Nov 2021 06:18:08 +0000 (14:18 +0800)]
MdeModulePkg/Logo: Add LoongArch64 architecture.

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

Add LoongArch64 architecture to the Logo.

Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
18 months agoMdePkg/BaseSafeIntLib: Add LoongArch64 architecture for BaseSafeIntLib.
Chao Li [Fri, 12 Nov 2021 04:37:47 +0000 (12:37 +0800)]
MdePkg/BaseSafeIntLib: Add LoongArch64 architecture for BaseSafeIntLib.

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

Add LoongArch64 architecture for BaseSafeIntLib library.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
18 months agoMdePkg/BaseSynchronizationLib: LoongArch cache related code.
Chao Li [Fri, 30 Sep 2022 23:38:07 +0000 (07:38 +0800)]
MdePkg/BaseSynchronizationLib: LoongArch cache related code.

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

Support LoongArch cache related functions.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Co-authored-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
18 months agoMdePkg/BaseCpuLib: LoongArch Base CPU library implementation.
Chao Li [Thu, 11 Nov 2021 12:14:20 +0000 (20:14 +0800)]
MdePkg/BaseCpuLib: LoongArch Base CPU library implementation.

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

Implement LoongArch CPU related functions in BaseCpuLib.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>