]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
19 months agoRedfishPkg/RedfishDiscoverDxe: Install protocol on each network interface
Abner Chang [Tue, 30 Aug 2022 04:15:47 +0000 (12:15 +0800)]
RedfishPkg/RedfishDiscoverDxe: Install protocol on each network interface

BZ 4037:
Install EFI_DISCOVER_PROTOCOL on each network interface.

This fixes the issue that causes the high-level Redfish driver
on the network interface is stopped when:
1. EFI_DISCOVER_PROTOCOL is reinstalled on a new-found network
   interface, or
2. EFI_DISCOVER_PROTOCOL is stopped on the network interface
   other than the one which is used to communicate with Redfish
   service.

Cc: Nickle Wang <nickle@csie.io>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
Reviewed-by: Nickle Wang <nickle@csie.io>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
19 months agoOvmfPkg: Add build-flag SECURE_BOOT_FEATURE_ENABLED
Min M Xu [Fri, 24 Jun 2022 00:33:58 +0000 (08:33 +0800)]
OvmfPkg: Add build-flag SECURE_BOOT_FEATURE_ENABLED

SECURE_BOOT_FEATURE_ENABLED is the build-flag defined when secure boot
is enabled. Currently this flag is used in below lib:
 - OvmfPkg/PlatformPei
 - PeilessStartupLib

So it is defined in below 5 .dsc
 - OvmfPkg/CloudHv/CloudHvX64.dsc
 - OvmfPkg/IntelTdx/IntelTdxX64.dsc
 - OvmfPkg/OvmfPkgIa32.dsc
 - OvmfPkg/OvmfPkgIa32X64.dsc
 - OvmfPkg/OvmfPkgX64.dsc

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg/TdxDxe: Set PcdEmuVariableNvStoreReserved
Min M Xu [Wed, 22 Jun 2022 01:11:03 +0000 (09:11 +0800)]
OvmfPkg/TdxDxe: Set PcdEmuVariableNvStoreReserved

Set PcdEmuVariableNvStoreReserved with the value in PlatformInfoHob. It
is the address of the EmuVariableNvStore reserved in Pei-less startup.

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg/NvVarsFileLib: Shortcut ConnectNvVarsToFileSystem in secure-boot
Min M Xu [Wed, 29 Jun 2022 02:33:09 +0000 (10:33 +0800)]
OvmfPkg/NvVarsFileLib: Shortcut ConnectNvVarsToFileSystem in secure-boot

OvmfPkg/Library/NvVarsFileLib allows loading variables into emulated
varstore from a on-disk NvVars file.  We can't allow that when secure
boot is active.  So check secure-boot feature and shortcut the
ConnectNvVarsToFileSystem() function when sb is enabled.

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>
Suggested-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg: Reserve and init EmuVariableNvStore in Pei-less Startup
Min M Xu [Wed, 22 Jun 2022 01:13:48 +0000 (09:13 +0800)]
OvmfPkg: Reserve and init EmuVariableNvStore in Pei-less Startup

EmuVariableNvStore is reserved and init with below 2 functions defined in
PlatformInitLib:
 - PlatformReserveEmuVariableNvStore
 - PlatformInitEmuVariableNvStore

PlatformInitEmuVariableNvStore works when secure boot feature is enabled.
This is because secure boot needs the EFI variables (PK/KEK/DB/DBX, etc)
and EmuVariableNvStore is cleared when OVMF is launched with -bios
parameter.

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore
Min M Xu [Wed, 22 Jun 2022 01:08:41 +0000 (09:08 +0800)]
OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore

ReserveEmuVariableNvStore is updated with below 2 functions defined in
PlatformInitLib:
 - PlatformReserveEmuVariableNvStore
 - PlatformInitEmuVariableNvStore

PlatformInitEmuVariableNvStore works when secure boot feature is enabled.
This is because secure boot needs the EFI variables (PK/KEK/DB/DBX, etc)
and EmuVariableNvStore is cleared when OVMF is launched with -bios
parameter.

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg/PlatformInitLib: Add functions for EmuVariableNvStore
Min M Xu [Wed, 29 Jun 2022 02:46:22 +0000 (10:46 +0800)]
OvmfPkg/PlatformInitLib: Add functions for EmuVariableNvStore

There are 3 functions added for EmuVariableNvStore:
 - PlatformReserveEmuVariableNvStore
 - PlatformInitEmuVariableNvStore
 - PlatformValidateNvVarStore

PlatformReserveEmuVariableNvStore allocate storage for NV variables early
on so it will be at a consistent address.

PlatformInitEmuVariableNvStore copies the content in
PcdOvmfFlashNvStorageVariableBase to the storage allocated by
PlatformReserveEmuVariableNvStore. This is used in the case that OVMF is
launched with -bios parameter. Because in that situation UEFI variables
will be partially emulated, and non-volatile variables may lose their
contents after a reboot. This makes the secure boot feature not working.

PlatformValidateNvVarStore is renamed from TdxValidateCfv and it is used
to validate the integrity of FlashNvVarStore
(PcdOvmfFlashNvStorageVariableBase). It should be called before
PlatformInitEmuVariableNvStore is called to copy over the content.

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg/PeilessStartupLib: Delete TdxValidateCfv
Min M Xu [Wed, 29 Jun 2022 02:30:02 +0000 (10:30 +0800)]
OvmfPkg/PeilessStartupLib: Delete TdxValidateCfv

TdxValidateCfv is used to validate the integrity of FlashNvVarStore
(PcdOvmfFlashNvStorageVariableBase) and it is not Tdx specific.
So it will be moved to PlatformInitLib and be renamed to
PlatformValidateNvVarStore in the following patch. And it will be called
before EmuVaribleNvStore is initialized with the content in
FlashNvVarStore.

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoEmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib
Min M Xu [Wed, 22 Jun 2022 01:00:23 +0000 (09:00 +0800)]
EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib

AllocateRuntimePages is used to allocate one or more 4KB pages of
type EfiRuntimeServicesData.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Abner Chang <abner.chang@hpe.com>
Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb+tianocore@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
19 months agoOvmfPkg: Set default Pci PCDs in Tdx guest
Min M Xu [Fri, 26 Aug 2022 00:41:09 +0000 (08:41 +0800)]
OvmfPkg: Set default Pci PCDs in Tdx guest

In previous implementation below Pci related PCDs were set based on the
ResourceDescriptor passed in TdHob.
 - PcdPciMmio64Base / PcdPciMmio64Size
 - PcdPciMmio32Base / PcdPciMmio32Size
 - PcdPciIoBase / PcdPciIoSize

The PCDs will not be set if TdHob doesn't include these information. This
patch set the PCDs with the information initialized in PlatformInitLib
by default. Then TdxDxe will check the ResourceDescriptor in TdHob and
reset them if they're included.

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg: Update CcProbeLib to DxeCcProbeLib
Min M Xu [Thu, 7 Jul 2022 02:51:20 +0000 (10:51 +0800)]
OvmfPkg: Update CcProbeLib to DxeCcProbeLib

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

CcProbeLib once was designed to probe the Confidential Computing guest
type by checking the PcdOvmfWorkArea. But this memory is allocated with
either EfiACPIMemoryNVS or EfiBootServicesData. It cannot be accessed
after ExitBootService. Please see the detailed analysis in BZ#3974.

