]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
3 years agoOvmfPkg/LsiScsiDxe: Probe PCI devices and look for LsiScsi
Gary Lin [Fri, 17 Jul 2020 06:11:23 +0000 (14:11 +0800)]
OvmfPkg/LsiScsiDxe: Probe PCI devices and look for LsiScsi

Implement LsiScsiControllerSupported() to probe the PCI ID and look for
LSI 53C895A.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200717061130.8881-5-glin@suse.com>

3 years agoOvmfPkg/LsiScsiDxe: Report the name of the driver
Gary Lin [Fri, 17 Jul 2020 06:11:22 +0000 (14:11 +0800)]
OvmfPkg/LsiScsiDxe: Report the name of the driver

Implement LsiScsiGetDriverName() and LsiScsiGetDeviceName()
to report the name of the driver.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200717061130.8881-4-glin@suse.com>

3 years agoOvmfPkg/LsiScsiDxe: Install the skeleton of driver binding
Gary Lin [Fri, 17 Jul 2020 06:11:21 +0000 (14:11 +0800)]
OvmfPkg/LsiScsiDxe: Install the skeleton of driver binding

Implement the dummy functions for EFI Driver Binding protocol.

v2: Remove "STATIC" from LsiScsiControllerSupported()

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200717061130.8881-3-glin@suse.com>

3 years agoOvmfPkg/LsiScsiDxe: Create the empty driver
Gary Lin [Fri, 17 Jul 2020 06:11:20 +0000 (14:11 +0800)]
OvmfPkg/LsiScsiDxe: Create the empty driver

Create the driver with only a dummy LsiScsiEntryPoint() for the further
implementation of the driver for LSI 53C895A SCSI controller.

v2: Fix the mixed-case GUID string

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200717061130.8881-2-glin@suse.com>

3 years agoMaintainers.txt: Remove invalid email address and a few other role changes
Jian J Wang [Thu, 16 Jul 2020 09:29:52 +0000 (17:29 +0800)]
Maintainers.txt: Remove invalid email address and a few other role changes

- Remove the address of Zhang, Chao from maintainer and reviewer list since
  he has left the community. Many thanks to his great contributions to edk2.
- Add Yao, Jiewen as maintainer of CryptoPkg, but remove him from
  SignedCapsulePkg.
- Add Wang, Jian J as maintainer list of SignedCapsulePkg

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
3 years agoBaseTools: Add Guid name support in GenFfs.
Yuwei Chen [Tue, 14 Jul 2020 05:30:40 +0000 (13:30 +0800)]
BaseTools: Add Guid name support in GenFfs.

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

The Fv Section in the FDF files use hard coding Guid values
which is inconvenient to manage. This patch adds Guid name
support in GenFfs to solve this problem.

Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Bob Feng<bob.c.feng@intel.com>
3 years agoSignedCapsulePkg: Address NULL pointer dereference case.
Vin Xue [Tue, 14 Jul 2020 02:09:35 +0000 (10:09 +0800)]
SignedCapsulePkg: Address NULL pointer dereference case.

Original code GetFmpImageDescriptors for OriginalFmpImageInfoBuf
pointer, if failed, return a NULL pointer. The OriginalFmpImageInfoBuf
should not be NULL and the NULL pointer dereference case
should be false positive.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Signed-off-by: Vin Xue <vinxue@outlook.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoMdeModulePkg/DisplayEngine: Add Debug message to show mismatch menu info
Dandan Bi [Fri, 1 Nov 2019 06:41:23 +0000 (14:41 +0800)]
MdeModulePkg/DisplayEngine: Add Debug message to show mismatch menu info

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

Currently when meet mismatch case for one-of and ordered-list
menu, just show a popup window to indicate mismatch, no more
info for debugging. This patch is to add more debug message
about mismatch menu info which is helpful to debug.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoOvmfPkg/OvmfPkg.dec: Adjust PcdMptScsiStallPerPollUsec token value
Gary Lin [Wed, 15 Jul 2020 08:20:31 +0000 (16:20 +0800)]
OvmfPkg/OvmfPkg.dec: Adjust PcdMptScsiStallPerPollUsec token value

The token value of PcdMptScsiStallPerPollUsec should be 0x3a since the
previous token value is 0x39.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Liran Alon <liran.alon@oracle.com>
Cc: Nikita Leshenko <nikita.leshchenko@oracle.com>
Signed-off-by: Gary Lin <glin@suse.com>
Message-Id: <20200715082031.30978-1-glin@suse.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
[lersek@redhat.com: clarify subject, fix typos in commit message]
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
3 years agoUefiCpuPkg: Add New Memory Attributes
Oleksiy Yakovlev [Thu, 2 Jul 2020 20:50:39 +0000 (16:50 -0400)]
UefiCpuPkg: Add New Memory Attributes

Add usage of EFI_MEMORY_SP and EFI_MEMORY_CPU_CRYPTO
attributes introduced in UEFI 2.8.
(UEFI 2.8, mantis 1919 and 1872).
Use attributes bitmasks, defined in MdePkg.

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200702205039.52400-5-oleksiyy@ami.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
3 years agoUefiCpuPkg: Update EFI_MEMORY_CACHETYPE_MASK definition
Oleksiy Yakovlev [Thu, 2 Jul 2020 20:50:38 +0000 (16:50 -0400)]
UefiCpuPkg: Update EFI_MEMORY_CACHETYPE_MASK definition

Add EFI_MEMORY_WP attribute to
EFI_MEMORY_CACHETYPE_MASK definition.

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>
Message-Id: <20200702205039.52400-4-oleksiyy@ami.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Eric Dong <eric.dong@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
3 years agoMdeModulePkg: Add New Memory Attributes
Oleksiy Yakovlev [Thu, 2 Jul 2020 20:50:37 +0000 (16:50 -0400)]
MdeModulePkg: Add New Memory Attributes

Add usage of EFI_MEMORY_SP and EFI_MEMORY_CPU_CRYPTO
attributes introduced in UEFI 2.8
(UEFI 2.8, mantis 1919 and 1872)
Use attributes bitmasks, defined in MdePkg.

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200702205039.52400-3-oleksiyy@ami.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
3 years agoMdePkg: Add New Memory Attributes
Oleksiy Yakovlev [Thu, 2 Jul 2020 20:50:36 +0000 (16:50 -0400)]
MdePkg: Add New Memory Attributes

Add usage of EFI_MEMORY_SP and EFI_MEMORY_CPU_CRYPTO
attributes introduced in UEFI 2.8
(UEFI 2.8, mantis 1919 and 1872)
Fix typos in EFI_MEMORY_CPU_CRYPTO description.
Add attributes bitmasks, grouped by type.

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Message-Id: <20200702205039.52400-2-oleksiyy@ami.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
3 years agoUnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()
Michael D Kinney [Thu, 11 Jun 2020 01:14:39 +0000 (18:14 -0700)]
UnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()

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

Add samples for all UnitTestLib macros including using
UT_EXPECT_ASSERT_FAILURE() for positive test cases where an
ASSERT() is triggered and detected correctly.

Additional test cases are added that disable ASSERT()s and
verify that UT_EXPECT_ASSERT_FAILURE() macros are skipped.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg/Library/BaseStackCheckLib: Fix PCD type in INF
Michael D Kinney [Mon, 6 Jul 2020 16:15:35 +0000 (09:15 -0700)]
MdePkg/Library/BaseStackCheckLib: Fix PCD type in INF

Update INF file to use a [Pcd] section instead of a
[FixedPcd] section.  [FixedPcd] should only be used in an
INF file if the source code looks up the PCD value using
the PcdLib FixedPcdGetxx() services.  Using [FixedPcd]
forces a platform to configure the PCD to type FixedAtBuild.
In this case, PcdDebugPropertyMask supports PCD types
FixedAtBuild and PatchableInModule.  Without this change
any platform that wants to use PcdDebugPropertyMask as
type PatchableInModule breaks the build.

Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib
Michael D Kinney [Thu, 11 Jun 2020 01:09:16 +0000 (18:09 -0700)]
MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib

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

