]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
22 months agoDxeMain: Fix the bug that StackGuard is not enabled
Ray Ni [Fri, 10 Jun 2022 08:43:32 +0000 (16:43 +0800)]
DxeMain: Fix the bug that StackGuard is not enabled

Commit e7abb94d1 removed InitializeCpuExceptionHandlersEx
and updated DxeMain to call InitializeCpuExceptionHandlers
for exception setup. But the old behavior that calls *Ex() sets
up the stack guard as well. To match the old behavior,
the patch calls InitializeSeparateExceptionStacks.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
22 months agoArmPkg/ArmExceptionLib: Follow new CpuExceptionHandlerLib APIs
Ray Ni [Mon, 13 Jun 2022 01:51:06 +0000 (09:51 +0800)]
ArmPkg/ArmExceptionLib: Follow new CpuExceptionHandlerLib APIs

CpuExceptionHandlerLib has been refactored with following changes:
1. Removed InitializeCpuInterruptHandlers in 2a09527ebcb459b40
2. Removed InitializeCpuExceptionHandlersEx and
   added InitializeSeparateExceptionStacks in e7abb94d1fb8a0e7

The patch updates ARM version of CpuExceptionHandlerLib to follow
the API changes.

The functionality to ARM platforms should be none.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
22 months agoMdePkg/BaseLib: Add CRC16-ANSI and CRC32c implementations
Pedro Falcato [Thu, 7 Apr 2022 22:02:00 +0000 (06:02 +0800)]
MdePkg/BaseLib: Add CRC16-ANSI and CRC32c implementations

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

Add the CRC16-ANSI and CRC32C implementations previously found at
Features/Ext4Pkg/Ext4Dxe/Crc{16,32c}.c to BaseLib.

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: Pedro Falcato <pedro.falcato@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
22 months agoMdePkg: Remove "assert" from SmmCpuRendevousLibNull.c
Zhihao Li [Wed, 18 May 2022 12:01:51 +0000 (20:01 +0800)]
MdePkg: Remove "assert" from SmmCpuRendevousLibNull.c

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

Some drivers will break down when they use
SmmWaitForAllProcessor() which from SmmCpuRendezvousLibNull.c.
Removing the code "ASSERT(False)" will make consumer
work normally if they keep default setting for sync mode.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Zhihao Li <zhihao.li@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
22 months agoRevert "OvmfPkg/Sec: fix stack switch"
Gerd Hoffmann [Fri, 10 Jun 2022 11:02:44 +0000 (19:02 +0800)]
Revert "OvmfPkg/Sec: fix stack switch"

This reverts commit ff36b2550f94dc5fac838cf298ae5a23cfddf204.

Has no effect because GCC_IA32_CC_FLAGS and GCC_X64_CC_FLAGS are unused.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoMpInitLib: Move the Above1Mb vector allocation to MpInitLibInitialize
Ray Ni [Sun, 8 May 2022 05:22:49 +0000 (13:22 +0800)]
MpInitLib: Move the Above1Mb vector allocation to MpInitLibInitialize

The AP vector consists of 2 parts:
1. the initial 16-bit code that should be under 1MB and page aligned.
2. the 32-bit/64-bit code that can be anywhere in the memory with any
   alignment.

The need of part #2 is because the memory under 1MB is temporary
"stolen" for use and will "give" back after all AP wake up. The range
of memory is not marked as code page in page table. CPU may trigger
exception as soon as NX is enabled.

The part #2 memory allocation can be done in the MpInitLibInitialize.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoMpInitLib: Only allocate below 1MB memory for 16bit code
Ray Ni [Sat, 7 May 2022 14:25:19 +0000 (22:25 +0800)]
MpInitLib: Only allocate below 1MB memory for 16bit code

Today's implementation allocates below 1MB memory for the 16bit, 32bit
and 64bit code.

But it's not necessary since now the 32bit and 64bit code run at high
memory no matter in PEI and DXE phase.

The patch simplifies the logic to remove the code that handles the
case when WakeupBufferHigh is 0.
It also reduce the memory foot print under 1MB by allocating
memory for 16bit code only.

MP_CPU_EXCHANGE_INFO is still under 1MB which is immediate
after the 16bit code.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoMpInitLib: Put SEV logic in separate file
Ray Ni [Sat, 7 May 2022 13:19:08 +0000 (21:19 +0800)]
MpInitLib: Put SEV logic in separate file

The patch does several simplifications:
1. Treat SwitchToRealProc as part of RendezvousFunnelProc.
   So the common logic in MpLib.c doesn't need to be aware of
   SwitchToRealProc.
   As a result, SwitchToRealSize/Offset are removed from
   MP_ASSEMBLY_ADDRESS_MAP.

2. Move SwitchToRealProc to AmdSev.nasm.
   All other assembly code in AmdSev.nasm is called through
   OneTimeCall.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Michael Roth <michael.roth@amd.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
22 months agoMpInitLib: remove unneeded global ASM_PFX
Ray Ni [Sat, 7 May 2022 12:34:36 +0000 (20:34 +0800)]
MpInitLib: remove unneeded global ASM_PFX

global in NASM file is used for symbols that are
referenced in C files.
Remove unneeded global keyword in NASM file.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoMpInitLib: Allocate code buffer for PEI phase
Ray Ni [Sat, 7 May 2022 09:10:49 +0000 (17:10 +0800)]
MpInitLib: Allocate code buffer for PEI phase

Today's implementation assumes PEI phase runs at 32bit so
the execution-disable feature is not applicable.
It's not always TRUE.
The patch allocates 32bit&64bit code buffer for PEI phase as well.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Add InitializeSeparateExceptionStacks
Ray Ni [Fri, 20 May 2022 11:12:35 +0000 (19:12 +0800)]
CpuException: Add InitializeSeparateExceptionStacks

Today InitializeCpuExceptionHandlersEx is called from three modules:
1. DxeCore (links to DxeCpuExceptionHandlerLib)
    DxeCore expects it initializes the IDT entries as well as
    assigning separate stacks for #DF and #PF.
2. CpuMpPei (links to PeiCpuExceptionHandlerLib)
   and CpuDxe (links to DxeCpuExceptionHandlerLib)
    It's called for each thread for only assigning separate stacks for
    #DF and #PF. The IDT entries initialization is skipped because
    caller sets InitData->X64.InitDefaultHandlers to FALSE.