To fix this issue, CcProbeLib is redesigned as 2 implementation:
 - SecPeiCcProbeLib
 - DxeCcProbeLib

In SecPeiCcProbeLib we check the CC guest type by reading the
PcdOvmfWorkArea. Because it is used in SEC / PEI and we don't worry about
the issues in BZ#3974.

In DxeCcProbeLib we cache the GuestType in Ovmf work area in a variable.
After that the Guest type is returned with the cached value. So that we
don't need to worry about the access to Ovmf work area after
ExitBootService.

The reason why we probe CC guest type in 2 different ways is the global
varialbe. Global variable cannot be used in SEC/PEI and CcProbe is called
very frequently.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoOvmfPkg: Add SecPeiCcProbeLib
Min M Xu [Thu, 7 Jul 2022 02:47:31 +0000 (10:47 +0800)]
OvmfPkg: Add SecPeiCcProbeLib

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

SecPeiCcProbeLib is designed to probe the Confidential Computing guest
type in SEC/PEI phase. The CC guest type was set by each CC guest at
the beginning of boot up and saved in PcdOvmfWorkArea.

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>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
19 months agoEmbeddedPkg/GdbSerialDebugPortLib: fix compile warning
Wenyi Xie [Wed, 3 Aug 2022 09:27:22 +0000 (17:27 +0800)]
EmbeddedPkg/GdbSerialDebugPortLib: fix compile warning

The value of gTimeOut is from PcdGdbMaxPacketRetryCount, and this
PCD is UINT32. So change the declaratrion of gTimeOut to UINT32
to fix compile warning.

Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
19 months agoOvmfPkg: increase max debug message length to 512
Laszlo Ersek [Wed, 10 Aug 2022 08:11:40 +0000 (10:11 +0200)]
OvmfPkg: increase max debug message length to 512

Increase the maximum line length for debug messages.
While log messages should be short, they can still
get quite long, for example when printing device paths
or config strings in HII routing.
512 chars is an empirically good value.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
19 months agoOvmfPkg/BhyvePkg: use correct PlatformSecureLib
Corvin Köhne [Fri, 2 Sep 2022 10:32:49 +0000 (12:32 +0200)]
OvmfPkg/BhyvePkg: use correct PlatformSecureLib

There's no bhyve specific PlatformSecureLib any more. Use the default
one of OvmfPkg which works too.

Signed-off-by: Corvin Köhne <c.koehne@beckhoff.com>
Reviewed-by: Ard Biesheuvel <ardb+tianocore@kernel.org>
19 months agoEmbeddedPkg: Remove duplicated words
Pierre Gondois [Tue, 23 Aug 2022 16:00:15 +0000 (18:00 +0200)]
EmbeddedPkg: Remove duplicated words

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

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
19 months agoArmPkg: Remove duplicated words
Pierre Gondois [Tue, 23 Aug 2022 16:00:09 +0000 (18:00 +0200)]
ArmPkg: Remove duplicated words

In an effort to clean the documentation of the above
package, remove duplicated words, and fix a typo while at it.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.muajwar@arm.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
19 months agoArmPlatformPkg: Remove duplicated words
Pierre Gondois [Tue, 23 Aug 2022 16:00:10 +0000 (18:00 +0200)]
ArmPlatformPkg: Remove duplicated words

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

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.muajwar@arm.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
19 months agoArmVirtPkg: Remove duplicated words
Pierre Gondois [Tue, 23 Aug 2022 16:00:11 +0000 (18:00 +0200)]
ArmVirtPkg: Remove duplicated words

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

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.muajwar@arm.com>
19 months agoOvmfPkg: Remove duplicated words
Pierre Gondois [Tue, 23 Aug 2022 16:00:22 +0000 (18:00 +0200)]
OvmfPkg: Remove duplicated words

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

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
19 months agoStandaloneMmPkg: Remove duplicated words
Pierre Gondois [Tue, 23 Aug 2022 16:00:28 +0000 (18:00 +0200)]
StandaloneMmPkg: Remove duplicated words

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

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
19 months agoArmPlatformPkg/PrePeiCore: Invoke constructors for SEC phase
Rohit Mathew [Fri, 22 Jul 2022 17:02:57 +0000 (18:02 +0100)]
ArmPlatformPkg/PrePeiCore: Invoke constructors for SEC phase

On platforms that do not have the serial console port pre-initialized
prior to the SEC phase and due to the absence of a call to
"SerialPortInitialize", this results in missing debug logs. So, call
the auto-generated "ProcessLibraryConstructorList" function from SEC
phase to have all the dependent library constructors called
(this includes a call to "SerialPortInitialize").

Signed-off-by: Rohit Mathew <rohit.mathew@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoArmPkg: Handle warm reboot request correctly
Pranav Madhu [Wed, 24 Aug 2022 16:44:21 +0000 (22:14 +0530)]
ArmPkg: Handle warm reboot request correctly

The warm reboot requests from OSPM are mapped to cold reboot. To handle
the warm reboot separately from a cold reboot, update
ArmSmcPsciResetSystemLib and to invoke the PSCI call with parameters
for warm reboot.

Signed-off-by: Pranav Madhu <pranav.madhu@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
19 months agoOvmfPkg/PlatformDxe: Handle all requests in ExtractConfig and RouteConfig
Dimitrije Pavlov [Thu, 18 Aug 2022 19:58:42 +0000 (14:58 -0500)]
OvmfPkg/PlatformDxe: Handle all requests in ExtractConfig and RouteConfig

Per the UEFI specification, if the Request argument in
EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig() is NULL or does not contain
any request elements, the implementation should return all of the settings
being abstracted for the particular ConfigHdr reference.

The current implementation returns EFI_INVALID_PARAMETER if Request is
NULL or does not contain any request elements. Instead, construct
a new ConfigRequest to handle these cases per the specification.

In addition, per the UEFI specification, if the Configuration argument in
EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig() has a ConfigHdr that
specifies a non-existing target, the implementation should return
EFI_NOT_FOUND.

The current implementation returns EFI_INVALID_PARAMETER if Configuration
has a non-existing target in ConfigHdr. Instead, perform a check and
return EFI_NOT_FOUND in this case.

Signed-off-by: Dimitrije Pavlov <Dimitrije.Pavlov@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
19 months agoOvmfPkg/PlatformDxe: Check RouteConfig arguments for spec compliance
Yuan Yu [Wed, 24 Aug 2022 02:31:23 +0000 (19:31 -0700)]
OvmfPkg/PlatformDxe: Check RouteConfig arguments for spec compliance

Per UEFI Spec 2.9, EFI_HII_CONFIG_ROUTING_PROTOCOL.RouteConfig()
should return EFI_INVALID_PARAMETER if caller passes in a NULL for
the Configuration parameter (see 35.4 EFI HII Configuration Routing
Protocol).

Add a check to return EFI_INVALID_PARAMETER when Configuration is NULL.

Signed-off-by: Yuan Yu <yuanyu@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
19 months agoOvmfPkg: Add BUILD_SHELL flag for IA32, IA32X64, X64
Oliver Steffen [Tue, 30 Aug 2022 16:13:54 +0000 (18:13 +0200)]
OvmfPkg: Add BUILD_SHELL flag for IA32, IA32X64, X64