Add the UT_EXPECT_ASSERT_FAILURE(FunctionCall, Status) macro
to the UnitTestLib that can be used to check if a function
under test triggers an ASSERT() condition.  If an ASSERT()
condition is triggered, then the macro returns.  If the
ASSERT() condition is not triggered, then the current unit
test fails with a status of UNIT_TEST_ERROR_TEST_FAILED.

If ASSERT()s are disabled, then this check for ASSERT()
behavior is not possible, and the check is skipped.

The global variable gUnitTestExpectAssertFailureJumpBuffer
is added to the UnitTestLib to save/restore context when
the UT_EXPECT_ASSERT_FAILURE(FunctionCall, Status) macro
is used.  The UT_EXPECT_ASSERT_FAILURE() macro uses the
SetJump() service with this global variable.  The UnitTestLib
service UnitTestDebugAssert() uses the LongJump() service
with this global to restore context if an ASSERT() is
triggered by the code under test.

Add UnitTestExpectAssertFailure() to the UnitTestLib class.
The UnitTestExpectAssertFailure() is called from the new
UT_EXPECT_ASSERT_FAILURE() macro after the status of this
macro check is known.

Add UnitTestDebugAssert() to the UnitTestLib class.  The
UnitTestDebugAssert() service is the same as the DebugLib
DebugAssert() service and is invoked from the DebugLib
_ASSERT() macro if unit testing is enabled.  This allows the
Unit Test Framework to know when code under test triggers an
ASSERT() condition.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg/Include: Hook DebugLib _ASSERT() for unit tests
Michael D Kinney [Thu, 11 Jun 2020 01:00:37 +0000 (18:00 -0700)]
MdePkg/Include: Hook DebugLib _ASSERT() for unit tests

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

Update DebugLib.h _ASSERT() macro to check if unit testing
is enabled and call UnitTestDebugAssert() instead of
DebugAssert() so the an ASSERT() condition that is triggered
by a function under test can be handled by the Unit Test
Framework.

If EDKII_UNIT_TEST_FRAMEWORK_ENABLED is not defined, then
the existing DebugLib behavior is preserved.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoUnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT()
Michael D Kinney [Thu, 11 Jun 2020 00:57:16 +0000 (17:57 -0700)]
UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT()

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

Add UnitTestDebugAssertLib that provides the UnitTestDebugAssert()
service and the gUnitTestExpectAssertFailureJumpBuffer global
variable.  This NULL library is linked against all host and target
unit test builds.  This guarantees that the UnitTestDebugAssert()
service is available to link against all libraries and modules that
use the DebugLib class.

EDKII_UNIT_TEST_FRAMEWORK_ENABLED must always be defined when
building unit tests so the behavior of the DebugLib ASSERT()
macros can be adjusted to allow the unit test framework to
catch an ASSERT() if it is triggered by a function under test.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
3 years agoUnitTestFrameworkPkg/UnitTestLib: Fix target mode log messages
Michael D Kinney [Thu, 11 Jun 2020 00:40:27 +0000 (17:40 -0700)]
UnitTestFrameworkPkg/UnitTestLib: Fix target mode log messages

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

Update the log messages generated in target mode to use
FileName instead of FunctionName.  FunctionName is an empty
string so the log messages generated do not provide enough
information to know the source of a unit test failure.

Using FileName combined with LineNumber provides the
right information to identify the location of a unit test
failure.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
3 years agoUnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup
Michael D Kinney [Thu, 11 Jun 2020 00:36:38 +0000 (17:36 -0700)]
UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup

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

If a unit test fails with an exception or an assert, then the
CmockaUnitTestFunctionRunner() is terminated and the logic
that follows the invocation of the unit test is skipped.  This
currently skips the logic that prints log messages.

Move the print of log messages to the end of the function
CmockaUnitTestTeardownFunctionRunner() that is guaranteed to
be executed when a unit test completes normally or is
terminated with an exception or an assert.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
3 years agoUnitTestFrameworkPkg: Change target mode DebugLib mapping
Michael D Kinney [Thu, 11 Jun 2020 00:49:12 +0000 (17:49 -0700)]
UnitTestFrameworkPkg: Change target mode DebugLib mapping

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

The default DebugLib for target mode was DebugLibNull.  This
library instance disables all ASSERT() and DEBUG() macros
which removes the ability to write unit tests that check for
ASSERT() behaviors.

The DebugLib is changed to PeiDxeDebugLibReportStatusCode.inf
that guarantees that DEBUG() and ASSERT() macros are active.  The
default ReportStatusCodeLib is set to BaseReportStatusCodeLibNull.inf
so no messages are sent to any devices preserving the DebugLibNull
behavior.

A platform specific unit test can always override these mappings
with a platform specific DebugLib.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
3 years agoUnitTestFrameworkPkg: Set host application stack size to 256KB
Michael D Kinney [Sun, 31 May 2020 23:39:06 +0000 (16:39 -0700)]
UnitTestFrameworkPkg: Set host application stack size to 256KB

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

The UEFI Specification defines the minimum stack size before
ExitBootServices() to be 128KB.  When running a host based unit
test, there may be additional stack overhead from the host
application environment and cmocka.

Update the build flags to set the size of the stack to 256KB
which is double the UEFI Specification requirement.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
3 years agoUnitTestFrameworkPkg: Enable source level debug for host tests
Michael D Kinney [Thu, 28 May 2020 02:49:33 +0000 (19:49 -0700)]
UnitTestFrameworkPkg: Enable source level debug for host tests

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

Optionally enable a feature to support source level debug of a
host based unit test.  By default, this feature is disabled.
Exceptions are caught by the unit test framework and are
interpreted as a test failure.

When a unit test is under development, bugs may generate
exceptions or a unit test developer may want to trace the
execution of unit tests to debug some unexpected behavior.
Defining UNIT_TESTING_DEBUG in the DSC file or from the build
command line allows exceptions to be caught by the host OS
and allows the developer to debug their unit test under
development or debug the Unit Test Framework itself.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
3 years agoUnitTestFrameworkPkg: Use host libraries from MdePkg
Michael D Kinney [Fri, 5 Jun 2020 18:22:30 +0000 (11:22 -0700)]
UnitTestFrameworkPkg: Use host libraries from MdePkg

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2800
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2799
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2798

Update the default unit test library mappings to use the
library instances from the MdePkg that are safe for host
based unit tests.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
3 years agoMdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
Michael D Kinney [Fri, 5 Jun 2020 18:21:03 +0000 (11:21 -0700)]
MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests

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

Add a new version of BaseLib that is safe for use from host based
unit test applications.  Host based unit test applications may need
to provide implementations of some BaseLib functions that provide
simple emulation to exercise the code under test.  The structure
UNIT_TEST_HOST_BASE_LIB is filled in with services that provide
default emulation for BaseLib APIs that would normally generate
exceptions in a host based unit test application.  This structure
allows an individual unit test to replace the default emulation of
a BaseLib service with an alternate version that is required by a
specific unit test.  A global variable of type UNIT_TEST_HOST_BASE_LIB
is provided through the new UnitTestHostBaseLib library class.

Normally cmocka would be used to mock services the code under
test calls.  However, the BaseLib is used by the Unit Test
Framework itself, so using a mocked interface is not possible.
The use of a structure to provide hooks for unit test is not
expected to be a common feature.  It should only be required
for libraries that are used by both the Unit Test Framework and
the code under test where the code under test requires a
different behavior than the Unit Test Framework.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg/BaseLib: Break out IA32/X64 GCC inline privileged functions
Michael D Kinney [Fri, 5 Jun 2020 18:05:19 +0000 (11:05 -0700)]
MdePkg/BaseLib: Break out IA32/X64 GCC inline privileged functions

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