Additionally, SecPeiCpuExceptionHandlerLib, SmmCpuExceptionHandlerLib
also implement such API and the behavior of the API is simply to initialize
IDT entries only.

Because it mixes the IDT entries initialization and separate stacks
assignment for certain exception handlers together, in order to know
whether the function call only initializes IDT entries, or assigns stacks,
we need to check:
1. value of InitData->X64.InitDefaultHandlers
2. library instance

This patch cleans up the code to separate the stack assignment to a new API:
InitializeSeparateExceptionStacks().

Only when caller calls the new API, the separate stacks are assigned.
With this change, the SecPei and Smm instance can return unsupported which
gives caller a very clear status.

The old API InitializeCpuExceptionHandlersEx() is removed in this patch.
Because no platform module is consuming the old API, the impact is none.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
22 months agoCpuException: Remove InitializeCpuInterruptHandlers
Ray Ni [Wed, 18 May 2022 09:51:21 +0000 (17:51 +0800)]
CpuException: Remove InitializeCpuInterruptHandlers

InitializeCpuExceptionHandlers() expects caller allocates IDT while
InitializeCpuInterruptHandlers() allocates 256 IDT entries itself.

InitializeCpuExceptionHandlers() fills max 32 IDT entries allocated
by caller. If caller allocates 10 entries, the API just fills 10 IDT
entries.

The inconsistency between the two APIs makes code hard to
unerstand and hard to share.

Because there is only one caller (CpuDxe) for
InitializeCpuInterruptHandler(), this patch updates CpuDxe driver
to allocates 256 IDT entries then call
InitializeCpuExceptionHandlers().

This is also a backward compatible change.

With this change, InitializeCpuInterruptHandlers() is removed
completely.

And InitializeCpuExceptionHandlers() fills max 32 entries for PEI
and SMM instance, max 256 entries for DXE instance.
Such behavior matches to the original one.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Avoid allocating page but using global variables
Ray Ni [Wed, 18 May 2022 06:45:37 +0000 (14:45 +0800)]
CpuException: Avoid allocating page but using global variables

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Init global variables in-place
Ray Ni [Wed, 18 May 2022 05:56:05 +0000 (13:56 +0800)]
CpuException: Init global variables in-place

Additionally removed two useless global variables:
"SPIN_LOCK  mDisplayMessageSpinLock" from SMM instance.
"UINTN mEnabledInterruptNum" from DXE instance.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
22 months agoCpuException: Avoid allocating code pages for DXE instance
Ray Ni [Wed, 18 May 2022 05:44:24 +0000 (13:44 +0800)]
CpuException: Avoid allocating code pages for DXE instance

Today the DXE instance allocates code page and then copies the IDT
vectors to the allocated code page. Then it fixes up the vector number
in the IDT vector.

But if we update the NASM file to generate 256 IDT vectors, there is
no need to do the copy and fix-up.

A side effect is 4096 bytes (HOOKAFTER_STUB_SIZE * 256) is used for
256 IDT vectors while 32 IDT vectors only require 512 bytes without
this change, in following library instances:
1. 32bit SecPeiCpuExceptionHandlerLib and PeiCpuExceptionHandlerLib
2. 64bit PeiCpuExceptionHandlerLib

But considering the code logic simplification, 3.5K extra space is
not a big deal.
If 3.5K is too much, we can enhance the code further to generate 32
vectors for above mentioned library instances.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Acked-by: Eric Dong <eric.dong@intel.com>
22 months agoOvmfPkg/Sec: fix stack switch
Gerd Hoffmann [Wed, 8 Jun 2022 10:09:36 +0000 (18:09 +0800)]
OvmfPkg/Sec: fix stack switch

The ebp/rbp register can either be used for the frame pointer or
as general purpose register.  With gcc (and clang) this depends
on the -f(no-)omit-frame-pointer switch.

This patch updates tools_def.template to explicitly set the compiler
option and also add a define to allow conditionally compile code.

The new define is used to fix stack switching in TemporaryRamMigration.
The ebp/rbp must not be touched when the compiler can use it as general
purpose register.  With version 12 gcc starts actually using the
register, so changing it leads to firmware crashes in some
configurations.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3934
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: Delete SecMeasurementLibTdx
Min M Xu [Sun, 5 Jun 2022 01:02:48 +0000 (09:02 +0800)]
OvmfPkg: Delete SecMeasurementLibTdx

The feature of SecMeasurementLibTdx is replaced by SecTpmMeasurementLibTdx
(which is in SecurityPkg). So SecMeasurementLibTdx is deleted.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: Implement MeasureHobList/MeasureFvImage
Min M Xu [Sun, 5 Jun 2022 01:02:47 +0000 (09:02 +0800)]
OvmfPkg: Implement MeasureHobList/MeasureFvImage

MeasureHobList and MeasureFvImage once were implemented in
SecMeasurementTdxLib. The intention of this patch-set is to refactor
SecMeasurementTdxLib to be an instance of TpmMeasurementLib. So these
2 functions (MeasureHobList/MeasureFvImage) are moved to
PeilessStartupLib. This is because:
1. RTMR based trusted boot is implemented in Config-B (See below link)
2. PeilessStartupLib is designed for PEI-less boot and it is the right
   place to do the measurement for Hoblist and Config-FV.

Config-B: https://edk2.groups.io/g/devel/message/76367

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoSecurity: Add SecTpmMeasurementLibTdx
Min M Xu [Sun, 5 Jun 2022 01:02:46 +0000 (09:02 +0800)]
Security: Add SecTpmMeasurementLibTdx

SecTpmMeasurementLitTdx is an instance of TpmMeasurementLib. It is
designed to used in a Td guest. This lib measures and logs data, and
extendx the measurement result into a specific RTMR.

SecTpmMeasurementLibTdx is a refactored lib of
OvmfPkg/Library/SecMeasurementLibTdx and it just copies
GetMappedRtmrIndex/TdxMeasureAndLogData from that lib. At the end of
this patch-set SecMeasurementLibTdx will be deleted.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
22 months ago.pytool: UncrustifyCheck: Set IgnoreFiles path relative to package path
Kun Qin [Mon, 6 Jun 2022 19:24:54 +0000 (12:24 -0700)]
.pytool: UncrustifyCheck: Set IgnoreFiles path relative to package path

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