Add BUILD_SHELL flag, similar to the one in OvmfPkg/AmdSev,
to enable/disable building of the UefiShell as part of
the firmware image. The UefiShell should not be included for
secure production systems (e.g. SecureBoot) because it can be
used to circumvent security features.

The default value for BUILD_SHELL is TRUE to keep the default
behavior of the Ovmf build.
Note: the default for AmdSev is FALSE.

The BUILD_SHELL flag for AmdSev was introduced in b261a30c900a8.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
19 months agoUefiPayloadPkg: To replace the libraries for the capsule driver.
KasimX Liu [Thu, 25 Aug 2022 02:32:46 +0000 (10:32 +0800)]
UefiPayloadPkg: To replace the libraries for the capsule driver.

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

For the system support the Capsule function in UPL,
we replace the libraries for the Capsule driver.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: KasimX Liu <kasimx.liu@intel.com>
19 months agoIntelFsp2WrapperPkg: Rename PlatformMultiPhaseLibSample.
Chasel Chiu [Thu, 1 Sep 2022 05:45:37 +0000 (22:45 -0700)]
IntelFsp2WrapperPkg: Rename PlatformMultiPhaseLibSample.

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

Basing on offline feedbacks to rename
FspWrapperPlatformMultiPhaseLibSample to
FspWrapperPlatformMultiPhaseLibNull.

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>
19 months agoIntelFsp2WrapperPkg: Remove duplicated words
Pierre Gondois [Tue, 23 Aug 2022 16:00:18 +0000 (09:00 -0700)]
IntelFsp2WrapperPkg: Remove duplicated words

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

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
19 months agoDynamicTablesPkg: Fix typo in AmlCodeGenRdMemory32Fixed doxygen comment
Rebecca Cran [Wed, 31 Aug 2022 16:20:29 +0000 (10:20 -0600)]
DynamicTablesPkg: Fix typo in AmlCodeGenRdMemory32Fixed doxygen comment

Fix typo of "Address".

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: Fix nested processor containers
Jeff Brasen [Thu, 18 Aug 2022 16:47:55 +0000 (10:47 -0600)]
DynamicTablesPkg: Fix nested processor containers

Current code will generate duplicate UID if there are nested processor
containers in the topology. For example if there is a
socket/cluster/core layout.

Change references to processor container from cluster to be more
accurate on what is being created.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: AcpiSsdtPcieLibArm : Add UID to slot creation
Jeff Brasen [Wed, 24 Aug 2022 04:35:53 +0000 (22:35 -0600)]
DynamicTablesPkg: AcpiSsdtPcieLibArm : Add UID to slot creation

Expose the UID value to GeneratePciSlots().
This is needed for some cases for example:
https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports#identifying-externally-exposed-pcie-root-ports

Name (_DSD, Package () {
  ToUUID("EFCC06CC-73AC-4BC3-BFF0-76143807C389"),
  Package () {
    Package (2) {"ExternalFacingPort", 1},
    Package (2) {"UID", 0},
  }
})

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: Add support to build _DSD
Jeff Brasen [Wed, 17 Aug 2022 16:39:39 +0000 (10:39 -0600)]
DynamicTablesPkg: Add support to build _DSD

Add APIs needed to build _DSD with different UUIDs.
This is per ACPI specification 6.4 s6.2.5.

Adds support for building data packages with format
Package {"Name", Integer}

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: AcpiSsdtPcieLibArm: Added function to reserve ECAM space
Kun Qin [Wed, 20 Jul 2022 17:39:27 +0000 (10:39 -0700)]
DynamicTablesPkg: AcpiSsdtPcieLibArm: Added function to reserve ECAM space

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

Certain OSes will complain if the ECAM config space is not reserved in
the ACPI namespace.

This change adds a function to reserve PNP motherboard resources for a
given PCI node.

Co-authored-by: Joe Lopez <joelopez@microsoft.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: DynamicTableManagerDxe: Added check for installed tables
Kun Qin [Tue, 5 Jul 2022 19:31:07 +0000 (12:31 -0700)]
DynamicTablesPkg: DynamicTableManagerDxe: Added check for installed tables

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

This change added an extra step to allow check for installed ACPI tables.

For FADT, MADT, GTDT, DSDT, DBG2 and SPCR tables, either pre-installed or
supplied through AcpiTableInfo can be accepted.

An extra check for FADT ACPI table existence during installation step is
also added.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Co-authored-by: Joe Lopez <joelopez@microsoft.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@Arm.com>
Tested-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: DynamicPlatRepoLib: Adding more token fixers
Kun Qin [Fri, 1 Jul 2022 01:00:17 +0000 (18:00 -0700)]
DynamicTablesPkg: DynamicPlatRepoLib: Adding more token fixers

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

This change added more token fixers for other node types, including
NamedComponentNode, RootComplexNode, and SmmuV3Node.

The corresponding entries for tokenFixer functions table is also updated.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Co-authored-by: Joe Lopez <joelopez@microsoft.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Tested-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: DynamicPlatRepoLib: Fix incorrect dereferencing
Kun Qin [Fri, 1 Jul 2022 00:38:50 +0000 (17:38 -0700)]
DynamicTablesPkg: DynamicPlatRepoLib: Fix incorrect dereferencing

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

The content of token should be derived from the data section of the
`CmObject` instead of the object itself.

This change fixed the issue by dereferencing the token value from the
data buffer of input CmObject.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Co-authored-by: Joe Lopez <joelopez@microsoft.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Tested-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoDynamicTablesPkg: DynamicPlatRepoLib: Added MemoryAllocationLib to inf
Kun Qin [Fri, 1 Jul 2022 00:32:36 +0000 (17:32 -0700)]
DynamicTablesPkg: DynamicPlatRepoLib: Added MemoryAllocationLib to inf

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

The DynamicPlatRepoLib has multiple reference to MemoryAllocationLib,
such as DynamicPlatRepo.c and TokenMapper.c. Not including it in the
library inf file could lead to potential build break.

This change added the MemoryAllocationLib into this inf file.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Co-authored-by: Joe Lopez <joelopez@microsoft.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Tested-by: Sami Mujawar <sami.mujawar@arm.com>
19 months agoMdeModulePkg/NvmExpressPei: Use PCI_DEVICE_PPI to manage Nvme device
Chen, Xiao X [Tue, 30 Aug 2022 05:46:48 +0000 (13:46 +0800)]
MdeModulePkg/NvmExpressPei: Use PCI_DEVICE_PPI to manage Nvme device

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

This change modifies NvmExpressPei library
to allow usage both EDKII_PCI_DEVICE_PPI and
EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI to manage Nvme device.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Xiao X Chen <xiao.x.chen@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
19 months agoIntelFsp2WrapperPkg: Add FSP 2.4 MultiPhase interface.
Chasel Chiu [Wed, 10 Aug 2022 00:31:52 +0000 (17:31 -0700)]
IntelFsp2WrapperPkg: Add FSP 2.4 MultiPhase interface.

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