Break out the IA32/X64 GCC inline functions that can not be used
in a unit test host application into their own source file.  This
does not make any changes to the BaseLib library instance.  This
is in preparation for a new BaseLib instances that is safe to use
with host-based unit test applications.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg/BaseCacheMaintenanceLibNull: Add Null instance for host testing
Michael D Kinney [Fri, 5 Jun 2020 18:01:43 +0000 (11:01 -0700)]
MdePkg/BaseCacheMaintenanceLibNull: Add Null instance for host testing

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

The services in CacheMaintenanceLib usually generate exceptions in a
unit test host application.  Provide a Null instance that can be safely
used.

This Null instance can also be used as a template for implementing
new instances of CacheMaintenanceLib.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing
Michael D Kinney [Fri, 5 Jun 2020 18:01:22 +0000 (11:01 -0700)]
MdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing

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

The services in CpuLib usually generate exceptions in a unit test
host application.  Provide a Null instance that can be safely used.

This Null instance can also be used as a template for implementing
new instances of CpuLib.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools/Python: Allow HOST_APPLICATION to use NULL libraries
Michael D Kinney [Thu, 11 Jun 2020 22:25:30 +0000 (15:25 -0700)]
BaseTools/Python: Allow HOST_APPLICATION to use NULL libraries

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

Update HOST_APPLICATION module type to use NULL library instances.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdeModulePkg/PartitionDxe: Add already start check for child hanldes
Zhichao Gao [Thu, 2 Jul 2020 07:31:53 +0000 (15:31 +0800)]
MdeModulePkg/PartitionDxe: Add already start check for child hanldes

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

The partition binding driver would run serval times during BDS.
If the partition support MBR, it would pass the first connection
in MBR partition child handler. The second connect for the same
device would return already started which would be treated as
not found. And it would continue to run next partition child
handler check. That is incorrect behavior to do next check if one
of the routine functions is passed. It may cause one device
installed serval partition child handle on it.
So treat the EFI_ALREADY_STARTED as EFI_SUCCESS to avoid incorrect
next partition child handle check.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoMdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROM
Zhichao Gao [Thu, 2 Jul 2020 01:03:12 +0000 (09:03 +0800)]
MdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROM

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

Refer to
http://manpages.ubuntu.com/manpages/bionic/man8/mkudffs.8.html.
Some Linux ISOs may have the MBR table for compatibility reasons
for Windows. The MBR tale would contain the partition entry with
start LBA0 and whole media size. There are two methods to check
the filesystem in the CD-ROM:
1. MBR partition check (Windows)
2. Whole disk check (MAC OS)

UEFI doesn't have the MBR check for UDF and Eltorito. But it may
pass the MBR check for such table and fail to detect the filesystem
of UDF. Skip the MBR check if the MBR is added for Windows
compatiblity so that the partition driver can continue UDF and
ElTorito check.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoMdeModulePkg/PartitionDxe: Correct the MBR last block value
Zhichao Gao [Mon, 6 Jul 2020 06:21:10 +0000 (14:21 +0800)]
MdeModulePkg/PartitionDxe: Correct the MBR last block value

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

PartitionValidMbr function's second parameter should be the
last sector of the device. For MBR partition, the block size is
sector size, i.e. 512 bytes. The original value is media block
last LBA which is counted by the media block size. And media
block size is not always 512 bytes, it may be larger which would
cause the MBR boundary check incorrect. The boundary check is
based on the partition entry start LBA and size of LBA which
are both counted by the sector number (512 bytes).

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoMdeModulePkg/Variable/RuntimeDxe: Fix return status from Reclaim()
Michael D Kinney [Fri, 10 Jul 2020 02:41:15 +0000 (19:41 -0700)]
MdeModulePkg/Variable/RuntimeDxe: Fix return status from Reclaim()

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

Update Reclaim() to return the error status from the reclaim
operation and not the status of SynchronizeRuntimeVariableCache()
that can be EFI_SUCCESS even through the status from reclaim
is an error.  Without this change, the return status from
SetVariable() can be EFI_SUCCESS even though the variable was
not actually set.  This occurs if the variable store is full
and a Reclaim() is invoked to free up space and even after all
possible space is freed, there is still not enough room for
the variable being set.  This condition should return
EFI_OUT_OF_RESOURCES.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Remove unnecessary API MtrrSetFixedMtrr()
Ray Ni [Mon, 13 Jul 2020 07:55:32 +0000 (15:55 +0800)]
UefiCpuPkg/MtrrLib: Remove unnecessary API MtrrSetFixedMtrr()

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

MtrrSetFixedMtrr() sets all the fixed MTRR settings.
But in fact MtrrSetAllMtrrs() is always used by callers to set all
MTRR settings including the fixed and variable ones.

The patch removes the unnecessary API MtrrSetFixedMtrr()
to simplify the MtrrLib API.

There is no code in edk2 and edk2-platforms repo that calls
MtrrSetFixedMtrr().

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Remove unnecessary API MtrrSetVariableMtrr()
Ray Ni [Mon, 13 Jul 2020 07:47:41 +0000 (15:47 +0800)]
UefiCpuPkg/MtrrLib: Remove unnecessary API MtrrSetVariableMtrr()

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

MtrrSetVariableMtrr() sets all the variable MTRR settings.
But in fact MtrrSetAllMtrrs() is always used by callers to set all
MTRR settings including the fixed and variable ones.

The patch removes the unnecessary API MtrrSetVariableMtrr() to
simplify the MtrrLib API.

There is no code in edk2 and edk2-platforms repo that calls
MtrrSetVariableMtrr().

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Remove unnecessary API MtrrGetVariableMtrr()
Ray Ni [Mon, 13 Jul 2020 07:43:44 +0000 (15:43 +0800)]
UefiCpuPkg/MtrrLib: Remove unnecessary API MtrrGetVariableMtrr()

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

MtrrGetVariableMtrr() returns all the variable MTRR settings.
But in fact MtrrGetAllMtrrs() and
MtrrGetMemoryAttributeInVariableMtrr() are used by callers to get the
MTRR settings. The former one returns both the fixed and variable
MTRR settings.

The patch removes the unnecessary API MtrrGetVariableMtrr() to
simplify the MtrrLib API.

There is no code in edk2 and edk2-platforms repo that calls
MtrrGetVariableMtrr().

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
3 years agoUefiPayloadPkg: Fix TerminalDxe build time configurable
Guo Dong [Mon, 13 Jul 2020 15:49:56 +0000 (08:49 -0700)]
UefiPayloadPkg: Fix TerminalDxe build time configurable

This patch fixed the merge issue for the previous TerminalDxe patch.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
3 years agoSecurityPkg/Tcg2Pei: Add missing PCRIndex in FvBlob event.
Jiewen Yao [Sun, 5 Jul 2020 11:31:26 +0000 (19:31 +0800)]
SecurityPkg/Tcg2Pei: Add missing PCRIndex in FvBlob event.

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

Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
3 years agoSecurityPkg/Tcg2Dxe: Add PcdTcgPfpMeasurementRevision in SpecId event.
Jiewen Yao [Sun, 5 Jul 2020 11:30:31 +0000 (19:30 +0800)]
SecurityPkg/Tcg2Dxe: Add PcdTcgPfpMeasurementRevision in SpecId event.

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

Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
3 years agoUefiPayloadPkg: Make TerminalDxe build time configurable
Patrick Rudolph [Sat, 11 Jul 2020 00:12:56 +0000 (17:12 -0700)]
UefiPayloadPkg: Make TerminalDxe build time configurable

As the TerminalDxe significantly slows down the boot menu rendering,
add the DISABLE_SERIAL_TERMINAL option to disable it at build time.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
3 years agoUefiPayloadPkg:Fix NOOPT build failure
Guo Dong [Sun, 21 Jun 2020 02:01:15 +0000 (19:01 -0700)]
UefiPayloadPkg:Fix NOOPT build failure

When build UEFI payload using NOOPT, it would build failure since
the FV size. So this patch increases FV size to support NOOPT.
If not NOOPT build, there is no change to FV size.