`IgnoreFiles` tag is specified in the CI YAML files in each individual
packages. The current logic for UncrustifyCheck script bases specified
file paths from workspace, which requires the package name to be included
in each entry.

This change updates the ignore checking logic to be based on current
package path in order to reduce redundancy. It also keeps the consistency
of `IgnoreFiles` field other pytools such as SpellCheck and EccCheck.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
22 months agoBaseTools: Fix dependency issue in PcdValueInit
Jake Garver [Thu, 7 Apr 2022 16:59:03 +0000 (00:59 +0800)]
BaseTools: Fix dependency issue in PcdValueInit

The generated Makefile was missing a dependency.  This resulted in a
build-time race condition if the recursive make is multi-threaded and
shares job control.

Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
22 months agoOvmfPkg/IntelTdx: Enable RTMR based measurement and measure boot
Min Xu [Mon, 16 May 2022 07:42:23 +0000 (15:42 +0800)]
OvmfPkg/IntelTdx: Enable RTMR based measurement and measure boot

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

Enable RTMR based measurement and measure boot for Td guest.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg/IntelTdx: Add TdTcg2Dxe
Min Xu [Mon, 16 May 2022 07:42:22 +0000 (15:42 +0800)]
OvmfPkg/IntelTdx: Add TdTcg2Dxe

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

TdTcg2Dxe mimics the Security/Tcg/Tcg2Dxe. It does below tasks:
 - Set up and install CC_EVENTLOG ACPI table
 - Parse the GUIDed HOB (gCcEventEntryHobGuid) and create CC event log
 - Measure handoff tables, Boot##### variables etc
 - Measure Exit Boot Service failed
 - Install CcMeasurement Protocol

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoMdePkg: Define CC Measure EventLog ACPI Table
Min Xu [Mon, 16 May 2022 07:42:21 +0000 (15:42 +0800)]
MdePkg: Define CC Measure EventLog ACPI Table

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

TDVF set up an ACPI table (EFI_CC_EVENTLOG_ACPI_TABLE) to pass the
event-log information. The event log created by the TD owner contains
the hashes to reconstruct the MRTD and RTMR registers.

Please refer to Sec 4.3.3 in blow link:
https://www.intel.com/content/dam/develop/external/us/en/documents/
intel-tdx-guest-hypervisor-communication-interface-1.0-344426-002.pdf

Please be noted, the definition of EFI_CC_EVENTLOG_ACPI_TABLE is a
little different from the above document. This difference is based on
below discussion:
- https://edk2.groups.io/g/devel/message/87396
- https://edk2.groups.io/g/devel/message/87402

This change will be reflected in the next version of the above document.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg: Add PCDs for LAML/LASA field in CC EVENTLOG ACPI table
Min Xu [Mon, 16 May 2022 07:42:20 +0000 (15:42 +0800)]
OvmfPkg: Add PCDs for LAML/LASA field in CC EVENTLOG ACPI table

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

Add PCDs to records LAML/LASA field in CC EVENTLOG ACPI table.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg/IntelTdx: Measure Td HobList and Configuration FV
Min Xu [Mon, 16 May 2022 07:42:19 +0000 (15:42 +0800)]
OvmfPkg/IntelTdx: Measure Td HobList and Configuration FV

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

TdHobList and Configuration FV are external data provided by Host VMM.
These are not trusted in Td guest. So they should be validated , measured
and extended to Td RTMR registers. In the meantime 2 EFI_CC_EVENT_HOB are
created. These 2 GUIDed HOBs carry the hash value of TdHobList and
Configuration FV. In DXE phase EFI_CC_EVENT can be created based on these
2 GUIDed HOBs.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg: Introduce SecMeasurementLib
Min Xu [Mon, 16 May 2022 07:42:18 +0000 (15:42 +0800)]
OvmfPkg: Introduce SecMeasurementLib

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

SecMeasurementLib is designed to do the measurement in SEC phase. In
current stage there are 2 functions introduced:
 - MeasureHobList: Measure the Hoblist passed from the VMM.
 - MeasureFvImage: Measure the FV image.

SecMeasurementLibTdx is the TDX version of the library.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ken Lu <ken.lu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoSecurityPkg: Add definition of EFI_CC_EVENT_HOB_GUID
Min Xu [Mon, 16 May 2022 07:42:17 +0000 (15:42 +0800)]
SecurityPkg: Add definition of EFI_CC_EVENT_HOB_GUID

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

EFI_CC_EVENT_HOB_GUID is the global ID of a GUIDed HOB used to pass
TDX_DIGEST_VALUE from SEC to a DXE Driver ( This DXE driver will
be introduced in the following commit in this patch-sets ). In that
DXE driver this GUIDed HOB will be parsed and the TDX_DIGEST_VALUE
then will be extracted. After that a EFI_CC_EVENT will be created
based on it.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoCryptoPkg: Add SecCryptLib
Min Xu [Mon, 16 May 2022 07:42:16 +0000 (15:42 +0800)]
CryptoPkg: Add SecCryptLib

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

This is the Cryptographic library instance for SEC. The motivation of
this library is to support SHA384 in SEC phase for Td guest. So only
Hash/CryptSha512.c is included which supports SHA384 and SHA512. Other
cryptographics are added with the null version, such as CryptMd5Null.c.

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: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoSecurity: Add HashLibTdx
Min Xu [Mon, 16 May 2022 07:42:15 +0000 (15:42 +0800)]
Security: Add HashLibTdx

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

This library provides hash service by registered hash handler in Td
guest. Currently only SHA384 is supported. After that the hash value is
extended to Td RTMR registers which is similar to TPM PCRs.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
22 months agoOvmfPkg: Don't access A20 gate register on Cloud Hypervisor
Sebastien Boeuf [Tue, 10 May 2022 12:50:46 +0000 (20:50 +0800)]
OvmfPkg: Don't access A20 gate register on Cloud Hypervisor

Since Cloud Hypervisor doesn't emulate an A20 gate register on I/O port
0x92, it's better to avoid accessing it when the platform is identified
as Cloud Hypervisor.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: CloudHv: Rely on QemuFwCfgLibNull implementation
Sebastien Boeuf [Tue, 10 May 2022 12:50:45 +0000 (20:50 +0800)]
OvmfPkg: CloudHv: Rely on QemuFwCfgLibNull implementation