Provide FSP 2.4 MultiPhase wrapper support library.

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>
19 months agoIntelFsp2Pkg: Add FSP 2.4 MultiPhase interface.
Chasel Chiu [Mon, 25 Jul 2022 19:03:51 +0000 (12:03 -0700)]
IntelFsp2Pkg: Add FSP 2.4 MultiPhase interface.

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

Provide FSP 2.4 MultiPhase interface and scripts
support.

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>
19 months agoUefiCpuPkg: Enhance logic in InitializeMpExceptionStackSwitchHandlers
Liu, Zhiguang [Fri, 26 Aug 2022 07:39:01 +0000 (15:39 +0800)]
UefiCpuPkg: Enhance logic in InitializeMpExceptionStackSwitchHandlers

Parallelly run the function to SeparateExceptionStacks for all CPUs and
allocate buffers together for better performance.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
19 months agoUefiCpuPkg: Use Top of each AP's stack to save CpuMpData
Yuanhao Xie [Fri, 19 Aug 2022 06:17:28 +0000 (14:17 +0800)]
UefiCpuPkg: Use Top of each AP's stack to save CpuMpData

To remove the dependency of CPU register, 4/8 byte at the top of the
stack is occupied for CpuMpData. BIST information is also taken care
here. This modification is only for PEI phase, since in DXE phase
CpuMpData is accessed via global variable.

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
19 months agoUefiCpuPkg: Simplify the implementation when separate exception stacks
Liu, Zhiguang [Fri, 26 Aug 2022 07:04:47 +0000 (15:04 +0800)]
UefiCpuPkg: Simplify the implementation when separate exception stacks

The API of InitializeSeparateExceptionStacks is just changed before, and
makes the struct CPU_EXCEPTION_INIT_DATA an internal definition.
Furthermore, we can even remove the struct to make core simpler.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
19 months agoUefiCpuPkg/MpInitLib: Simplify logic in SwitchBsp
Liu, Zhiguang [Fri, 26 Aug 2022 07:04:46 +0000 (15:04 +0800)]
UefiCpuPkg/MpInitLib: Simplify logic in SwitchBsp

When switch bsp, old bsp and new bsp put CR0/CR4 into stack, and put IDT
and GDT register into a structure. After they exchange their stack, they
restore these registers. This logic is now implemented by assembly code.
This patch aims to reuse (Save/Restore)VolatileRegisters function to
replace such assembly code for better code readability.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
19 months agoUefiCpuPkg: Add PCD to control SMRR enable & SmmFeatureControl support
Wu, Jiaxin [Fri, 29 Jul 2022 06:25:55 +0000 (14:25 +0800)]
UefiCpuPkg: Add PCD to control SMRR enable & SmmFeatureControl support

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

Two SMM variables (mSmrrSupported & mSmmFeatureControlSupported) are global
variables, they control whether the SMRR and SMM Feature Control MSR will
be restored respectively.
To avoid the TOCTOU, add PCD to control SMRR & SmmFeatureControl enable.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
19 months agoUefiCpuPkg/MpInitLib: Fix potential issue when IDT table is at above 4G
Liu, Zhiguang [Thu, 25 Aug 2022 02:55:04 +0000 (10:55 +0800)]
UefiCpuPkg/MpInitLib: Fix potential issue when IDT table is at above 4G

Currently, when waking up AP, IDT table of AP will be set in 16 bit code,
and assume the IDT table base is 32 bit. However, the IDT table is created
by BSP. Issue will happen if the BSP allocates memory above 4G for BSP's
IDT table. Moreover, even the IDT table location is below 4G, the handler
function inside the IDT table is 64 bit, and it won't take effect until
CPU transfers to 64 bit long mode. There is no benefit to set IDT table in
such an early phase.
To avoid such issue, this patch moves the LIDT instruction into 64 bit
code.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
19 months agoShellPkg: Adds Local APIC parser to AcpiView
Abdul Lateef Attar [Tue, 9 Aug 2022 06:49:10 +0000 (14:49 +0800)]
ShellPkg: Adds Local APIC parser to AcpiView

Parse Type 0 or Local APIC structure.
Also parse the Local APIC Flags as bitfields.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Abdul Lateef Attar <abdattar@amd.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
19 months agoUefiCpuPkg/CpuPageTableLib/UnitTest: Add host based unit test
Zhiguang Liu [Mon, 27 Jun 2022 08:58:48 +0000 (16:58 +0800)]
UefiCpuPkg/CpuPageTableLib/UnitTest: Add host based unit test

Add host based unit tests for the CpuPageTableLib services.

Unit test focuses on PageTableMap function, containing two kinds of test
cases: manual test case and random test case.
Manual test case creates some corner case to test function PageTableMap.
Random test case generates multiple random memory entries (with random
attribute) as the input of function PageTableMap to get the output
pagetable. Output pagetable will be validated and be parsed to get output
memory entries, and then the input and output memory entries will be
compared to verify the functionality.

The unit test is not perfect yet. There are options for random test, and
some of them control the test coverage, and some option are not ready.
Will enhance in the future.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
19 months ago.azurepipelines: Use Python 3.10.6+
Michael Kubacki [Thu, 25 Aug 2022 15:03:29 +0000 (11:03 -0400)]
.azurepipelines: Use Python 3.10.6+

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

Changes the Python version used in pipelines to 3.10.6 or greater
since that version introduces a fix (bp0-47231) for inconsistent
trailing slashes in tarfile longname directories.

This is required for stuart_update to succeed when handling a
web_dependency (e.g. GCC ARM compilers).

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: Michael D Kinney <michael.d.kinney@intel.com>
19 months agoMaintainers.txt: Update Maintainers/reviewers for universal payload
Guo Dong [Mon, 22 Aug 2022 23:58:00 +0000 (16:58 -0700)]
Maintainers.txt: Update Maintainers/reviewers for universal payload

Add James Lu as UefiPayloadPkg maintainer.
Add Gua Guo as universal payload reviewer.

Signed-off-by: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
20 months agoBaseTools: Fix DevicePath GNUmakefile for macOS edk2-stable202208
Rebecca Cran [Fri, 26 Aug 2022 01:31:46 +0000 (09:31 +0800)]
BaseTools: Fix DevicePath GNUmakefile for macOS

On macOS, /usr/bin/gcc is clang, and so doesn't have
the -Wno-error=stringop-overflow flag that was added
for gcc 12.
Update the GNUmakefile for DevicePath to skip setting
that on macOS.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
20 months agoRevert "BaseTools: Fix DSC LibraryClass precedence rule"
Liming Gao [Fri, 26 Aug 2022 02:06:20 +0000 (10:06 +0800)]
Revert "BaseTools: Fix DSC LibraryClass precedence rule"

This reverts commit 039bdb4d3e96f9c9264abf135b8a0eef2e2b4860 for tag202208.
This brings the behavior changes, and needs more discussion.

Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Bob Feng <bob.c.feng@intel.com>
20 months agoRevert "ShellPkg: Adds Local APIC parser to AcpiView"
Liming Gao [Fri, 26 Aug 2022 02:06:01 +0000 (10:06 +0800)]
Revert "ShellPkg: Adds Local APIC parser to AcpiView"