Signed-off-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
3 years agoUefiCpuPkg: PiSmmCpuDxeSmm skip MSR_IA32_MISC_ENABLE manipulation on AMD
Kirkendall, Garrett [Mon, 22 Jun 2020 13:18:25 +0000 (08:18 -0500)]
UefiCpuPkg: PiSmmCpuDxeSmm skip MSR_IA32_MISC_ENABLE manipulation on AMD

AMD does not support MSR_IA32_MISC_ENABLE.  Accessing that register
causes and exception on AMD processors.  If Execution Disable is
supported, but if the processor is an AMD processor, skip manipulating
MSR_IA32_MISC_ENABLE[34] XD Disable bit.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Garrett Kirkendall <garrett.kirkendall@amd.com>
Message-Id: <20200622131825.1352-5-Garrett.Kirkendall@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoUefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib
Kirkendall, Garrett [Mon, 22 Jun 2020 13:18:24 +0000 (08:18 -0500)]
UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib

Refactor StandardSignatureIsAuthenticAMD into BaseUefiCpuLib from
separate copies in BaseXApicLib, BaseXApicX2ApicLib, and MpInitLib.
This allows for future use of StandarSignatureIsAuthinticAMD without
creating more instances in other modules.

This function allows IA32/X64 code to determine if it is running on an
AMD brand processor.

UefiCpuLib is already included directly or indirectly in all modified
modules.  Complete move is made in this change.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Garrett Kirkendall <garrett.kirkendall@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Message-Id: <20200622131825.1352-4-Garrett.Kirkendall@amd.com>

3 years agoSourceLevelDebugPkg: SourceLevelDebugPkg.dsc add UefiCpuLib LibraryClass
Kirkendall, Garrett [Mon, 22 Jun 2020 13:18:23 +0000 (08:18 -0500)]
SourceLevelDebugPkg: SourceLevelDebugPkg.dsc add UefiCpuLib LibraryClass

In preparation for moving StandardSignatureIsAuthenticAMD to UefiCpuLib
in UefiCpuPkg, SourceLevelDebugPkg/SourceLevelDebugPkg.dsc needs
LibraryClass UefiCpuLib.
LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf will need
UefiCpuLib LibraryClass.  Likely most "real" platforms will be using
BaseX2XApicLib instance which already required UefiCpuLib.

Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Garrett Kirkendall <garrett.kirkendall@amd.com>
Message-Id: <20200622131825.1352-3-Garrett.Kirkendall@amd.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
3 years agoPcAtChipsetPkg: PcAtChipsetPkg.dsc add UefiCpuLib LibraryClass
Kirkendall, Garrett [Mon, 22 Jun 2020 13:18:22 +0000 (08:18 -0500)]
PcAtChipsetPkg: PcAtChipsetPkg.dsc add UefiCpuLib LibraryClass

In preparation for moving StandardSignatureIsAuthenticAMD to UefiCpuLib
in UefiCpuPkg, PcAtChipset/PcAtChipsetPkg.dsc needs LibraryClass
UefiCpuLib.
LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf will need
UefiCpuLib LibraryClass.  Likely most "real" platforms will be using
BaseX2XApicLib instance which already required UefiCpuLib.

Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Garrett Kirkendall <garrett.kirkendall@amd.com>
Message-Id: <20200622131825.1352-2-Garrett.Kirkendall@amd.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
3 years agoBaseTools: convert diff.order to LF-only
Leif Lindholm [Wed, 22 Apr 2020 15:08:01 +0000 (16:08 +0100)]
BaseTools: convert diff.order to LF-only

SetupGit.py sets the git config option diff.orderFile to
{edk2 directory}/BaseTools/Conf/diff.order, to override the default order
in which files are shown in a diff/patch/whatever. This is in imitation
of what is done manually in Laszlo's Unkempt Guide.

However, the version currently in the tree is in CRLF format, which makes
git interpret e.g. *.c as matching on *.c<CR>, finding no matches and
failing to apply the desired reordering. Note: this is true regardless of
whether running on Linux or Windows.

Convert the file to LF-only to make it work as expected.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg: Add Serial Terminal Device Type Guid
Oleksiy Yakovlev [Wed, 1 Jul 2020 19:35:39 +0000 (03:35 +0800)]
MdePkg: Add Serial Terminal Device Type Guid

Add definition of EFI_SERIAL_TERMINAL_DEVICE_TYPE_GUID.
It was miseed in "Extend SERIAL_IO with DeviceTypeGuid" patch.
(UEFI 2.8, mantis 1832)

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
3 years agoBaseTools: explicitly import email.header PatchCheck.py
Leif Lindholm [Thu, 2 Jul 2020 15:39:34 +0000 (23:39 +0800)]
BaseTools: explicitly import email.header PatchCheck.py

On Debian 10 (Buster), when running PatchCheck.py with python2, a
backtrace is printed, starting from:

  File "../edk2/BaseTools/Scripts/PatchCheck.py", line 595,
   in find_patch_pieces
    parts = email.header.decode_header(pmail.get('subject'))
  AttributeError: 'module' object has no attribute 'header'

When using python3, this backtrace does not appear.

Explicitly importing email.header resolves this for python2 and does not
appear to cause any issues with python3.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoBaseTools/PatchCheck.py: add exception for diff orderfile
Leif Lindholm [Thu, 2 Jul 2020 15:39:33 +0000 (23:39 +0800)]
BaseTools/PatchCheck.py: add exception for diff orderfile

SetupGit.py adds BaseTools/Conf/diff.order as a diff orderfile, but that
file currently has CRLF line endings, which causes all pattern matches
to fail and the ordering remaining unaffected.

Add an exception to PatchCheck.py (to the existing .gitmodules clause),
so that we can merge the fix to the config file.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoBaseTools: Fix string concatenation
Pierre Gondois [Wed, 1 Jul 2020 14:06:04 +0000 (22:06 +0800)]
BaseTools: Fix string concatenation

Using Python 3.7.2 on win32, when printing a FileBuildRule
instance, the following error occurs:
File "edk2\BaseTools\Source\Python\AutoGen\BuildEngine.py",
line 177, in __str__
  DestString = ", ".join(self.DestFileList)
  TypeError: sequence item 0: expected str instance, PathClass found

This patch converts each PathClass element of the list to a string
instance before concatenating them.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoBaseTools: Compile AML bytecode arrays into .obj file
Pierre Gondois [Wed, 1 Jul 2020 14:06:03 +0000 (22:06 +0800)]
BaseTools: Compile AML bytecode arrays into .obj file

The AmlToHex script and Posix/WindowsLike wrappers convert
an AML file to a .hex file, containing a C array storing
AML bytecode. This ".hex" file can then be included in a
C file, allowing to access the AML bytecode from this C
file.

The EDK2 build system doesn't allow to a depict dependency
orders between files of different languages. For instance,
in a module containing a ".c" file and a ".asl", the ".c"
file may or may not be built prior to the ".asl" file.
This prevents any inclusion of a generated ".hex" in a
".c" file since this later ".hex" file may or may not
have been created yet.

This patch modifies the AmlToC script to generate a C file
instead of a ".hex" file.
It also adds the generation of an intermediate ".amli" file
when compiling an ASL file, and adds a rule to convert this
".amli" to a C file.

This allows to generate a C file containing the AML bytecode
from an ASL file. This C file will then be handled by the EDK2
build system to generate an object file.
Thus, no file inclusion will be required anymore. The C file
requiring the AML bytecode as a C array, and the ASL file,
will be compiled independently. The C array must be defined
as an external symbol. The linker is resolving the
reference to the C array symbol.

To summarize, the flow goes as:
 -1. ASL file is compiled to AML;
 -2. AML file is copied to a ".amli" intermediate file;
 -3. EDK2 build system applies the rule relevant to ".amli"
     files. This is, calling the "AmlToC" script, generating
     a C file from the ".amli" file;
 -4. EDK2 build system applies the rule relevant to C files.
     This is creating an object file.
 -5. EDK2 build system links the object file containing the
     AML bytecode with the object file requiring it.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Suggested-by: Tomas Pilar <Tomas.Pilar@arm.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoBaseTools: Rename AmlToHex script to AmlToC