Since Cloud Hypervisor doesn't support the fw_cfg mechanism, it's more
appropriate to rely on QemuFwCfgLibNull implementation of QemuFwCfgLib
since it provides a null implementation that will not issue any PIO
accesses to ports 0x510 and 0x511.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: Check for QemuFwCfg availability before accessing it
Sebastien Boeuf [Tue, 10 May 2022 12:50:44 +0000 (20:50 +0800)]
OvmfPkg: Check for QemuFwCfg availability before accessing it

There are few places in the codebase assuming QemuFwCfg will be present
and supported, which can cause some issues when trying to rely on the
QemuFwCfgLibNull implementation of QemuFwCfgLib.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
22 months agoOvmfPkg: CloudHv: Fix FW_BASE_ADDRESS
Sebastien Boeuf [Tue, 10 May 2022 12:50:43 +0000 (20:50 +0800)]
OvmfPkg: CloudHv: Fix FW_BASE_ADDRESS

The FW_BASE_ADDRESS value provided by OvmfPkgDefines.fdf.inc is
incorrect for the CloudHv target. We know the generated firmware
contains a PVH ELF header, meaning it will be loaded according to the
address provided through this header. And since we know this address
isn't going to change as it's part of CloudHvElfHeader.fdf.inc, we can
hardcode it through a new include file CloudHvDefines.fdf.inc, which
replaces the generic one OvmfPkgDefines.fdf.inc.

With this change, we prevent the firmware from accessing MMIO addresses
from the address range 0xffc00000-0xffffffff since we know the firmware
hasn't been loaded on this address range.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
22 months agoOvmfPkg/Microvm/pcie: add pcie support
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:16 +0000 (10:42 +0200)]
OvmfPkg/Microvm/pcie: add pcie support

Link in pcie and host bridge bits.  Enables support for PCIe in microvm
(qemu-system-x86_64 -M microvm,pcie=on).

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3777
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Microvm/pcie: mPhysMemAddressWidth tweak
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:15 +0000 (10:42 +0200)]
OvmfPkg/Microvm/pcie: mPhysMemAddressWidth tweak

microvm places the 64bit mmio space at the end of the physical address
space.  So mPhysMemAddressWidth must be correct, otherwise the pci host
bridge setup throws an error because it thinks the 64bit mmio window is
not addressable.

On microvm we can simply use standard cpuid to figure the address width
because the host-phys-bits option (-cpu ${name},host-phys-bits=on) is
forced to be enabled.  Side note: For 'pc' and 'q35' this is not the
case for backward compatibility reasons.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Microvm/pcie: no vbeshim please
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:14 +0000 (10:42 +0200)]
OvmfPkg/Microvm/pcie: no vbeshim please

Those old windows versions which need the vbeshim hack
will not run on microvm anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Platform: unfix PcdPciExpressBaseAddress
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:13 +0000 (10:42 +0200)]
OvmfPkg/Platform: unfix PcdPciExpressBaseAddress

Will be set by FdtPciHostBridgeLib, so it can't be an fixed when we
want use that library.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/FdtPciHostBridgeLib: io range is not mandatory
Gerd Hoffmann [Thu, 2 Jun 2022 08:42:12 +0000 (10:42 +0200)]
OvmfPkg/FdtPciHostBridgeLib: io range is not mandatory

io range is not mandatory according to pcie spec,
so allow host bridges without io address space.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/Microvm: drop CODE and VARS files
Gerd Hoffmann [Thu, 2 Jun 2022 09:35:23 +0000 (11:35 +0200)]
OvmfPkg/Microvm: drop CODE and VARS files

microvm doesn't support pflash and loads the firmware via -bios,
so we can't use the separate CODE and VARS files.  Remove them.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
22 months agoOvmfPkg/AmdSev: remove unused SMM bits from .dsc and .fdf files
Gerd Hoffmann [Thu, 2 Jun 2022 09:11:05 +0000 (11:11 +0200)]
OvmfPkg/AmdSev: remove unused SMM bits from .dsc and .fdf files

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Dov Murik <dovmurik@linux.ibm.com>
22 months agoOvmfPkg: Search EFI_RESOURCE_MEMORY_UNACCEPTED for Fw hoblist
Min Xu [Tue, 31 May 2022 14:31:17 +0000 (22:31 +0800)]
OvmfPkg: Search EFI_RESOURCE_MEMORY_UNACCEPTED for Fw hoblist

In current TDVF implementation all unaccepted memory passed in Hoblist
are tagged as EFI_RESOURCE_MEMORY_UNACCEPTED. They're all accepted before
they can be accessed. After accepting memory region, the Hob ResourceType
is unchanged (still be EFI_RESOURCE_MEMORY_UNACCEPTED).

TDVF Config-B skip PEI phase and it tries to find a memory region which
is the largest one below 4GB. Then this memory region will be used as the
firmware hoblist.

So we should walk thru the input hoblist and search for the memory region
with the type of EFI_RESOURCE_MEMORY_UNACCEPTED.

Because EFI_RESOURCE_MEMORY_UNACCEPTED has not been officially in PI spec.
So it cannot be defined in MdePkg/Include/Pi/PiHob.h. As a temporary
solution it is defined in Hob.c.

There is a patch-set for lazy-accept very soon. In that patch-set
EFI_RESOURCE_MEMORY_UNACCEPTED will be defined in MdeModulePkg.

Config-B: https://edk2.groups.io/g/devel/message/76367

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg: Fix TDVMCALL error in ApRunLoop.nasm
Min Xu [Tue, 31 May 2022 14:31:16 +0000 (22:31 +0800)]
OvmfPkg: Fix TDVMCALL error in ApRunLoop.nasm

According to GHCI Spec Table 2-1, in TDVMCALL R10 should be cleared
to 0 in input operands, and be checked for the return result.
https://cdrdv2.intel.com/v1/dl/getContent/726790

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
22 months agoOvmfPkg/ResetVector: Removing SEV-ES CPUID bit check
Peter Gonda [Wed, 1 Jun 2022 12:17:45 +0000 (14:17 +0200)]
OvmfPkg/ResetVector: Removing SEV-ES CPUID bit check