This reverts commit d5fd86f256b9ab5b4e3aff70d3c177c18faea892 for tag202208.
This feature will be merged after stable tag 202208 is created.

Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
20 months agoRevert "UefiCpuPkg/CpuPageTableLib/UnitTest: Add host based unit test"
Liming Gao [Fri, 26 Aug 2022 02:05:50 +0000 (10:05 +0800)]
Revert "UefiCpuPkg/CpuPageTableLib/UnitTest: Add host based unit test"

This reverts commit 2812668bfc121ee792cf3302195176ef4a2ad0bc for tag202208.
This feature will be merged after stable tag 202208 is created.

Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
20 months agoMaintainers.txt: Update maintainers list
Abner Chang [Thu, 25 Aug 2022 10:33:36 +0000 (18:33 +0800)]
Maintainers.txt: Update maintainers list

Update package maintainers for below package/arch,

1. RISCV64 Architecture:
   Abner is stepping out from RISC-V stuff for now and hand over edk2 RISC-V
   responsibilities to Sunil.
   Daniel Schaefer is no longer with HPE. Update his email address for
   RISCV64 arch. He will keep helping on RISC-V stuff with his personal
   email.

2. EmbeddedPkg:
   Daniel Schaefer is no longer with HPE. Update his email address for
   EmbeddedPkg.

3. EmulatorPkg and RedfishPkg:
   Nickle Wang is no longer with HPE. Update his email address for
   EmulatorPkg and RedfishPkg packages. He will use the personal email for
   the time being until he gets ready with his next journey.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Nickle Wang <nickle@csie.io>
Reviewed-by: Daniel Schaefer <git@danielschaefer.me>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
Reviewed-by: Nickle Wang <nickle@csie.io>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
20 months agoShellPkg: Add revision check for DSDT Header on Arm
Edward Pickup [Wed, 20 Jul 2022 08:59:49 +0000 (16:59 +0800)]
ShellPkg: Add revision check for DSDT Header on Arm