Pierre Gondois [Wed, 1 Jul 2020 14:06:02 +0000 (22:06 +0800)]
BaseTools: Rename AmlToHex script to AmlToC

The AmlToHex script and Posix/WindowsLike wrappers convert
an AML file to a .hex file, containing a C array storing
AML bytecode. This ".hex" file can then be included in a
C file, allowing to access the AML bytecode from this C
file.

The EDK2 build system doesn't allow to a depict dependency
orders between files of different languages. For instance,
in a module containing a ".c" file and a ".asl", the ".c"
file may or may not be built prior to the ".asl" file.
This prevents any inclusion of a generated ".hex" in a
".c" file since this later ".hex" file may or may not
have been created yet.

This patch renames the script as AmlToC. It is posted as
a separate patch to prevent git from seeing the renaming
as a deletion plus addition of a new file.
The ending line of the posix-like bin-wrapper script has
also been corrected.

This is a first step toward generating a C file containing
the AML bytecode from an ASL file. This C file will then
be handled by the EDK2 build system to generate an object
file.
Thus, no file inclusion will be required anymore. The C file
requiring the AML bytecode as a C array, and the ASL file,
will be compiled independently. The C array must be defined
as an external symbol. The linker is resolving the
reference to the C array symbol.

To summarize, the flow goes as:
 -1. ASL file is compiled to AML;
 -2. AML file is copied to a ".amli" intermediate file;
 -3. EDK2 build system applies the rule relevant to ".amli"
     files. This is, calling the "AmlToC" script, generating
     a C file from the ".amli" file;
 -4. EDK2 build system applies the rule relevant to C files.
     This is creating an object file.
 -5. EDK2 build system links the object file containing the
     AML bytecode with the object file requiring it.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Suggested-by: Tomas Pilar <Tomas.Pilar@arm.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoBaseTools: Generate multiple rules when multiple output files
Pierre Gondois [Wed, 1 Jul 2020 14:06:01 +0000 (22:06 +0800)]
BaseTools: Generate multiple rules when multiple output files

This patch modifies the Makefile generation not to stop
adding Makfile rules when the first final target is found.
E.g.:
If the following rules are described in build_rule.txt:
 -[Rule1]: .X files generate .Y and .Z files;
 -[Rule2]: .Z files generate .Z1 files.
Currently, if a File1.X file was part of the sources of a
module, only [Rule1] would be generated in the Makefile.
Indeed, there are no rules to apply to .Y files: .Y files
are a final target. However, there is still [Rule2] to
apply to .Z files.

This patch also adds a dependency between the first
ouput file of a rule and the other output files.
For instance, with the same example as above, File1.Y
and File1.Z are generated by the following rule:
File1.Y: File1.X
    <Generate File1.Y>
    <Generate File1.Z>

and the new dependency is:
File1.Z: File1.Y

This is necessary to keep a dependency order during the
execution of the Makefile. Indeed, .Y and .Z files are
generated by the execution of a common set of commands,
and without this rule, there is no explicit dependency
relation between them.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Suggested-by: Tomas Pilar <Tomas.Pilar@arm.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoBaseTools: PatchCheck: Exclude bash scripts from CRLF check
Pierre Gondois [Wed, 1 Jul 2020 14:06:00 +0000 (22:06 +0800)]
BaseTools: PatchCheck: Exclude bash scripts from CRLF check

Bash scripts require LF line endings to work.
PatchCheck.py checks that the files added in a patch have CRLF
line endings. It excludes files ending with the ".sh" extension
from this check.

Some bash script don't have a ".sh" extension. Most of them are
located in:
 - BaseTools/BinWrappers/PosixLike/
 - BaseTools/Bin/CYGWIN_NT-5.1-i686/

This patch excludes these folder plus BaseTools/BuildEnv from
this CRLF check.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoArmPlatformPkg/PL011UartLib: Check PID2 if FiFoDepth is zero
Irene Park [Tue, 9 Jun 2020 17:56:31 +0000 (13:56 -0400)]
ArmPlatformPkg/PL011UartLib: Check PID2 if FiFoDepth is zero

PL011UartLib determines its FIFO depth based on the PID2 value but
the register PID2 is not mandatory as per the SBSA spec.
This change won't check PID2 if PcdUartDefaultReceiveFifoDepth is set
to a value > 0.

Signed-off-by: Irene Park <ipark@nvidia.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
3 years agoShellPkg/AcpiView: Add application wrapper
Tomas Pilar [Fri, 19 Jun 2020 11:59:54 +0000 (12:59 +0100)]
ShellPkg/AcpiView: Add application wrapper

Simple application wrapper that invokes the shell
command wrapper for 'acpiview'.

This allows the AcpiView functionality to be used
on platforms with older specifications of the UEFI
shell or where the 'acpiview' command is not built in
due to platform build configuration.

Furthermore, this app can be integrated into more comprehensive
testing frameworks as a single component of a more thorough
specification compliance validation strategy.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
3 years agoShellPkg: Add AcpiViewCommandLib
Tomas Pilar [Fri, 19 Jun 2020 11:59:54 +0000 (12:59 +0100)]
ShellPkg: Add AcpiViewCommandLib

The UefiShellAcpiViewCommandLib is converted from NULL library to a
named library so that it may be used in modules other than shell.
The library interface exposes the main method for to AcpiView
functionality as well as a helper method to dump a buffer to a file.

The Shell module is still built by pulling UefiShellAcpiViewCommandLib
as a NULL library to preserve the modularity of shell builds.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
3 years agoShellPkg/AcpiView: Refactor DumpAcpiTableToFile
Tomas Pilar [Fri, 19 Jun 2020 11:59:54 +0000 (12:59 +0100)]
ShellPkg/AcpiView: Refactor DumpAcpiTableToFile

Method is refactored into two parts. A new method is
created that dumps arbitrary buffers into a newly created
file. This method is called from core code after the core code
determined the appropriate filename to be used.

This improves the modular design.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
3 years agoShellPkg/AcpiView: Move parameter parsing
Tomas Pilar [Fri, 19 Jun 2020 11:59:54 +0000 (12:59 +0100)]
ShellPkg/AcpiView: Move parameter parsing

Parsing command line parameters is done in the shell
command wrapper. This declutters the core code and improves
modular design.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
3 years agoShellPkg/AcpiView: Move table count reset
Tomas Pilar [Fri, 19 Jun 2020 11:59:54 +0000 (12:59 +0100)]
ShellPkg/AcpiView: Move table count reset

The table count module level symbols are now reset when
executing the core method, rather than the shell command
wrapper.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
3 years agoShellPkg/AcpiView: Refactor configuration
Tomas Pilar [Fri, 19 Jun 2020 11:59:54 +0000 (12:59 +0100)]
ShellPkg/AcpiView: Refactor configuration

A new file and header (AcpiViewConfig.[ch]) is created
that houses the user configuration. This declutters the
core code and improves modularity of the design.

The module level symbols for verbosity, table selection, and
highlighting are refactored into the new file.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
3 years agoShellPkg/AcpiView: Move log reset to main method
Tomas Pilar [Fri, 19 Jun 2020 11:59:54 +0000 (12:59 +0100)]
ShellPkg/AcpiView: Move log reset to main method

The error and warning counters are reset in the AcpiView main method.
This improves reusability of the main method.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
3 years agoCryptoPkg/BaseCryptLib: Add MARCO to disable the deprecated SHA1
Zhichao Gao [Tue, 16 Jun 2020 05:01:44 +0000 (13:01 +0800)]
CryptoPkg/BaseCryptLib: Add MARCO to disable the deprecated SHA1

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

SHA1 is deprecated but it is required for compatible issue.
So add a MARCO for the platform to disable the usage of SHA1 for
security.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
3 years agoCryptoPkg/BaseCryptLib: Add MARCO to disable the deprecated MD5
Zhichao Gao [Mon, 15 Jun 2020 08:06:17 +0000 (16:06 +0800)]
CryptoPkg/BaseCryptLib: Add MARCO to disable the deprecated MD5

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