The SEV-ES bit of Fn800-001F[EAX] - Bit 3 is used for a host to
determine support for running SEV-ES guests. It should not be checked by
a guest to determine if it is running under SEV-ES. The guest should use
the SEV_STATUS MSR Bit 1 to determine if SEV-ES is enabled. This check
was not part of the original SEV-ES support and was added in
a91b700e38. Removing the check makes this code consistent with the
Linux kernel

Fixes: a91b700e38 ("Ovmf/ResetVector: Simplify and consolidate the SEV features checks")
Signed-off-by: Peter Gonda <pgonda@google.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
22 months agoIntelFsp2WrapperPkg: FSP_TEMP_RAM_INIT call for X64 Calling Convention
Duggapu, Chinni B [Tue, 17 May 2022 08:44:01 +0000 (16:44 +0800)]
IntelFsp2WrapperPkg: FSP_TEMP_RAM_INIT call for X64 Calling Convention

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3926
Pass Input parameters using RCX.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Signed-off-by: cbduggap <chinni.b.duggapu@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Ted Kuo <ted.kuo@intel.com>
22 months agoIntelFsp2Pkg: FSP_TEMP_RAM_INIT call must follow X64 Calling Convention
Duggapu, Chinni B [Tue, 17 May 2022 08:44:00 +0000 (16:44 +0800)]
IntelFsp2Pkg: FSP_TEMP_RAM_INIT call must follow X64 Calling Convention

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3926
This API accept one parameter using RCX and this is consumed
in mutiple sub functions.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Signed-off-by: cbduggap <chinni.b.duggapu@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
22 months agoIntelFsp2Pkg: Add FSP 2.3 header support
Loo, Tung Lun [Wed, 11 May 2022 23:26:29 +0000 (07:26 +0800)]
IntelFsp2Pkg: Add FSP 2.3 header support

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

This patch adds a couple of fields supported in FSP 2.3 header from
both header generation and tool support perspective.

Signed-off-by: Loo Tung Lun <tung.lun.loo@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
22 months agoOvmfPkg/VirtioGpuDxe: replace struct copy with CopyMem call
Gerd Hoffmann [Mon, 30 May 2022 09:22:55 +0000 (11:22 +0200)]
OvmfPkg/VirtioGpuDxe: replace struct copy with CopyMem call

Buildfix for `-t CLANG38 -b NOOPT -p OvmfPkg/OvmfPkgX64.dsc`.

Fixes: 5f6ecaa398ba ("OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode")
Reported-by: Rebecca Cran <quic_rcran@quicinc.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
23 months agoUefiPayloadPkg: Align SpecRevision value with UPL spec
Gua Guo [Thu, 26 May 2022 09:37:44 +0000 (17:37 +0800)]
UefiPayloadPkg: Align SpecRevision value with UPL spec

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3933
URL: https://universalpayload.github.io/documentation/

1. Currently, SpecRevision on USF spec is 0.7. Change to align it.
2. SpecRevision is not be patched into UniversalPayloadInfo.bin due to
different structure item name. Change item name from "HeaderRevision"
 to "SpecRevision" to check the correct value can be patched.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
23 months agoUefiPayloadPkg: Align Identifier value with UPL spec
Gua Guo [Thu, 26 May 2022 01:05:39 +0000 (09:05 +0800)]
UefiPayloadPkg: Align Identifier value with UPL spec

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

URL: https://universalpayload.github.io/documentation/
Currently, Identifier value is "UPLD", it needs to have correct value
"PLDH" based on Universal Payload Specification spec section 2.12.2

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
23 months agoMdeModulePkg/UniversalPayload: Align Identifier value with UPL spec
Gua Guo [Thu, 26 May 2022 00:59:39 +0000 (08:59 +0800)]
MdeModulePkg/UniversalPayload: Align Identifier value with UPL spec

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

URL: https://universalpayload.github.io/documentation/
Currently, Identifier value is "UPLD", it needs to have correct value
"PLDH" based on Universal Payload Specification spec section 2.12.2

Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
23 months agoRemoved prefix to match AsmRelocateApMailBoxLoopStart edk2-stable202205
Theo Jehl [Thu, 26 May 2022 09:40:51 +0000 (17:40 +0800)]
Removed prefix to match AsmRelocateApMailBoxLoopStart

This fixes a compilation issue.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Jehl Theo <theojehl76@gmail.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Rebecca Cran <quic_rcran@quicinc.com>
Tested-by: Rebecca Cran <quic_rcran@quicinc.com>
23 months agoOvmfPkg: fix PcdFSBClock
Gerd Hoffmann [Mon, 23 May 2022 13:45:04 +0000 (21:45 +0800)]
OvmfPkg: fix PcdFSBClock

kvm FSB clock is 1GHz, not 100 MHz.  Timings are off by factor 10.
Fix all affected build configurations.  Not changed: Microvm and
Cloudhw (they have already have the correct value), and Xen (has
no fixed frequency, the PCD is configured at runtime by platform
initialization code).

Fixes: c37cbc030d96 ("OvmfPkg: Switch timer in build time for OvmfPkg")
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months agoOvmfPkg: TdxDxe: Fix AsmRelocateApMailBoxLoop
Isaku Yamahata [Tue, 24 May 2022 07:53:46 +0000 (15:53 +0800)]
OvmfPkg: TdxDxe: Fix AsmRelocateApMailBoxLoop

In TDX, Application Processor busy-loops on Mailbox for OS to issue
MpProtectedModeWakeupCommandWakeup command to UEFI.  As the AP acking to
it, it clears the command member according to ACPI spec 6.4, 5.2.12.19
Multiprocessor Wakeup Structure: "The application processor need clear the
command to Noop(0) as the acknowledgement that the command is received."
However, AsmRelocateApMailBoxLoop wrongly clears WakeupVector.  Correctly
clear command instead of WakeupVector.

Without this patch, TD guest kernel fails to boot APs.

Fixes: fae5c1464d ("OvmfPkg: Add TdxDxe driver")
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
23 months agoOvmfPkg: Make an Ia32/X64 hybrid build work with SEV
Tom Lendacky [Mon, 16 May 2022 20:24:02 +0000 (15:24 -0500)]
OvmfPkg: Make an Ia32/X64 hybrid build work with SEV