Bugzilla: 3995 (https://bugzilla.tianocore.org/show_bug.cgi?id=3995)

ACPI 6.4 spec states that if the revision field in the DSDT header is less
than 2, then all integers are restricted in width to 32 bits, including in
SSDTs.

Arm Base boot requirements state that platforms must conform to ACPI 6.3
or later, and that legacy tables are not supported.

Adds a check for this field and raise warning if revision is less
than 2 on arm.

Signed-off-by: Edward Pickup <edward.pickup@arm.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
20 months agoUefiPayloadPkg: Fix Coverity report defect
James Lu [Tue, 23 Aug 2022 03:13:55 +0000 (11:13 +0800)]
UefiPayloadPkg: Fix Coverity report defect

https://bugzilla.tianocore.org/show_bug.cgi?id=4018
Coverity report FORWARD_NULL and OVERFLOW_BEFORE_WIDEN potential defect
in UefiPayloadPkg.

Signed-off-by: Gregx Yeh <gregx.yeh@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
20 months agoRedfishPkg: Redfish functions for REST requests are not fully spec complied
Abner Chang [Tue, 23 Aug 2022 02:09:37 +0000 (10:09 +0800)]
RedfishPkg: Redfish functions for REST requests are not fully spec complied

There is no function to send POST request with the
ContentType different from "application\json".
There is no function to send DELETE request with the body.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
20 months agoRedfishPkg: Redfish modules may need to use the functions which are private
Abner Chang [Wed, 17 Aug 2022 03:28:25 +0000 (11:28 +0800)]
RedfishPkg: Redfish modules may need to use the functions which are private

Definitions of the required functions to send requests to BMC
are in the PrivateInclude folder. So they cannot be used by
the other Redfish packages.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
20 months agoRedfishPkg/RedfishDiscoverDxe: USB Redfish host interface is not supported
Abner Chang [Mon, 15 Aug 2022 01:47:30 +0000 (09:47 +0800)]
RedfishPkg/RedfishDiscoverDxe: USB Redfish host interface is not supported

Host Interface details are described by the SMBIOS Type 42
table. The table is published by the RedfishHostInterfaceDxe
driver. That driver supports PCI-E and USB host interface
types.The table is consumed by the edfishGetHostInterfaceProtocolData
function in the RedfishDiscoverDxe driver. The function only supports
PCI-E host interface type.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
20 months agoUefiPayloadPkg: Add macro to control NvmExpressDxe
Kavya [Mon, 22 Aug 2022 13:50:15 +0000 (19:20 +0530)]
UefiPayloadPkg: Add macro to control NvmExpressDxe

Add NVME_ENABLE macro to control NvmExpressDxe driver.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: Kavya <k.kavyax.sravanthi@intel.com>
20 months agoUefiPayloadPkg: Return PciRootBridges instead of NULL
Kavya [Mon, 22 Aug 2022 13:19:30 +0000 (18:49 +0530)]
UefiPayloadPkg: Return PciRootBridges instead of NULL

Return PciRootBridges instead of NULL and set
PcdPciDisableBusEnumeration to FALSE when
root bridge count is zero.

Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: Kavya <k.kavyax.sravanthi@intel.com>
20 months agoShellPkg: Adds Local APIC parser to AcpiView
Abdul Lateef Attar [Tue, 9 Aug 2022 06:49:10 +0000 (14:49 +0800)]
ShellPkg: Adds Local APIC parser to AcpiView

Parse Type 0 or Local APIC structure.
Also parse the Local APIC Flags as bitfields.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Abdul Lateef Attar <abdattar@amd.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
20 months agoBaseTools/Source/C/GenSec: Fix EFI_SECTION_FREEFORM_SUBTYPE_GUID header
Michael D Kinney [Tue, 16 Aug 2022 01:15:24 +0000 (18:15 -0700)]
BaseTools/Source/C/GenSec: Fix EFI_SECTION_FREEFORM_SUBTYPE_GUID header

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

When the size of a EFI_SECTION_FREEFORM_SUBTYPE_GUID section required
the use of EFI_FREEFORM_SUBTYPE_GUID_SECTION2 header, set the section
type to EFI_SECTION_FREEFORM_SUBTYPE_GUID.

Cc: Leif Lindholm <llindhol@qti.qualcomm.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Konstantin Aladyshev <aladyshev22@gmail.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Acked-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Leif Lindholm <llindhol@qti.qualcomm.com>
20 months agoMdePkg: Added support for SMBIOS spec v3.6.0 to Smbios.h
Sainadh Nagolu [Wed, 17 Aug 2022 07:38:28 +0000 (13:08 +0530)]
MdePkg: Added support for SMBIOS spec v3.6.0 to Smbios.h

Updated SmBios.h with new fields added as part of SMBIOS 3.6.0 spec update.

Signed-off-by: Sainadh Nagolu <sainadhn@ami.com>
Cc: Vasudevan Sambandan <vasudevans@ami.com>
Cc: Sundaresan S <sundaresans@ami.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
20 months agoShellPkg: Improved Smbios Type 9 table changes in PrintInfo.c
Sainadh Nagolu [Wed, 17 Aug 2022 07:35:23 +0000 (15:35 +0800)]
ShellPkg: Improved Smbios Type 9 table changes in PrintInfo.c

Since PeerGroups has a variable number of entries, new fields added
after PeerGroups are defined in a extended structure.
Done changes in PrintInfo.c to access those fields using
SMBIOS_TABLE_TYPE9_EXTENDED structure from SmBios.h.

Signed-off-by: Sainadh Nagolu <sainadhn@ami.com>
Cc: Vasudevan Sambandan <vasudevans@ami.com>
Cc: Sundaresan S <sundaresans@ami.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
20 months agoMdePkg: Improved Smbios Type9 table and Smbios spec v3.5.0 Changes
Sainadh Nagolu [Wed, 17 Aug 2022 07:35:23 +0000 (15:35 +0800)]
MdePkg: Improved Smbios Type9 table and Smbios spec v3.5.0 Changes

In Type9 structure since PeerGroups has a variable
number of entries, must not define new fields in the structure.So added an
extended structure and defined new fields added after PeerGroups. Also done
some improvements to Smbios 3.5.0 spec changes.

Signed-off-by: Sainadh Nagolu <sainadhn@ami.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
20 months agoMdeModulePkg/DumpDynPcd: Remove unsupported format specifiers
Konstantin Aladyshev [Wed, 27 Jul 2022 08:45:03 +0000 (16:45 +0800)]
MdeModulePkg/DumpDynPcd: Remove unsupported format specifiers

Some print statements use format specifiers like %N/%H/%E/%B that are
only supported in the shell print functions. In the ordinary 'Print'
function they are just displayed as letters N/H/E/B.
Remove these unsupported format specifiers from the 'Print' statements
to fix the issue.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
20 months agoOvmfPkg/VirtioFsDxe: Check GetDriverName arguments
Dimitrije Pavlov [Mon, 15 Aug 2022 16:31:19 +0000 (11:31 -0500)]
OvmfPkg/VirtioFsDxe: Check GetDriverName arguments

The current implementation does not check if Language or DriverName
are NULL. This causes the SCT test suite to crash.

Add a check to return EFI_INVALID_PARAMETER if any of these pointers
are NULL.

Signed-off-by: Dimitrije Pavlov <Dimitrije.Pavlov@arm.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
20 months agoOvmfPkg/VirtioGpuDxe: Check QueryMode arguments
Dimitrije Pavlov [Tue, 16 Aug 2022 20:28:36 +0000 (15:28 -0500)]
OvmfPkg/VirtioGpuDxe: Check QueryMode arguments

The current implementation does not check if Info or SizeInfo
pointers are NULL. This causes the SCT test suite to crash.

Add a check to return EFI_INVALID_PARAMETER if any of these
pointers are NULL.

Signed-off-by: Dimitrije Pavlov <Dimitrije.Pavlov@arm.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
20 months agoOvmfPkg/PlatformDxe: Check ExtractConfig and RouteConfig arguments
Dimitrije Pavlov [Tue, 16 Aug 2022 20:28:35 +0000 (15:28 -0500)]
OvmfPkg/PlatformDxe: Check ExtractConfig and RouteConfig arguments

The current implementation does not check if Progress or Results
pointers in ExtractConfig are NULL, or if Progress pointer in
RouteConfig is NULL. This causes the SCT test suite to crash.

Add a check to return EFI_INVALID_PARAMETER if any of these pointers
are NULL.

Signed-off-by: Dimitrije Pavlov <Dimitrije.Pavlov@arm.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
20 months agoUefiCpuPkg/CpuPageTableLib/UnitTest: Add host based unit test
Zhiguang Liu [Mon, 27 Jun 2022 08:58:48 +0000 (16:58 +0800)]
UefiCpuPkg/CpuPageTableLib/UnitTest: Add host based unit test

Add host based unit tests for the CpuPageTableLib services.

Unit test focuses on PageTableMap function, containing two kinds of test
cases: manual test case and random test case.
Manual test case creates some corner case to test function PageTableMap.
Random test case generates multiple random memory entries (with random
attribute) as the input of function PageTableMap to get the output
pagetable. Output pagetable will be validated and be parsed to get output
memory entries, and then the input and output memory entries will be
compared to verify the functionality.

The unit test is not perfect yet. There are options for random test, and
some of them control the test coverage, and some option are not ready.
Will enhance in the future.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
20 months agoMdeModulePkg: Update the SMBIOS version by UPL
KasimX Liu [Fri, 5 Aug 2022 08:17:21 +0000 (16:17 +0800)]
MdeModulePkg: Update the SMBIOS version by UPL

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

For the SMBIOS version can be update by UPL,we create
the gUniversalPayloadSmbios3TableGuid HOB to store
the value then updated version.

Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: KasimX Liu <kasimx.liu@intel.com>
20 months agoIntelFsp2Pkg: FSPM_ARCH2_UPD mismatching bug.
Chasel Chiu [Mon, 15 Aug 2022 06:13:01 +0000 (23:13 -0700)]
IntelFsp2Pkg: FSPM_ARCH2_UPD mismatching bug.

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

FSPM_ARCH2_UPD in FspApiEntryM.nasm was not up-to-date and
should be fixed for both IA32 and X64 builds.

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: Star Zeng <star.zeng@intel.com>
20 months agoUefiPayloadPkg: Remove clearing CR0.WP when protecting pagetable
Dun Tan [Wed, 10 Aug 2022 03:31:57 +0000 (11:31 +0800)]
UefiPayloadPkg: Remove clearing CR0.WP when protecting pagetable

Remove clearing CR0.WP when marking the memory used for page table
as read-only in the page table itself created by UefiPayloadEntry.
This page table address is written to Cr3 after these protection
steps. Till this, the memory used for page table is always RW.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Ray Ni <ray.ni@intel.com>
20 months agoMdeModulePkg/DxeIpl: Remove clearing CR0.WP when protecting pagetable
Dun Tan [Tue, 26 Jul 2022 14:13:40 +0000 (22:13 +0800)]
MdeModulePkg/DxeIpl: Remove clearing CR0.WP when protecting pagetable

Remove clearing CR0.WP when marking the memory used for page table
as read-only in the page table itself created by DxeIpl. This page
table address is written to Cr3 after these protection steps. Till
this, the memory used for page table is always RW.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Ray Ni <ray.ni@intel.com>
20 months agoUefiCpuPkg/PiSmmCpuDxeSmm: Remove mInternalCr3 in PiSmmCpuDxeSmm
Dun Tan [Tue, 9 Aug 2022 07:58:28 +0000 (15:58 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm: Remove mInternalCr3 in PiSmmCpuDxeSmm

This patch is code refactoring and doesn't change any functionality.
Remove mInternalCr3 in PiSmmCpuDxe pagetable related code. In previous
code, mInternalCr3 is used to pass address of page table which is
different from Cr3 register in different level of SetMemoryAttributes
function. Now remove it and pass the page table base address from the
root function parameter to simplify the code logic.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
20 months agoUefiCpuPkg/PiSmmCpuDxeSmm: Add a new mIsShadowStack flag
Dun Tan [Tue, 9 Aug 2022 07:22:07 +0000 (15:22 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm: Add a new mIsShadowStack flag

This patch is code refactoring and doesn't change any functionality.
Add a new mIsShadowStack flag to identify whether current memory is
shadow stack. Previous smm code logic regards a RO range as shadow
stack and set the dirty bit in corresponding page table entry if
mInternalCr3 is not 0, which may be confusing.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
20 months agoShellPkg/SmbiosView: Display extended memory info in smbiosview -t 17
Shengfengx Xue [Sat, 6 Aug 2022 02:02:13 +0000 (10:02 +0800)]
ShellPkg/SmbiosView: Display extended memory info in smbiosview -t 17

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

If Configured Memory Speed is 65,535 MT/s or greater,
and the actual speed is stored in the Extended Configured Memory Speed
field. but current Smbiosview have no this logic.

Signed-off-by: Shengfengx Xue <shengfengx.xue@intel.com>
20 months agoMdeModulePkg: Enhance bus scan for all root bridge instances
Foster Nong [Fri, 22 Jul 2022 09:10:26 +0000 (17:10 +0800)]
MdeModulePkg: Enhance bus scan for all root bridge instances

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

Change flow to bus scan all root bridge instances even when any
one root bridge meet bus resource OUT_OF_RESOURCE case.
thus platform handler  of "EfiPciHostBridgeEndBusAllocation" has
an chance to do relative pci bus rebalance to handle this case.

Signed-off-by: Foster Nong <foster.nong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
20 months agoMdePkg/Library/UefiDevicePathLib: Add back StandaloneMm INF file
Michael D Kinney [Wed, 10 Aug 2022 04:22:54 +0000 (21:22 -0700)]
MdePkg/Library/UefiDevicePathLib: Add back StandaloneMm INF file

REF: https://github.com/tianocore/edk2/pull/3130

The above PR removed UefiDevicePathLibStandaloneMm.inf, which is
a non-backwards compatible change and does not provide time for
downstream platforms to use the UefiDevicePathLibBase.inf.

Add UefiDevicePathLibStandaloneMm.inf back, but add comments that
it is deprecated and that UefiDevicePathLibBase.inf should be used
instead.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Mateusz Albecki <mateusz.albecki@intel.com>
Cc: Yanbo Huang <yanbo.huang@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
20 months agoCpuPageTableLib: define IA32_PAGE_LEVEL enum type internally
Ray Ni [Mon, 18 Jul 2022 09:00:29 +0000 (17:00 +0800)]
CpuPageTableLib: define IA32_PAGE_LEVEL enum type internally

The change doesn't change functionality behavior.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoCpuPageTableLib: Fix bug that wrongly requires extra size for mapping
Ray Ni [Mon, 18 Jul 2022 08:41:37 +0000 (16:41 +0800)]
CpuPageTableLib: Fix bug that wrongly requires extra size for mapping

With following paging structure to map
  [2M-4K, 2M] as P = 1, RW = 0,
  [2M, 4M]    as P = 1, RW = 1:

PML4[0] -> PDPTE[0] -> PDE[0](RW = 0) -> PTE[255](P = 0, RW = 0)
                    -> PDE[1](RW = 1)

When a new request to map [2M-4K, 2M+4K] as P = 1, RW = 1,
CpuPageTableMap() wrongly requests 4K buffer size for the new mapping
request.

But in fact, for [2M-4K, 2M] request, PTE[255] can be changed in place,
for [2M, 2M+4K], no change is needed because PDE[1].RW = 1 already.

The change fixes the bug.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoCpuPageTableLib: Fix a bug to avoid unnecessary changing to page table
Ray Ni [Fri, 15 Jul 2022 12:40:29 +0000 (20:40 +0800)]
CpuPageTableLib: Fix a bug to avoid unnecessary changing to page table

With the following paging structure that maps [0, 2G] with ReadWrite
bit set.
PML4[0] --> PDPTE[0] --> PDE[0-255]
              \-> PDPTE[1] --> PDE[0-255]

If ReadWrite bit is cleared in PML4[0] and PageTableMap() is called
to change [0, 2M] as read-only, today's logic unnecessarily changes
the paging structure in 2 aspects:
1. When setting PageTableBaseAddress in the entry, the code clears
    all attributes.
2. Even the ReadWrite bit in parent entry is not set, the code clears
    the ReadWrite bit in the leaf entry.

First change is wrong. It should not change other attributes when
setting the PA.
Second change is unnecessary. Because the parent entry already
declares the whole region as read-only, there is no need to clear
ReadWrite bit in the leaf entry again.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoCpuPageTableLib: Fix parent attributes are not inherited properly
Ray Ni [Fri, 15 Jul 2022 12:10:08 +0000 (20:10 +0800)]
CpuPageTableLib: Fix parent attributes are not inherited properly

With the following paging structure that maps [0, 2G] with ReadWrite
bit set.
PML4[0] --> PDPTE[0] --> PDE[0-255]
              \-> PDPTE[1] --> PDE[0-255]

If ReadWrite bit is cleared in PML4[0] and PageTableMap() is called
to change [0, 2M] as writable, today's logic doesn't inherit the
parent entry's attributes when determining the child entry's
attributes. It just sets the PDPTE[0].PDE[0].ReadWrite bit.
But since the PML4[0].ReadWrite is 0, [0, 2M] is still read-only.

The change fixes the bug.
If the inheritable attributes in ParentPagingEntry conflicts with the
requested attributes, let the child entries take the parent attributes
and loosen the attribute in the parent entry.

E.g.: when PDPTE[0].ReadWrite = 0 but caller wants to map [0-2MB as
ReadWrite = 1 (PDE[0].ReadWrite = 1), we need to change
PDPTE[0].ReadWrite = 1 and let all PDE[0-255].ReadWrite = 0 first.
Then change PDE[0].ReadWrite = 1.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoCpuPageTableLib: Avoid treating non-leaf entry as leaf one
Ray Ni [Fri, 15 Jul 2022 07:22:57 +0000 (15:22 +0800)]
CpuPageTableLib: Avoid treating non-leaf entry as leaf one

Today's logic wrongly treats the non-leaf entry as leaf entry and
updates its paging attributes.

The patch fixes the bug to only update paging attributes for
non-present entries or leaf entries.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoCpuPageTableLib: Split the page entry when LA is aligned but PA is not
Ray Ni [Thu, 14 Jul 2022 12:08:29 +0000 (20:08 +0800)]
CpuPageTableLib: Split the page entry when LA is aligned but PA is not

When PageTableMap() is called to create non 1:1 mapping
such as [0, 1G) to [8K, 1G+8K), it should split the page entry to the
4K page level, but old logic has a bug that it just uses 1G page
entry.

The patch fixes the bug.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoCpuPageTableLib: Refactor the logic
Ray Ni [Thu, 14 Jul 2022 10:00:47 +0000 (18:00 +0800)]
CpuPageTableLib: Refactor the logic

The patch replaces
  LinearAddress + Offset == RegionStart
with
  ((LinearAddress + Offset) & RegionMask) == 0

The replace should not cause any behavior change.

Because:
1. In first loop of while when LinearAddress + Offset == RegionStart,
  because the lower "BitStart" bits of RegionStart are all-zero,
  all lower "BitStart" bits of (LinearAddress + Offset) are all-zero.
  Because all lower "BitStart" bits of RegionMask is all-one and
  bits are all-zero, ((LinearAddress + Offset) & RegionMask) == 0.

2. In following loops of the while, even RegionStart is increased
  by RegionLength, the lower "BitStart" bits are still all-zero.
  So the two expressions still semantically equal to each other.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoCpuPageTableLib: Fix a bug when a bit is 1 in Attribute, 0 in Mask
Ray Ni [Thu, 14 Jul 2022 08:03:11 +0000 (16:03 +0800)]
CpuPageTableLib: Fix a bug when a bit is 1 in Attribute, 0 in Mask

To reproduce the issue:
  UINTN               PageTable;
  VOID                *Buffer;
  UINTN               PageTableBufferSize;
  IA32_MAP_ATTRIBUTE  Attribute;
  IA32_MAP_ATTRIBUTE  Mask;
  RETURN_STATUS       Status;

  Attribute.Uint64       = 0;
  Mask.Uint64            = 0;
  PageTableBufferSize    = 0;
  PageTable              = 0;
  Buffer                 = NULL;
  Attribute.Bits.Present = 1;
  Attribute.Bits.Nx      = 1;
  Mask.Bits.Present      = 1;
  Mask.Uint64            = MAX_UINT64;

  //
  // Create page table to cover [0, 10M)
  //
  Status = PageTableMap (
             &PageTable, PagingMode, Buffer, &PageTableBufferSize,
             0, (UINT64)SIZE_2MB * 5, &Attribute, &Mask
             );
  ASSERT (Status == RETURN_BUFFER_TOO_SMALL);
  Buffer = AllocatePages (EFI_SIZE_TO_PAGES (PageTableBufferSize));
  Status = PageTableMap (
             &PageTable, PagingMode, Buffer, &PageTableBufferSize,
             0, (UINT64)SIZE_2MB * 5, &Attribute, &Mask
             );
  ASSERT (Status == RETURN_SUCCESS);

  //
  // Change the mapping for [0, 4KB)
  // No change actually. Just clear Nx bit in Mask.
  //
  Mask.Bits.Nx        = 0;
  PageTableBufferSize = 0;

  Status = PageTableMap (
             &PageTable, PagingMode, NULL, &PageTableBufferSize,
             0, (UINT64)SIZE_4KB, &Attribute, &Mask
             );
  ASSERT (Status == RETURN_SUCCESS); // FAIL!!

The root cause is when comparing the existing mapping attributes
against the requested one, Mask is not used but it should be used.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoUefiCpuPkg/CpuPageTableLib: Return error on invalid parameters
Ray Ni [Thu, 14 Jul 2022 07:36:09 +0000 (15:36 +0800)]
UefiCpuPkg/CpuPageTableLib: Return error on invalid parameters

When LinearAddress or Length is not aligned on 4KB, PageTableMap()
should return Invalid Parameter.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoUefiCpuPkg: Create CpuPageTableLib for manipulating X86 paging structs
Ray Ni [Thu, 14 Jul 2022 06:33:18 +0000 (14:33 +0800)]
UefiCpuPkg: Create CpuPageTableLib for manipulating X86 paging structs

The lib includes two APIs:
* PageTableMap
  It creates/updates mapping from LA to PA.
  The implementation only supports paging structures used in 64bit
  mode now. PAE paging structure support will be added in future.

* PageTableParse
   It parses the page table and returns the mapping relations in an
  array of IA32_MAP_ENTRY.

It passed some stress tests. These test code will be upstreamed in
other patches following edk2 Unit Test framework.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
20 months agoUefiCpuPkg: Simplify the struct definition of CPU_EXCEPTION_INIT_DATA
Liu, Zhiguang [Tue, 9 Aug 2022 01:25:37 +0000 (09:25 +0800)]
UefiCpuPkg: Simplify the struct definition of CPU_EXCEPTION_INIT_DATA

CPU_EXCEPTION_INIT_DATA is now an internal implementation of
CpuExceptionHandlerLib. Union can be removed since Ia32 and X64 have the
same definition. Also, two fields (Revision and InitDefaultHandlers)are
useless, can be removed.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
20 months agoMdeModulePkg: Move CPU_EXCEPTION_INIT_DATA to UefiCpuPkg
Liu, Zhiguang [Tue, 9 Aug 2022 01:25:36 +0000 (09:25 +0800)]
MdeModulePkg: Move CPU_EXCEPTION_INIT_DATA to UefiCpuPkg

Since the API InitializeSeparateExceptionStacks is simplified and does't
use the struct CPU_EXCEPTION_INIT_DATA, CPU_EXCEPTION_INIT_DATA become
a inner implementation of CpuExcetionHandlerLib.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
20 months agoUefiCpuPkg: Simplify InitializeSeparateExceptionStacks
Liu, Zhiguang [Tue, 9 Aug 2022 01:25:35 +0000 (09:25 +0800)]
UefiCpuPkg: Simplify InitializeSeparateExceptionStacks

Hide the Exception implementation details in CpuExcetionHandlerLib and
caller only need to provide buffer

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
20 months agoPrmPkg: Add details on AArch64 build to the Readme.
Jose Marinho [Tue, 26 Jul 2022 16:54:42 +0000 (17:54 +0100)]
PrmPkg: Add details on AArch64 build to the Readme.

Specify how to build the PrmPkg for the AArch64 architecture.
Make the 2 following notes:
 - the PrmPkg has only been tested on AArch64 using the GCC5
toolchain.
 - All symbols to be listed in the PRMT as well as the
PrmModuleExportDescriptor must be explicitly preserved by resorting to
the --require-defined linker flag.

Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
20 months agoPrmPkg: Support AArch64 builds using GCC
Jose Marinho [Fri, 18 Dec 2020 14:01:55 +0000 (14:01 +0000)]
PrmPkg: Support AArch64 builds using GCC

Add support to build PrmPkg for AArch64 using the GCC compiler.

Add AARCH64 architecture to the list of supported architectures.
Add BaseStackCheck library to allow for Prm module builds on AARCH64.

Also update the CI to add dependency on ArmPkg.

Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
20 months agoPrmPkg: Build Prm Samples with GCC for AARCH64
Jose Marinho [Tue, 5 Apr 2022 17:57:23 +0000 (18:57 +0100)]
PrmPkg: Build Prm Samples with GCC for AARCH64

- Add the --prm flag to the GENFW_FLAGS
- Add the --no-gc-section to the linker flags so that apparently
unreferenced symbols are not prematurely removed from the .dll which
is used to generate the Prm module .efi.
- Force the linker to maintain the PrmModuleExportDescriptor symbol.
- Force the linker to maintain the PRM handler funtion's symbol.

Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
20 months agoPrmPkg: Enable external visibility on PRM symbols
Jose Marinho [Tue, 5 Apr 2022 17:53:25 +0000 (18:53 +0100)]
PrmPkg: Enable external visibility on PRM symbols

Enable GCC compilations to keep external symbols when generating a PRM
module.

Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
20 months agoBasetools/GenFw: Allow AARCH64 builds to use the --prm flag
Jose Marinho [Fri, 29 Oct 2021 16:48:26 +0000 (17:48 +0100)]
Basetools/GenFw: Allow AARCH64 builds to use the --prm flag

The GenFw invocation with the --prm flag was previously reserved for
X64.
AArch64 platforms, built with GCC5, can also deploy PRM modules, hence
the --prm flag is also applicable in builds targeting the AARCH64
architecture.

This commit enables the --prm flag to be used for EDK2 builds targeting
AARCH64.

Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>