MD5 is deprecated but it is required for compatible issue.
So add a MARCO for the platform to disable the usage of MD5 for
security.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
3 years agoIntelFsp2Pkg/FspSecCore: Use UefiCpuLib.
Dong, Eric [Sat, 27 Jun 2020 01:51:32 +0000 (09:51 +0800)]
IntelFsp2Pkg/FspSecCore: Use UefiCpuLib.

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

UefiCpuLib has API InitializeFloatingPointUnits.
Remove internal copy of InitializeFloatingPointUnits
in FspSecCoreM, use UefiCpuLib API.

This change also avoid later potential conflict when
use UefiCpuLib for FspSecCoreM module.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
3 years agoArmPkg/ArmMmuLib: Fix implicit cast
Pierre Gondois [Fri, 26 Jun 2020 15:28:04 +0000 (16:28 +0100)]
ArmPkg/ArmMmuLib: Fix implicit cast

While building with the following command line:

 build -b DEBUG -a AARCH64 -t VS2017 -p MdeModulePkg\MdeModulePkg.dsc

A missing cast triggers the following warning, then triggering an error:

  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c(652):
  warning C4152: nonstandard extension, function/data pointer
  conversion in expression

This patch first casts the function pointer to (UINTN), then to (VOID *),
followowing the C99 standard s6.3.2.3 "Pointer", paragraphs 5 and 6.
This suppresses the warning.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Suggested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
3 years agoArmVirtPkg/NorFlashQemuLib: disable NOR flash DT nodes upon discovery
Ard Biesheuvel [Tue, 23 Jun 2020 17:54:46 +0000 (19:54 +0200)]
ArmVirtPkg/NorFlashQemuLib: disable NOR flash DT nodes upon discovery

Our UEFI guest firmware takes ownership of the emulated NOR flash in
order to support the variable runtime services, and it does not expect
the OS to interfere with the underlying storage directly. So disable
the NOR flash DT nodes as we discover them, in a way similar to how we
disable the PL031 RTC in the device tree when we attach our RTC runtime
driver to it.

Note that this also hides the NOR flash bank that carries the UEFI
executable code, but this is not intended to be updatable from inside
the guest anyway, and if it was, we should use capsule update to do so.
Also, the first -pflash argument that defines the backing for this flash
bank is often issued with the 'readonly' modifier, in order to prevent
any changes whatsoever to be made to the executable firmware image by
the guest.

This issue has become relevant due to the following Linux changes,
which enable the flash driver stack for default build configurations
targetting arm64 and 32-bit ARM.

ce693fc2a877
("arm64: defconfig: Enable flash device drivers for QorIQ boards", 2020-03-16).

5f068190cc10
("ARM: multi_v7_defconfig: Enable support for CFI NOR FLASH", 2019-04-03)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
3 years agoBaseTools: Add external definitions for RISC-V assembly build
Abner Chang [Thu, 18 Jun 2020 00:59:51 +0000 (08:59 +0800)]
BaseTools: Add external definitions for RISC-V assembly build

Add opensbi external definitions to RISC-V build for assembly
code. Use GCC5_RISCV_OPENSBI_TYPES to refer to edk2 data type
for assembly files instead of using opensbi data type.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
3 years agoUefiPayloadPkg/Pci: Use the PCIE Base Addr stored in AcpiBoardInfo HOB
Ray Ni [Wed, 17 Jun 2020 08:34:29 +0000 (16:34 +0800)]
UefiPayloadPkg/Pci: Use the PCIE Base Addr stored in AcpiBoardInfo HOB

Today's UefiPayloadPkg always uses 0xE0000000 as the PCIE base address
and ignores the value set in AcpiBoardInfo HOB created by the boot
loader. This makes the payload binary cannot work in environment
where the PCIE base address set by boot loader doesn't equal to
0xE0000000.

The patch enhances UefiPayloadPkg so that the PCIE base address
set by boot loader in the AcpiBoardInfo HOB is used.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
3 years agoMdePkg/PciSegmentInfoLib: Add missing EFIAPI to GetPciSegmentInfo()
Ray Ni [Wed, 3 Jun 2020 09:42:23 +0000 (17:42 +0800)]
MdePkg/PciSegmentInfoLib: Add missing EFIAPI to GetPciSegmentInfo()

All public APIs should have EFIAPI modifier. Somehow PciSegmentInfoLib
missed the EFIAPI modifier.
The patch updates the library header file and NULL instance in MdePkg
to add the missing EFIAPI.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
3 years agoIntelFsp2WrapperPkg: Add FSP*_ARCH_UPD.
Chasel Chiu [Thu, 18 Jun 2020 12:59:37 +0000 (20:59 +0800)]
IntelFsp2WrapperPkg: Add FSP*_ARCH_UPD.

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

Provides sample code to include FSPT_ARCH_UPD initial values with
UPD header revision set to 2.

Cc: Maurice Ma <maurice.ma@intel.com>
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>
3 years agoIntelFsp2Pkg: Add FSP*_ARCH_UPD.
Chasel Chiu [Thu, 4 Jun 2020 06:43:40 +0000 (14:43 +0800)]
IntelFsp2Pkg: Add FSP*_ARCH_UPD.

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

Introduce FSPT_ARCH_UPD and FSPS_ARCH_UPD to support debug events
and multi-phase silicon initialization.
For backward compatibility the original structures are kept and
new ARCH_UPD structures will be included only when UPD header
revision equal or greater than 2.

GenCfgOpt script also updated to prevent from generating duplicate
FSPT_ARCH_UPD and FSPS_ARCH_UPD typedef structures.

Cc: Maurice Ma <maurice.ma@intel.com>
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>
3 years agoUefiCpuPkg/SecCore: Add pre-memory AP vector
Cole, Deric [Mon, 1 Jun 2020 22:32:25 +0000 (06:32 +0800)]
UefiCpuPkg/SecCore: Add pre-memory AP vector

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

Add a vector at 0xFF000 (0xFFFFF000) that can be used by Init-SIPI-SIPI
to start an AP before memory is initialized. This vector jumps into the
same SEC entry point as the ordinary reset vector, with a special value
of "AP" in the DI register. The platform-specific SEC code is expected
to check for that value and take a different path for APs, if this
feature is supported by the platform.

Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Deric Cole <deric.cole@intel.com>
3 years agoMdePkg: Include Acpi header file
Wasim Khan [Mon, 20 Apr 2020 07:48:01 +0000 (15:48 +0800)]
MdePkg: Include Acpi header file

ACPI memory mapped configuration space access (MCFG) table requires
defination of EFI_ACPI_DESCRIPTION_HEADER.

Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
3 years agoOvmfPkg: End timer interrupt later to avoid stack overflow under load
Igor Druzhinin [Tue, 16 Jun 2020 02:49:42 +0000 (03:49 +0100)]
OvmfPkg: End timer interrupt later to avoid stack overflow under load

RestoreTPL called while at TPL_HIGH_LEVEL unconditionally enables
interrupts even if called in interrupt handler. That opens a window while
interrupt is not completely handled but another interrupt could be
accepted.

If a VM starts on a heavily loaded host hundreds of periodic timer
interrupts might be queued while vCPU is descheduled (the behavior is
typical for a Xen host). The next time vCPU is scheduled again all of them
get delivered back to back causing OVMF to accept each one without
finishing a previous one and cleaning up the stack. That quickly results
in stack overflow and a triple fault.

Fix it by postponing sending EOI until we finished processing the current
tick giving interrupt handler opportunity to clean up the stack before
accepting the next tick.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Message-Id: <1592275782-9369-1-git-send-email-igor.druzhinin@citrix.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2815
Acked-by: Laszlo Ersek <lersek@redhat.com>
[lersek@redhat.com: add BZ ref; rewrap msg to silence PatchCheck.py]