The BaseMemEncryptSevLib functionality was updated to rely on the use of
the OVMF/SEV workarea to check for SEV guests. However, this area is only
updated when running the X64 OVMF build, not the hybrid Ia32/X64 build.
Base SEV support is allowed under the Ia32/X64 build, but it now fails
to boot as a result of the change.

Update the ResetVector code to check for SEV features when built for
32-bit mode, not just 64-bit mode (requiring updates to both the Ia32
and Ia32X64 fdf files).

Fixes: f1d1c337e7c0575da7fd248b2dd9cffc755940df
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Michael Roth <michael.roth@amd.com>
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoOvmfPkg/OvmfPkgX64: Use different CcProbeLib when SMM is on or off
Min Xu [Wed, 18 May 2022 03:37:16 +0000 (11:37 +0800)]
OvmfPkg/OvmfPkgX64: Use different CcProbeLib when SMM is on or off

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

CcProbeLib is designed to check the vm guest type. The OvmfPkg/CcProbeLib
reads the OvmfWorkArea (0x80B000) to get the vm guest type which is
written by each guest (SEV or TDX guest). But in SMM drivers the access
to OvmfWorkArea is illegal. PiSmmCpuDxeSmm.inf is an example. It uses
IoLib which in OvmfPkgX64 BaseIoLibIntrinsicSev.inf is included. The
IoLib probes if the working guest is td guest by calling CcProbe().

So CcProbeLibNull will be included when SMM_REQUIRE is set. Currently
only TDVF uses CcProbe to check the guest type, and TDVF doesn't
support SMM, so this fix has no side-effect.

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Dann Frazier <dann.frazier@canonical.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Tested-by: dann frazier <dann.frazier@canonical.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
23 months agoUefiPayloadPkg: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:08:31 +0000 (16:08 -0400)]
UefiPayloadPkg: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Guo Dong <guo.dong@intel.com>
23 months agoOvmfPkg: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:05:38 +0000 (16:05 -0400)]
OvmfPkg: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
23 months agoEmulatorPkg: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:49:10 +0000 (16:49 -0400)]
EmulatorPkg: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Abner Chang <abner.chang@hpe.com>
23 months agoArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib
Michael Kubacki [Fri, 8 Apr 2022 20:02:13 +0000 (16:02 -0400)]
ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
Michael Kubacki [Wed, 6 Apr 2022 01:40:17 +0000 (21:40 -0400)]
MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info

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

Adds support to the UEFI variable fault tolerant write (FTW) drivers
to receive FTW base and size information dynamically via the Variable
Flash Information library.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg/Variable: Consume Variable Flash Info
Michael Kubacki [Wed, 6 Apr 2022 01:34:51 +0000 (21:34 -0400)]
MdeModulePkg/Variable: Consume Variable Flash Info

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

Updates VariableRuntimeDxe, VariableSmm, and VariableStandaloneMm
to acquire variable flash information from the Variable Flash
Information library.

Note: This introduces a dependency on VariableFlashInfoLib in these
modules. Therefore, a platform building the variable modules must
specify an instance of VariableFlashInfoLib in their platform build.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg/VariableFlashInfoLib: Add initial library
Michael Kubacki [Fri, 8 Apr 2022 15:53:29 +0000 (11:53 -0400)]
MdeModulePkg/VariableFlashInfoLib: Add initial library

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

Adds a new library class VariableFlashInfoLib that abstracts access
to variable flash information. The instance provided first attempts
to retrieve information from the Variable Flash Info HOB. If that
HOB is not present, it falls back to the PCDs defined in
MdeModulePkg.

This fall back behavior provides backward compatibility for platforms
that only provide PCDs but also allows platforms that need to
dynamically provide the information using the Variable Flash Info HOB
to do so at runtime.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months agoMdeModulePkg: Add Variable Flash Info HOB
Michael Kubacki [Wed, 6 Apr 2022 01:17:59 +0000 (21:17 -0400)]
MdeModulePkg: Add Variable Flash Info HOB

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

Adds a new GUID that is used to identify a HOB that passes variable
flash information to UEFI variable drivers in HOB consumption phases
such as DXE, Traditional MM, and Standalone MM.

This information was previously passed directly with PCDs such
as EfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
and gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize.

However, the Standalone MM variable driver instance does not have
direct access to the PCD database. Therefore, this HOB will first
be considered as the source for variable flash information and
if platforms do not produce the HOB, reading the information from
the PCDs directly will be a backup to provide backward
compatibility.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
23 months ago.pytool/plugin/SpellCheck: Add more common words
Michael Kubacki [Tue, 17 May 2022 22:57:43 +0000 (18:57 -0400)]
.pytool/plugin/SpellCheck: Add more common words

Appends the word list to reduce the number of errors encountered
by individual packages.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months ago.pytool/plugin/SpellCheck: Allow compound words
Michael Kubacki [Tue, 17 May 2022 22:16:39 +0000 (18:16 -0400)]
.pytool/plugin/SpellCheck: Allow compound words

Sets "allowCompoundWords" to "true" to reduce the number of compound
word issues encountered in the future.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months ago.azurepipelines: Fix cspell version to v5.20.0
Michael Kubacki [Tue, 17 May 2022 21:54:36 +0000 (17:54 -0400)]
.azurepipelines: Fix cspell version to v5.20.0

The v5.21.0 update introduced a number of new issues that might
impact stable tag integration so this fixes the version to the
previous release.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This value can be revisited in the future to update the

23 months agoBaseTools: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:20 +0000 (02:48 +0800)]
BaseTools: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoOvmfPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:19 +0000 (02:48 +0800)]
OvmfPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoEmbeddedPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:18 +0000 (02:48 +0800)]
EmbeddedPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoArmVirtPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:17 +0000 (02:48 +0800)]
ArmVirtPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoNetworkPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:16 +0000 (02:48 +0800)]
NetworkPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoFatPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:15 +0000 (02:48 +0800)]
FatPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoMdePkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:14 +0000 (02:48 +0800)]
MdePkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoCryptoPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:13 +0000 (02:48 +0800)]
CryptoPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoArmPlatformPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:12 +0000 (02:48 +0800)]
ArmPlatformPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoArmPkg: Remove RVCT support
Rebecca Cran [Tue, 3 May 2022 18:48:11 +0000 (02:48 +0800)]
ArmPkg: Remove RVCT support