3 years agoShellPkg: Update timezone of 3 cities
Dorapika Wu [Mon, 15 Jun 2020 02:44:43 +0000 (10:44 +0800)]
ShellPkg: Update timezone of 3 cities

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

The timezone of following cities should be updated:
Istanbul: UTC+3
Novosibirsk: UTC+7
Georgetown (Guyana): UTC-4

Signed-off-by: Dorapika Wu <chuan-hsun.wu@hpe.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
3 years agoOvmfPkg/OvmfPkg*.dsc: Change PCDs type about status code
Tan, Ming [Wed, 10 Jun 2020 02:56:34 +0000 (10:56 +0800)]
OvmfPkg/OvmfPkg*.dsc: Change PCDs type about status code

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

Since the type of PcdStatusCodeUseSerial and PcdStatusCodeUseMemory
in MdeModulePkg.dec are changed, so change them from
PcdsFeatureFlag to PcdsFixedAtBuild in dsc files.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Ming Tan <ming.tan@intel.com>
3 years agoUefiPayloadPkg/UefiPayloadPkgIa*.dsc: Change some PCDs type
Tan, Ming [Wed, 10 Jun 2020 02:56:33 +0000 (10:56 +0800)]
UefiPayloadPkg/UefiPayloadPkgIa*.dsc: Change some PCDs type

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

Since the type of PcdStatusCodeUseSerial and PcdStatusCodeUseMemory
in MdeModulePkg.dec are changed, so change them from
PcdsFeatureFlag to PcdsFixedAtBuild in dsc files.

Cc: Maurice Ma <maurice.ma@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Ming Tan <ming.tan@intel.com>
3 years agoEmulatorPkg/EmulatorPkg.dsc: Change PCDs type about status code
Tan, Ming [Wed, 10 Jun 2020 02:56:32 +0000 (10:56 +0800)]
EmulatorPkg/EmulatorPkg.dsc: Change PCDs type about status code

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

Since the type of PcdStatusCodeUseSerial and PcdStatusCodeUseMemory
in MdeModulePkg.dec are changed, so change them from
PcdsFeatureFlag to PcdsFixedAtBuild in dsc file.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Ming Tan <ming.tan@intel.com>
3 years agoMdeModulePkg.dec: Change PCDs for status code.
Tan, Ming [Wed, 10 Jun 2020 02:56:31 +0000 (10:56 +0800)]
MdeModulePkg.dec: Change PCDs for status code.

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

In order to support enable/disable report status code through memory
or serial dynamic, change the following PCDs from [PcdsFeatureFlag] to
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]:
  PcdStatusCodeUseSerial
  PcdStatusCodeUseMemory
The original plaforms can use PcdsFixedAtBuild in .dsc files to save size.

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Ming Tan <ming.tan@intel.com>
3 years agoEmbeddedPkg/NonCoherentDmaLib: avoid dereferencing bogus buffer address
Ard Biesheuvel [Wed, 17 Jun 2020 15:32:16 +0000 (17:32 +0200)]
EmbeddedPkg/NonCoherentDmaLib: avoid dereferencing bogus buffer address

The bounce buffering code in NonCoherentDmaLib copies data into the
bounce buffer using CopyMem(), but passes Map->HostAddress as the
source of the copy before it has been assigned its correct value.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
3 years agoArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure
Ard Biesheuvel [Tue, 16 Jun 2020 17:35:24 +0000 (19:35 +0200)]
ArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure

One of the side effects of the recent changes to PlatformBootManagerLib
changes to avoid connecting all devices on every boot is that we no
longer default to network boot on a virgin boot, but end up in the
UiApp menu. At this point, the UiApp will instantiate the autogenerated
boot options that we used to rely on as before, but since we are already
sitting idle in the root UiApp menu at that point, it does break the
unattended boot case where devices are expected to attempt a network
boot on the very first power on.

Let's work around this by refreshing all boot options explicitly in
the UnableToBoot() handler, and rebooting the system if doing so
resulted in a change to the total number of configured boot options.
This way, we ultimately end up in the UiApp as before if no boot
options could be started, but only after all the autogenerated ones
have been attempted as well.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
3 years agoMdeModulePkg/StatusCodeHandler: do not output \n\r for string data
Tan, Ming [Mon, 15 Jun 2020 02:03:44 +0000 (10:03 +0800)]
MdeModulePkg/StatusCodeHandler: do not output \n\r for string data

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

When output string data through serial port, will not ouput \n\r now.
Caller can output several data in one line, and output \n\r when needed.

Signed-off-by: Ming Tan <ming.tan@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoRevert "OvmfPkg: use generic QEMU image loader for secure boot enabled ..."
Laszlo Ersek [Mon, 15 Jun 2020 14:45:14 +0000 (16:45 +0200)]
Revert "OvmfPkg: use generic QEMU image loader for secure boot enabled ..."

This reverts commit ced77332cab626f35fbdb36630be27303d289d79.

The command

  virt-install --location NETWORK-URL

downloads the vmlinuz and initrd files from the remote OS tree, and passes
them to the guest firmware via fw_cfg.

When used with IA32 / X64 guests, virt-install expects the guest firmware
to do two things, at the same time:

- launch the fw_cfg kernel image even if the latter does not pass SB
  verification (SB checking is supposed to be bypassed entirely in favor
  of the Linux/x86 Boot Protocol),

- still let the guest kernel perceive SB as enabled.

Commit ced77332cab6 prevented this, by removing the Linux/x86 Boot
Protocol from such an OVMF image that was built with SECURE_BOOT_ENALBE.
While that's the right thing in theory, in practice "virt-install
--location NETWORK-URL" is entrenched, and we shouldn't break it.

We can tolerate the Linux/x86 Boot Protocol as a one-of-a-kind SB bypass
for direct-booted kernels, because:

- the fw_cfg content comes from QEMU, and the guest is already at QEMU's
  mercy,

- in the guest, OS boots after the initial installation will use "shim"
  rather than an fw_cfg kernel, which we can consider somewhat similar to
  "Audit Mode / Deployed Mode" (~ trust for install, lock down after).

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Message-Id: <20200615144514.24597-1-lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[lersek@redhat.com: truncate the subject line, originally auto-generated
 by git-revert, to pacify PatchCheck.py]

3 years agoStandaloneMmPkg/StandaloneMmCoreEntryPoint: relocate StMM core on the fly
Ard Biesheuvel [Tue, 9 Jun 2020 08:34:27 +0000 (10:34 +0200)]
StandaloneMmPkg/StandaloneMmCoreEntryPoint: relocate StMM core on the fly

Apply PE/COFF fixups when starting up the standalone MM core, so that
it can execute at any address regardless of the link time address.

Note that this requires the PE/COFF image to be emitted with its
relocation section preserved. Special care is taken to ensure that
TE images are dealt with correctly as well.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoStandaloneMmPkg: generate position independent code for StMM core
Ard Biesheuvel [Tue, 9 Jun 2020 08:24:06 +0000 (10:24 +0200)]
StandaloneMmPkg: generate position independent code for StMM core

The standalone MM core runs in a restricted environment that is set
up by a higher privilege level, and which may not allow memory regions
to be writable and executable at the same time.

This means that making the StMM core self-relocatable requires that
all the targets of the relocation fixups are outside of the executable
region of the image, given that we cannot remap the executable code
writable from the executable code itself without losing those execute
permissions.

So instead, use the existing toolchain support to ensure that position
independent code is used where possible, and that all the remaining
relocated quantities are emitted into the data section. (Note that
staticallly initialized const pointers will be emitted into the
.data.rel.ro section, which gets pulled into the .data section by
our linker script)

To ensure that we don't pick up any absolute references in executable
code inadvertently (e.g., in assembler code), add the '-z text' linker
option which will force the build to fail in this case.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoStandaloneMmPkg/Core: add missing GUID reference
Ard Biesheuvel [Tue, 9 Jun 2020 08:23:23 +0000 (10:23 +0200)]
StandaloneMmPkg/Core: add missing GUID reference