RVCT is obsolete and no longer used.
Remove support for it.

Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
23 months agoUefiPayloadPkg: Connect all root bridge in PlatformBootManagerBeforeConsole
Liu, Zhiguang [Thu, 12 May 2022 10:54:59 +0000 (18:54 +0800)]
UefiPayloadPkg: Connect all root bridge in PlatformBootManagerBeforeConsole

Some ConIn or ConOut device may not in the first root bridge, so connect all
root bridge  before detect ConIn and ConOut device.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
23 months agoUefiPayloadPkg: Add Serial IO device path according to related protocol
Liu, Zhiguang [Thu, 12 May 2022 10:54:58 +0000 (18:54 +0800)]
UefiPayloadPkg: Add Serial IO device path according to related protocol

Current code follow some rules to check if the PCI device connected to a
serial port device, but some platform or hardware doesn't follow such rule.
By locating gEfiSerialIoProtocolGuid protocol, we can find the related
device path.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
23 months agoUefiPayloadPkg: Simplify code logic
Liu, Zhiguang [Thu, 12 May 2022 10:54:57 +0000 (18:54 +0800)]
UefiPayloadPkg: Simplify code logic

A little overdesign about VisitAllPciInstances function, since there are
two call back functions. Simplify the code logic by combining the two call
back functions, and unused parameters.
Change the PROTOCOL_INSTANCE_CALLBACK to SIMPLE_PROTOCOL_INSTANCE_CALLBACK
because the former is also defined in OvmfPkg. Rename it to avoid confusion.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
23 months agoMdeModulePkg: PiSmmCore: Inspect memory guarded with pool headers
Kun Qin [Tue, 26 Apr 2022 00:47:46 +0000 (08:47 +0800)]
MdeModulePkg: PiSmmCore: Inspect memory guarded with pool headers

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

Current free pool routine from PiSmmCore will inspect memory guard status
for target buffer without considering pool headers. This could lead to
`IsMemoryGuarded` function to return incorrect results.

In that sense, allocating a 0 sized pool could cause an allocated buffer
directly points into a guard page, which is legal. However, trying to
free this pool will cause the routine changed in this commit to read XP
pages, which leads to page fault.

This change will inspect memory guarded with pool headers. This can avoid
errors when a pool content happens to be on a page boundary.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months agoOvmfPkg: Enable 2 different CpuMpPei and CpuDxe drivers
Min M Xu [Sat, 7 May 2022 01:36:23 +0000 (09:36 +0800)]
OvmfPkg: Enable 2 different CpuMpPei and CpuDxe drivers

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

In OvmfPkgX64 we enable 2 different CpuMpPei and CpuDxe drivers. The
difference between the drivers is the MpInitLib or MpInitLibUp. This is
acomplished by adding a MpInitLibDepLib.

In IntelTdxX64 we enable 2 versions of CpuDxe drivers. It is because PEI
is skipped in IntelTdxX64.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
23 months agoOvmfPkg/TdxDxe: Install MpInitLibDepLib protocols
Min M Xu [Sat, 7 May 2022 01:36:22 +0000 (09:36 +0800)]
OvmfPkg/TdxDxe: Install MpInitLibDepLib protocols

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

In Td guest CpuDxe driver uses the MpInitLibUp, the other guest type
use the MpInitLib. So we install different Protocols according to
the current working guest type.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
23 months agoOvmfPkg/Sec: Install MpInitLibDepLib PPIs in SecMain.c
Min M Xu [Sat, 7 May 2022 01:36:21 +0000 (09:36 +0800)]
OvmfPkg/Sec: Install MpInitLibDepLib PPIs in SecMain.c

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

Td guest should use MpInitLibUp, other guest use the MpInitLib. So
in SecMain.c different PPI is installed according to the working
guest type.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
23 months agoOvmfPkg: Add MpInitLibDepLib
Min M Xu [Sat, 7 May 2022 01:36:20 +0000 (09:36 +0800)]
OvmfPkg: Add MpInitLibDepLib

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

There are 4 MpInitLibDepLib:
 - PeiMpInitLibMpDepLib:
   MpInitLib multi-processor dependency
 - PeiMpInitLibUpDepLib:
   MpInitLib unique-processor dependency
 - DxeMpInitLibMpDepLib:
   MpInitLib multi-processor dependency
 - DxeMpInitLibUpDepLib
   MpInitLib unique-processor dependency

The Pei libs depend on the corresponding PPI. The Dxe libs depend on the
corresponding Protocol.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
23 months agoOvmfPkg: Add MpInitLibDepLib related PPI/Protocol definitions
Min M Xu [Sat, 7 May 2022 01:36:19 +0000 (09:36 +0800)]
OvmfPkg: Add MpInitLibDepLib related PPI/Protocol definitions

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

MpInitLibDepLib is a set of libraries which depend on PPI/Protocol.
This patch defines the related PPI/Protocols in OvmfPkg.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
23 months agoUefiCpuPkg: Revert "UefiCpuPkg: Enable Tdx support in MpInitLib"
Min M Xu [Sat, 7 May 2022 01:36:18 +0000 (09:36 +0800)]
UefiCpuPkg: Revert "UefiCpuPkg: Enable Tdx support in MpInitLib"

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

This reverts commit 88da06ca763eb6514565c1867a801a427c1f3447.
This commit triggers the ASSERT in Non-Td guest.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
23 months agoCryptoPkg/openssl: disable codestyle checks for generated files
Yi Li [Tue, 10 May 2022 07:19:07 +0000 (15:19 +0800)]
CryptoPkg/openssl: disable codestyle checks for generated files

Files generated by process_files.pl from openssl sources should not be checked for edk2 code style.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Yi Li <yi1.li@intel.com>
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>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months agoCryptoPkg/openssl: update generated files
Yi Li [Tue, 10 May 2022 07:19:06 +0000 (15:19 +0800)]
CryptoPkg/openssl: update generated files

Run process_files.pl with the current openssl submodule version.

Signed-off-by: Yi Li <yi1.li@intel.com>
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: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months agoCryptoPkg: Update process_files.pl to automatically add PCD config option
Yi Li [Tue, 10 May 2022 07:19:05 +0000 (15:19 +0800)]
CryptoPkg: Update process_files.pl to automatically add PCD config option