The Standalone core uses gEfiHobMemoryAllocModuleGuid, but failed to
declare this in its INF.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoStandaloneMmPkg/Core: fix bogus FV pointer in DEBUG string
Ard Biesheuvel [Tue, 9 Jun 2020 08:16:05 +0000 (10:16 +0200)]
StandaloneMmPkg/Core: fix bogus FV pointer in DEBUG string

FvIsBeingProcessed () emits a DEBUG print with the intent to print
the memory address of the FV that is being processed, but instead,
it prints the contents of an uninitialized stack variable.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoMdePkg/BasePrintLib: avoid absolute addresses for error strings
Ard Biesheuvel [Wed, 10 Jun 2020 07:36:35 +0000 (09:36 +0200)]
MdePkg/BasePrintLib: avoid absolute addresses for error strings

The mStatusString[] array is constructed as an array of pointer-to-char,
which means that on X64 or AARCH64, it is emitted as a single linear list
of 64-bit quantities, each containing the absolute address of one of the
string literals in memory.

This means that each string takes up 8 bytes of additional space, along
with 2 bytes of relocation data. It also means that extra work needs to
be done at runtime to process these relocations, every time a module is
loaded that incorporates this library.

So fix both issues, by splitting mStatusString into two arrays of char
arrays. The memory footprint decreases from 955 to 843 bytes, and given
that in the latter case, the overhead consists of 278 NUL characters rather
than 390 bytes worth of absolute addresses and relocation records, the size
of a compressed image is reduced even further. For example, when building
ArmVirtQemu.dsc in RELEASE mode for AARCH64 with the GCC5 profile, I get:

  Before

  FV Space Information
  FVMAIN [100%Full] 5329920 total, 5329920 used, 0 free
  FVMAIN_COMPACT [38%Full] 2093056 total, 811840 used, 1281216 free

  After

  FV Space Information
  FVMAIN [100%Full] 5321728 total, 5321728 used, 0 free
  FVMAIN_COMPACT [38%Full] 2093056 total, 809696 used, 1283360 free

So the uncompressed contents of the compressed image are 8 KB smaller,
whereas the resulting flash image (consisting of the compressed image
along with SEC, PEI_CORE and a set of PEIMs that execute in place) is
2 KB smaller.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoShellPkg: smbiosview - print field values as unsigned integers
Rebecca Cran [Wed, 6 May 2020 16:52:05 +0000 (00:52 +0800)]
ShellPkg: smbiosview - print field values as unsigned integers

This prevents overflow when printing DWORD fields such as the type 17
tables's extended DIMM size.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
3 years agoUnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature
Michael Kubacki [Thu, 16 Apr 2020 23:47:18 +0000 (16:47 -0700)]
UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature

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

Removes the FrameworkHandle parameter from SaveFrameworkState() in the
UnitTestLib library instance and updates callers of the function in the
library to use the new function signature.

Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
3 years agoMdePkg/UnitTestLib.h: Drop FrameworkHandle param from SaveFrameworkState()
Michael Kubacki [Thu, 16 Apr 2020 23:28:19 +0000 (16:28 -0700)]
MdePkg/UnitTestLib.h: Drop FrameworkHandle param from SaveFrameworkState()

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

The framework handle can be retrieved from GetActiveFrameworkHandle()
internal to SaveFrameworkState() so this change removes the parameter
from the function signature.

Cc: Bret Barkelew <brbarkel@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
3 years agoArmVirtPkg: remove unused files
Ard Biesheuvel [Mon, 8 Jun 2020 16:51:26 +0000 (18:51 +0200)]
ArmVirtPkg: remove unused files

We no longer use ELF PIE executables to implement the self-relocating
PrePi so drop the custom linker script and visibility override header
file.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Sami Mujawar <Sami.Mujawar@arm.com>
3 years agoArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation
Ard Biesheuvel [Mon, 8 Jun 2020 11:07:54 +0000 (13:07 +0200)]
ArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation

Instead of having a GCC specific routine to perform self-relocation
based on ELF metadata, use the PE/COFF metadata and the existing
PeCoff library routines. This reduces the amount of bespoke assembler
code that is a burden to maintain, and is not portable across the set
of toolchains we support.

This does require some special care, as we have no control over how
the C code references global symbols, so we need to emit these
references from the calling assembler code. Otherwise, they may be
emitted as absolute references, in which case they need to be fixed
up themselves, leading to a circular dependency.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Sami Mujawar <Sami.Mujawar@arm.com>
3 years agoArmVirtPkg: add FDF rule for self-relocating PrePi
Ard Biesheuvel [Mon, 8 Jun 2020 11:02:12 +0000 (13:02 +0200)]
ArmVirtPkg: add FDF rule for self-relocating PrePi

In preparation for making the self-relocating PrePi use the ordinary
BasePeCoffLib routines for relocating the image in place in memory
at start, add a special FDF rule that builds SEC modules as PE32
images with the relocation metadata preserved.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Sami Mujawar <Sami.Mujawar@arm.com>
3 years agoEmbeddedPkg/MmcDxe: Added MaxBlock Transfer Limit 65535 in R/W.
Gaurav Jain [Fri, 3 Apr 2020 09:24:07 +0000 (14:54 +0530)]
EmbeddedPkg/MmcDxe: Added MaxBlock Transfer Limit 65535 in R/W.

Moved BlockCount calculation below BufferSize Validation checks.
First Ensure Buffersize is Not Zero and multiple of Media BlockSize.
then calculate BlockCount and perform Block checks.

Corrected BlockCount calculation, as BufferSize is multiple of BlockSize,
So adding (BlockSize-1) bytes to BufferSize and
then divide by BlockSize will have no impact on BlockCount.

Reading Large Images from MMC causes errors.
As per SD Host Controller Spec version 4.20,
Restriction of 16-bit Block Count transfer is 65535.
Max block transfer limit in single cmd is 65535 blocks.
Added Max Block check that can be processed is 0xFFFF.
then Update BlockCount on the basis of MaxBlock.

Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
Reviewed-by: "Loh, Tien Hock" <tien.hock.loh@intel.com>
3 years agoBaseTools/PatchCheck.py: Add LicenseCheck
Shenglei Zhang [Tue, 21 Apr 2020 06:45:02 +0000 (14:45 +0800)]
BaseTools/PatchCheck.py: Add LicenseCheck

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2691
For files to be added to the tree, this feature will check
whether it has BSD plus patent license. If not, licenses listed in
Readme are also accepted but warning will be reported.
Otherwise, it should be error.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoIntelFsp2Pkg: Add Fsp22SecCoreS.inf to Dsc.
Chasel Chiu [Wed, 10 Jun 2020 02:21:52 +0000 (10:21 +0800)]
IntelFsp2Pkg: Add Fsp22SecCoreS.inf to Dsc.

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

DSC is incomplete according to the established CI policies.
Fsp22SecCoreS.inf needs to be added to the Components section
for completeness.

Cc: Maurice Ma <maurice.ma@intel.com>
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: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
3 years agoBaseTools GenFv: Report the correct spare FV image size
Liming Gao [Tue, 9 Jun 2020 08:16:48 +0000 (16:16 +0800)]
BaseTools GenFv: Report the correct spare FV image size

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

If the top FFS is placed in FV image, current FV will show there is no space.
In fact, the pad ffs in FV image can be regarded as the spare space.
This change reports the max pad ffs size as the spare space for use.

Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
3 years agoArmPkg/ArmExceptionLib: use static buffer for sp_el0
Heyi Guo [Tue, 9 Jun 2020 01:26:30 +0000 (09:26 +0800)]
ArmPkg/ArmExceptionLib: use static buffer for sp_el0

The exception library is also used in DxeMain before memory services
are available, and AllocatePages() will fail in this case and cause
sp_el0 remains 0. Then if any exception occurs before CpuDxe driver is
loaded, a recursive exception will be trigged by page translation
fault for sp = 0 - 0x130.

Use static buffer instead to fix this issue.

Signed-off-by: Heyi Guo <guoheyi@linux.alibaba.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>