Recommend from Gerd:
(2) Keep the EC config option, but update process_files.pl to
  automatically add the PcdEcEnabled config option handling
  to the files it generates.

When remove 'no-ec' from openssl configure list, will automatically remove
'OPENSSL_NO_EC', 'OPENSSL_NO_ECDH', 'OPENSSL_NO_ECDSA', 'OPENSSL_NO_TLS1_3',
form header, and add '/ec/.', '/sm2/.' files to INF files.

Signed-off-by: Yi Li <yi1.li@intel.com>
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: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months agoCryptoPkg: Separate auto-generated openssl config and edk2 openssl config
Yi Li [Tue, 10 May 2022 07:19:04 +0000 (15:19 +0800)]
CryptoPkg: Separate auto-generated openssl config and edk2 openssl config

Move auto-generated openssl config to openssl/opensslconf_generated,
 And openssl/opensslconf.h will contain both edk2 conditional openssl
 feature and openssl/opensslconf_generated.
Will make two part more clear.
New conditional feture code in opensslconf.h will look like:

/* Autogenerated conditional openssl feature list starts here */
[.....]
/* Autogenerated conditional openssl feature list ends here */

Signed-off-by: Yi Li <yi1.li@intel.com>
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: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months agoCryptoPkg: Rename PCD about openssl EC configuration
Yi Li [Tue, 10 May 2022 07:19:03 +0000 (15:19 +0800)]
CryptoPkg: Rename PCD about openssl EC configuration

PcdOpensslXXXEnabled is a more appropriate choice.

Signed-off-by: Yi Li <yi1.li@intel.com>
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>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months ago.pytool: Fix python command error in self introduction doc
Chao Li [Fri, 22 Apr 2022 07:44:27 +0000 (15:44 +0800)]
.pytool: Fix python command error in self introduction doc

Fix misspelling of word "Prerequisites".

In the step 5 of the Prerequisites section, the python command was missing
the "-r" option, what the command really meant was to install from the given
requirements file, so fix that.

Cc: sean.brogan@microsoft.com
Cc: Bret.Barkelew@microsoft.com
Cc: michael.d.kinney@intel.com
Cc: gaoliming@byosoft.com.cn
Signed-off-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months agoMdeModulePkg/PCD: Pcd initialize DXE have assert
Gua Guo [Thu, 5 May 2022 21:29:51 +0000 (05:29 +0800)]
MdeModulePkg/PCD: Pcd initialize DXE have assert

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

When PlatformPkg.dsc has multiple SKU IDs but didn't exist delta PCD,
System will hang on BuildPcdDxeDataBase.

Ideally, if didn't exist delta PCD by different SKU ID,
UpdatePcdDatabase () shouldn't return EFI_NOT_FOUND.

Signed-off-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months agoPcAtChipsetPkg: Change the flow of PcRtcInit()
Chao, Zhuoran [Sat, 7 May 2022 09:39:37 +0000 (17:39 +0800)]
PcAtChipsetPkg: Change the flow of PcRtcInit()

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

The original flow of PcRtcInit() is like:
1. Guarantee atomic accesses to the RTC time registers and
   read out the value.
2. Program RTC register B. (adopt 12h mode or 24h mode. Current
   bios code sets RTC to 24h mode by default).
3. Then function ConvertRtcTimeToEfiTime converts the RTC time
   value to their 24h mode by checking the hour format bit
   (1:24h mode,0:12h mode).
And here lies the problem: Step3 will fail to adjust the value
if Step2 already sets RTC to 24h mode. The hour value in 12h mode
will not be converted to its 24h mode.
The solution is to program RTC register B a little later when all
the original RTC registers' value is retrieved, adjusted
and validated.

ConvertRtcTimeToEfiTime is modified to be more robust.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhuoran Chao <zhuoran.chao@intel.com>
23 months agoUefiPayloadPkg: Fix the UPL build failure
Tan, Dun [Sat, 7 May 2022 03:57:32 +0000 (11:57 +0800)]
UefiPayloadPkg: Fix the UPL build failure

Add double quotes to LlvmObjcopyPath.
Blank space in LlvmObjcopyPath will cause build failure.
This build failure is introduced by 2306555bf908 (
"UefiPayloadPkg: Fix IA32 entry build failure").

Signed-off-by: Dun Tan <dun.tan@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
23 months agoMdePkg: add SmmCpuRendezvousLib.h and SmmCpuRendezvousLibNull implement.
Li, Zhihao [Mon, 25 Apr 2022 08:47:27 +0000 (16:47 +0800)]
MdePkg: add SmmCpuRendezvousLib.h and SmmCpuRendezvousLibNull implement.

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

UefiCpuPkg define a new Protocol with the new services
SmmWaitForAllProcessor(), which can be used by SMI handler
to optionally wait for other APs to complete SMM rendezvous in
relaxed AP mode.

VariableSmm and VariableStandaloneMM driver in MdeModulePkg need
to use this services but MdeModulePkg can't depend on UefiCpuPkg.

Thus, the solution is moving SmmCpuRendezvouslib.h from UefiCpuPkg
to MdePkg and creating SmmCpuRendezvousLib NullLib version
implementation in MdePkg as dependency for the pkg that can't
depend on UefiCpuPkg.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Zhihao Li <zhihao.li@intel.com>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
23 months agoOvmfPkg: Add README for TDVF
Min Xu [Wed, 4 May 2022 00:13:50 +0000 (08:13 +0800)]
OvmfPkg: Add README for TDVF

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

Add README for TDVF.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
23 months agoUefiPayloadPkg: Add CpuLib to module INFs that depend on UefiCpuLib.
Yu Pu [Mon, 28 Mar 2022 15:33:22 +0000 (23:33 +0800)]
UefiPayloadPkg: Add CpuLib to module INFs that depend on UefiCpuLib.

There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Yu Pu <yu.pu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
23 months agoUefiCpuPkg: Add CpuLib to module INFs that depend on UefiCpuLib.
Yu Pu [Mon, 28 Mar 2022 15:29:18 +0000 (23:29 +0800)]
UefiCpuPkg: Add CpuLib to module INFs that depend on UefiCpuLib.

There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>