33910 Commits

Author SHA1 Message Date
Ard Biesheuvel
c558a3b18b ArmPkg/ArmGicDxe: Map GIC MMIO regions before use
The GIC driver itself has intimate knowledge of the hardware, and so it
is the best suited to create the mappings of the MMIO control regions,
in case they have not been mapped yet by the platform code.

So call in the the CPU arch protocol to map the CPU interface,
distributor and redistributor regions as they are discovered by the GIC
driver startup code.

Note that creating these mappings has no effect if the regions in
question have already been mapped with the correct attributes.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Ard Biesheuvel
3c4c7a0fc9 ArmPkg/ArmGicDxe: Remove pointless passing around of MMIO addresses
The GIC distributor and redistributor addresses that are passed into the
interrupt enable and disable routines are always the same, so just use
the global variables directly.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Ard Biesheuvel
e68e784649 ArmPkg/ArmGicDxe: Avoid pointless repeated iteration over GIC frames
The GIC DXE driver only runs on the boot CPU, and so there is really no
point in iterating over all the redistributor frames every time an
interrupt is enabled, disabled or its state tested. Instead, do this
only at load time.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Ard Biesheuvel
387fcf4fa1 ArmPkg/ArmGicDxe: Replace CpuArch registration event with DEPEX
Instead of relying on a protocol notification event to register the core IRQ
interrupt handler with CPU arch protocol once it becomes available, use
a DEPEX to ensure that the GIC driver is not dispatched at all until the
CPU arch protocol has turned up.

This will allow the GIC driver to use other CPU arch protocol methods,
such as the ones needed to map the GIC MMIO regions at driver startup.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Ard Biesheuvel
fb7497cbf9 ArmPkg/CpuDxe: Replace DEPEX on h/w protocol with event notification
Currently, ArmPkg's CpuDxe DEPEXes on the hardware interrupt protocol,
to ensure that it is not dispatched before the GIC driver. This way, the
CpuDxe driver is guaranteed not to enable interrupts on the CPU side
before the GIC driver has had the opportunity to configure the
interrupts on the distribution side.

However, this prevents the GIC driver from using any of the CPU arch
protocol interfaces, such as mapping memory, which it may need to do on
platforms where the GIC MMIO regions are not mapped yet when the driver
is started.

So instead, use a protocol notification on the hardware interrupt
protocol, which is installed by the GIC driver (as well as other
existing interrupt controller drivers for platforms that do not
implement a GIC) after it starts up and deasserts and disables all
incoming interrupts. Manipulate the interrupt state as usual only after
this notification has been received. Before that, keep track of the
caller's intent regarding the interrupt enabled state in a shadow
variable, but do not actually enable interrupt delivery to the CPU just
yet.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Ard Biesheuvel
0422dd0669 ArmPkg/CpuDxe: Remove rudimentary vector handoff logic
There is some fossilized code in the CpuDxe driver startup code that
permits a vector table to be inherited from the PEI stage, but this code
is essentially dead on ARM platforms, given that the VectorInfo argument
passed to InitializeCpuExceptionHandlers() is ignored, and no code
appears to exist that would result in the gEfiVectorHandoffTableGuid
configuration table ever being populated.

Also, due to prior refactoring, the code that disables and re-enables
IRQs and FIQs is completely pointless, and can simply be removed. That,
in turn, allows the CPU arch protocol parameter to be dropped from the
prototype of InitializeExceptions().

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Ard Biesheuvel
e5b56d6ef9 ArmPkg/CpuDxe: Use STATIC linkage where possible
Use static linkage for variables and routines that are not referenced
from other objects. This is generally preferred, because it gives the
compiler more freedom for optimization.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Ard Biesheuvel
afdae789cd ArmPkg/CpuDxe: Fix error handling in driver initialization
Failure to install the CPU arch protocol is a fatal error, so treat it
as such, rather than ignore it, even though we won't get very far if
this driver fails to dispatch - at least, we will get an error in a
DEBUG build rather than a mysterious failure due to unsatisfied DEPEXes.

Failure to install the idle loop event handler is not a fatal error, and
it should not cause the driver to exit with an error, as this will
unload the driver and keep the installed CPU arch protocol pointer
dangling. So keep the ASSERT() on the return value, but return
EFI_SUCCESS once we're past the point where the CPU arch protocol has
been installed.

Since the protocol is never uninstalled, make the CPU handle function
local, as there is no point in keeping its value around.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 13:07:05 +00:00
Michael Kubacki
b64f735867 Maintainers.txt: Update EmulatorPkg maintainers
Add Oliver Smith-Denny and Michael Kubacki as maintainers.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-01-29 22:04:49 +00:00
Michael D Kinney
2cb8bf6c69 UnitTestFrameworkPkg: Fix false positives from address sanitizer
PR #6408 introduced a host specific NORETURN function to resolve
false positives from the address sanitizer when LongJump() is
called and the stack is reset to a previous stack frame.

This approach was discussed here:
https://github.com/tianocore/edk2/pull/6408/files#r1918810499

False positives are still being observed with this initial
solution.

The address sanitizer provides __asan_handle_no_return()
to clean up shadow memory before a NORETURN function is
called and provides a simpler implementation for this
issue without having to introduce a host specific
NORETURN function.

https://github.com/llvm/llvm-project/blob/main/compiler-rt/include/sanitizer/asan_interface.h

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-01-29 19:35:30 +00:00
Ard Biesheuvel
3600675368 MdePkg/BasePeCoffLib: Remove DEBUG() statements from runtime code
PeCoffLoaderRelocateImageForRuntime() executes after boot services, and
so it should not use DEBUG() prints at all, given that these may rely on
MMIO mappings or other boot time facilities that are no longer
available.

So revert the changes in aedcaa3df8a2 ("MdePkg: Fix overflow issue in
PeCoffLoaderRelocateImageForRuntime") that replaced code comments with
DBEUG() statements.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-29 18:42:13 +00:00
Mike Maslenkin
254937f0bc ShellPkg: fix warnings about uninitialized variable
Dmem.c: In function 'GetImageExecutionInfo':
Dmem.c:241:10: error: 'Status' may be used uninitialized
  in this function [-Werror=maybe-uninitialized]
   return Status;
          ^~~~~~
Dmem.c:284:35: note: 'Status' was declared here
   EFI_STATUS                      Status;
                                   ^~~~~~
Dmem.c: In function 'ShellCommandRunDmem':
Dmem.c:586:27: error: 'ConformanceProfileTableAddress' may be used
  uninitialized in this function [-Werror=maybe-uninitialized]

ShellStatus = DisplayConformanceProfiles (ConformanceProfileTableAddress);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dmem.c:582:27: error: 'ImageExecutionTableAddress' may be used
  uninitialized in this function [-Werror=maybe-uninitialized]

ShellStatus = DisplayImageExecutionEntries (ImageExecutionTableAddress);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dmem.c:578:27: error: 'RtPropertiesTableAddress' may be used
  uninitialized in this function [-Werror=maybe-uninitialized]

ShellStatus = DisplayRtProperties (RtPropertiesTableAddress);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2025-01-29 17:20:57 +01:00
Mike Maslenkin
755d4b9397 OvmfPkg: fix warning about uninitialized variable
GenericQemuLoadImageLib.c: In function 'QemuLoadKernelImage':
GenericQemuLoadImageLib.c:323:5: error: 'CommandLine' may be used
  uninitialized in this function [-Werror=maybe-uninitialized]
     UnicodeSPrintAsciiFormat (
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
       KernelLoadedImage->LoadOptions,
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       KernelLoadedImage->LoadOptionsSize,
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "%a%a",
       ~~~~~~~
       (CommandLineSize == 0) ?  "" : CommandLine,
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       (InitrdSize == 0)      ?  "" : " initrd=initrd"
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       );
       ~
cc1: all warnings being treated as errors

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2025-01-29 17:20:57 +01:00
Mike Maslenkin
ceb87029c5 SecurityPkg/RngDxe: fix warning about uninitialized variable
ArmTrng.c: In function 'GenerateEntropy':
ArmTrng.c:40:15: error: 'Status' may be used uninitialized
  in this function [-Werror=maybe-uninitialized]

   EFI_STATUS  Status;
               ^~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2025-01-29 17:20:57 +01:00
Mike Maslenkin
c58501aa1a MdeModulePkg: NvmExpressDxe: fix warning about uninitialized variable
NvmExpressMediaSanitize.c: In function 'NvmExpressMediaClear':
NvmExpressMediaSanitize.c:337:29: error: 'Status' may be used uninitialized
  in this function [-Werror=maybe-uninitialized]

   EFI_STATUS                Status;
                             ^~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2025-01-29 17:20:57 +01:00
Mike Maslenkin
0f12a5f722 MdeModulePkg: fix warning about uninitialized variable
Handle.c:1302:24: error: 'Prot' may be used uninitialized
  in this function [-Werror=maybe-uninitialized]

       *Interface = Prot->Interface;
                    ~~~~^~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2025-01-29 17:20:57 +01:00
Mike Maslenkin
a5cb67fb8d MdeModulePkg: PeiMain: fix warning about uninitialized variable
Dispatcher.c:1639:34: error: 'FvMigrationFlags' may be used uninitialized
  in this function [-Werror=maybe-uninitialized]
(((FvMigrationFlags & FLAGS_FV_MIGRATE_BEFORE_PEI_CORE_REENTRY) == 0) ||
                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2025-01-29 17:20:57 +01:00
Gerd Hoffmann
bba72ffbe1 OvmfPkg/QemuKernelLoaderFsDxe: use SIZE_OF_EFI_FILE_INFO
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-01-28 23:28:45 +00:00
Santhosh Kumar V
df84bb5eda Resolved Coverity Issues in Http Dxe
1.HttpResponseWorker(DEADCODE)
The result of pointer arithmetic "HttpHeaders+AsciiStrLen("HTTP/1.1") + 1"
is never null.
2.HttpsSupport.c (NULL_RETURNS)
NetbufAlloc might return null pointer ,so assigning "NULL" to
"PacketOut" and "DataOut" pointer.

Solution:
1.Removed the NULL Check for "StatusCodeStr"
2.Added Null Check for PacketOut and returned EFI_OUT_OF_RESOURCES
on NULL case.

Signed-off-by: santhosh kumar V <santhoshkumarv@ami.com>
2025-01-28 20:38:38 +00:00
INDIA\sachinganesh
428cd8a46f MdePkg: Fix Clang Build Error
Fixed Clang build error introduced by unintialized variables in
6278bbb898

Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
2025-01-28 15:04:30 +00:00
Gerd Hoffmann
18984b68fe OvmfPkg: make legacy direct kernel loader code nx clean
kernel pages are code not data.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-01-27 22:59:55 +00:00
Ashraf Ali S
6d2143f685 BaseTools: Fix NoneType parent reference in FMMT operations
This patch addresses an issue in the FMMT operations where the parent
reference is not checked for NoneType. This oversight can lead to an
AttributeError: 'NoneType' object has no attribute 'Name' when
attempting to access the parent reference. The fix involves adding a
check for NoneType before accessing the parent reference to ensure that
the operations handle such cases gracefully.

The affected functions include:
- AddNewFfs
- ReplaceFfs
- ExtractFfs

These functions now include proper checks to prevent the AttributeError.

Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
2025-01-27 16:26:18 +00:00
Anthony PERARD
8c1e786e50 OvmfPkg/XenPvBlkDxe: Update disk size calculation
The specification wasn't clear and even contradict itself regarding
the calculation of the disk size. This have been clarified by Xen
commit 221f2748e8da ("blkif: reconcile protocol specification with
in-use implementations").

https://xenbits.xenproject.org/gitweb/?p=xen.git;a=commit;h=221f2748e8dabe8361b8cdfcffbeab9102c4c899

The value from the xenstore node "sectors" must be multiplied by 512
to have the size of the disk.

Calculation of LastBlock is now the same for both CD-ROM case and
generic case.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
2025-01-27 14:37:53 +00:00
Anthony PERARD
3cf7a644eb OvmfPkg/IndustryStandard/Xen: Update io/blkif.h
Import the latest version of blkif.h header from Xen.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
2025-01-27 14:37:53 +00:00
Star Zeng
7c5ec51175 MdeModulePkg PeiMain: Remove return for PeiCoreBuildHobHandoffInfoTable()
PeiCoreBuildHobHandoffInfoTable() always returns EFI_SUCCESS, and also
its return is not consumed at all, so this patch removes return for
PeiCoreBuildHobHandoffInfoTable().

Signed-off-by: Star Zeng <star.zeng@intel.com>
2025-01-26 18:35:08 +00:00
INDIA\sachinganesh
d35899b6d2 UnitTestFrameworkPkg: Add SafeIntLib to Common Includes
SafeIntLib has been added to UnitTestFrameworkPkg Common Includes DSC
for usage in host and target based tests.

Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
2025-01-26 17:15:56 +00:00
INDIA\sachinganesh
6278bbb898 MdePkg: Use SafeIntLib to handle overflow
Used SafeIntLib to handle the overflow check in
PeCoffLoaderRelocateImage

Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
2025-01-26 17:15:56 +00:00
INDIA\sachinganesh
aedcaa3df8 MdePkg: Fix overflow issue in PeCoffLoaderRelocateImageForRuntime
RelocDir->Size is a UINT32 value, and RelocDir->VirtualAddress is
also a UINT32 value. The current code in
PeCoffLoaderRelocateImageForRuntime does not check for overflow when
adding RelocDir->Size to RelocDir->VirtualAddress. This patch uses
SafeIntLib to ensure that the addition does not overflow.

Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
2025-01-26 17:15:56 +00:00
Chasel Chiu
b3bfb8f22d UefiPayloadPkg: Add 4KB align to CLANGDWARF build.
After commit aca75d3 the PayloadEntry ELF header will miss dynamic
section which caused PEI_ASSERT in PayloadLoader rebasing code.

This commit adding common-page-size=0x1000 to CLANGDWARF_DLINK_FLAGS
to overcome the ELF header generation issue.

Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
2025-01-25 19:52:25 +00:00
Yang Gang
e356b0f6fd EmulatorPkg PlatformBm: Fix duplicate BootManagerMenuApp boot option issue
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2025-01-24 20:41:08 +00:00
Yang Gang
0df3729ad6 ShellPkg Http.c: Remove extra \n when using -m param
There is already `PRINT_HII (STRING_TOKEN (STR_GEN_CRLF), NULL);`
after `DownloadFile()`, remove this extra `\n` to avoid
printing extra blank lines.

Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2025-01-24 19:44:08 +00:00
Gerd Hoffmann
1f19c3d6ee OvmfPkg/GenericQemuLoadImageLib: fix cmdline + initrd handling
Commit 459f5ffa24ae ("OvmfPkg/QemuKernelLoaderFsDxe: rework direct
kernel boot filesystem") has a small change in behavior:  In case
there is no data the file is not created and attempts to open file
return EFI_NOT_FOUND.  Old behavior was to add a zero-length file
to the filesystem.

Fix GenericQemuLoadImageLib to handle EFI_NOT_FOUND correctly for
'initrd' and 'cmdline'.

Reported-by: Srikanth Aithal <sraithal@amd.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-01-24 18:26:37 +00:00
Gerd Hoffmann
b873e8b8e3 OvmfPkg/QemuKernelLoaderFsDxe: root directory name should be ""
UEFI spec says so, fix it.

https://uefi.org/specs/UEFI/2.11/13_Protocols_Media_Access.html#efi-file-info

Reported-by: Laszlo Ersek <laszlo.ersek@posteo.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-01-24 17:12:07 +00:00
Star Zeng
9f28d48d2f Maintainers.txt: Add Star as UefiCpuPkg reviewer
Jiaxin has been maintainer, replace his reviewer line with Star.

Signed-off-by: Star Zeng <star.zeng@intel.com>
2025-01-24 15:52:56 +00:00
Star Zeng
38c17825ad UefiCpuPkg LocalApicLib: Correct typo LINT0 to LINT1
In ProgramVirtualWireMode(), correct typo LINT0 to LINT1.

Signed-off-by: Star Zeng <star.zeng@intel.com>
2025-01-24 14:09:37 +00:00
Anthony PERARD
99cbb63652 OvmfPkg/OvmfXen: use PeiPcdLib for PEI_CORE
Commit d64d1e195ceb ("MdeModulePkg: PeiMain: Introduce implementation
of delayed dispatch") introduced a new usage of the TimerLib which
uses a dynamic PCD in OvmfXen platform. But PeiMain has only access to
a NULL version of PcdLib, so OvmfXen can't start.

Introduce PeiPcdLib for PEI_CORE so PeiMain can read dynamic PCDs.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
2025-01-24 12:57:59 +00:00
zhu rui
33309733e4 command drvcfg ASSERT
REF: https://github.com/tianocore/edk2/issues/10626

Issue command drvcfg directly, system halt

Signed-off-by: "Zhu, Cliff" <Cliff.zhu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2025-01-24 10:02:23 +00:00
Abdul Lateef Attar
eda58c143c DynamicTablesPkg: Adds X64 FACS generator library
Adds a library to generate the ACPI FACS table for X64 architecture.
It gathers the necessary FACS information from the configuration manager.
Additionally, it includes an event to update the hardware signature
in the FACS table, where the hardware signature is the
CRC of all ACPI table's CRC

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
2025-01-24 09:38:40 +01:00
Heinrich Schuchardt
feb8d49834 OvmfPkg/RiscVVirtQemu.dsc: enable VGA support
QEMU enables VIRTIO_VGA by default.

Libvirt falls back from virtio-gpu-pci to virtio-vga if made available by
QEMU.

We need to enable VGA support to get video output for EDK II in
virt-manager.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-01-23 12:43:11 +00:00
Zhiguang Liu
a36fb60053 Maintainers.txt: Remove myself from some reviewer role
Remove myself from reviewer role for below folders:
  MdeModulePkg: Universal Payload definitions
  MdePkg

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
2025-01-23 06:31:24 +00:00
Michael D Kinney
81802056c8 EmulatorPkg: Move magic page to first allocation
The magic page is allocated from a fixed address specified
by PcdPeiServicesTablePage. This allocation has been observed
to sometimes fail. Move the allocation of this buffer to the
very beginning of main() to minimize the change that another
allocation is allocated from the PcdPeiServicesTablePage
address.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-01-23 04:20:47 +00:00
Nickle Wang
54c1460dd0 RedfishPkg/RedfishHttpDxe: report failure via status code
Manageability status code is introduced to edk2. Enable the ability
to report Redfish communication failure via status code. This
gives the chance for BMC to capture Redfish error.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
2025-01-22 23:58:21 +00:00
Chasel Chiu
3ba6f7d966 Maintainers.txt: add myself as UefiPayloadPkg maintainer
Add myself as UefiPayloadPkg maintainer.

Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
2025-01-22 22:20:44 +00:00
Oliver Smith-Denny
14cb48b0a0 BaseTools: Break Build on Linker Warnings
Today VS2022 and GCC are set to treat all compiler warnings as
errors and break the build. However, linker warnings for both
do not break the build. There are critical errors that can be
treated as warnings as the linker, such as not finding the
module entry point and use a default address as the entry
point. This will cause a runtime crash for something that
should be caught at build time.

This commit adds /WX to VS2022's DLINK_FLAGS and --fatal-warnings
to GCC's DLINK_FLAGS for IA32, X64, ARM, and AARCH64 in order to
break the build on linker warnings.

VS2022 linker warning 4210 is ignored for all builds because it
checks for static initializers and the linking of the VCRuntime.
edk2 never links the VCRuntime (except for HOST_APPLICATIONs) and
so the presence of static initializers will always cause this
warning, even when the edk2 code calls these initializers that
would otherwise be called in the _CRT_INIT function of the
VCRuntime. At the time of this commit, it only fails in CryptoPkg
for building OpenSSL, but could fail anywhere a static initializer
is used.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-01-22 19:47:20 +00:00
Oliver Smith-Denny
4613eb6abc EmulatorPkg: Fix IA32 MSVC Linker Warnings
IA32 EmulatorPkg had many linker warnings because with the current
set of linker flags, the MSVC linker was expecting the __stdcall
calling convention on all entry points. This was an effect of
having /SUBSYSTEM:CONSOLE on all binaries built in EmulatorPkg; this
is only needed on WinHost, as that is what Windows launches. The linker
options are adjusted to only set /SUBSYSTEM:CONSOLE on WinHost.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-01-22 19:47:20 +00:00
Oliver Smith-Denny
81ba76f7df PrmPkg: Clarify Architecture Support
Remove IA32 from supported architectures, as the MSVC build actually
fails due to the linker expecting a __stdcall calling convention.
IA32 PRMs are not supported anyway, only 64 bit OSes support PRM,
so simply drop the building of IA32 PrmPkg and clarify the README.
While there, clean up some markdown errors.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-01-22 19:47:20 +00:00
Chao Li
336e7e06eb UefiCpuPkg/CpuMpPei: Add LoongArch64 support
Added LoongArch64 CPU multiple processor PPI support.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
2025-01-22 03:57:16 +00:00
Chao Li
7bc51fc68e UefiCpuPkg/CpuMpPei: Split CpuMpPei.c to two files
CpuMpPei.c contains two parts: EFI_PEI_MP_SERVICES_PPI instance and
CpuMpPpi list installer. Move the EFI_PEI_MP_SERVICES_PPI instance in a
new file called CpuMp.c, keep the specific logic and entry point in
CpuMpPei.c, and rename the CpuMp2Pei.c to CpuMp2.c

Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
2025-01-22 03:57:16 +00:00
Khor Swee Aun
f6afd87663 UefiCpuPkg/PiSmmCpuDxeSmm: SmmWaitForApArrival first sync check
Restructured the SmmWaitForApArrival first CPU synchronization
conditional checks and added new IsCpuSyncAlwaysNeeded check to determine
whether the sync should be executed unconditionally when a SMI occurs.

The first CPU synchronization shall executed unconditionally if the new
IsCpuSyncAlwaysNeeded check return TRUE. Otherwise, first CPU
synchronization is not executed unconditionally, and the decision to
synchronize should be based on the system configuration and status.

Signed-off-by: Khor Swee Aun <swee.aun.khor@intel.com>
2025-01-22 01:22:05 +00:00
Nate DeSimone
cbfae3e8a9 EmulatorPkg: Fix Source Level Debug on Windows
The Visual Studio Windows debugger will only load symbols for PE/COFF images
that Windows is aware of. Therefore, to enable source level debugging, all
PEI/DXE modules must be loaded via LoadLibrary() or LoadLibraryEx() and the
the instance in memory created by LoadLibrary() must be the one that is
actually executed.

The current source level debug implementation in EmulatorPkg for Windows is
inherited from the old Nt32Pkg. This implementation makes the assumption that
all PEI/DXE modules have a DLL export tables with a symbol named
InitializeDriver. Therefore, this source level debug implementation requires
all modules to be linked in a non-PI spec defined manner. Support for adding
the InitializeDriver symbol was removed in EmulatorPkg, which broke source
level debugging.

To fix this, the source level debugging implementation has been modified to
use the PE/COFF entry point directly. This brings the implementation into
compliance with the PI spec and should work with any PEIM/DXE driver.
Implementing this requires parsing the in-memory instance of the PE/COFF image
created by Windows to find the entrypoint and since PEIMs/DXE drivers are not
garunteed to have 4KB aligned sections, it also requires explicit configuration
of the page table using VirtualProtect().

With this fix, the debugging experience is now so good it is unprecedented!
In Visual Studio Code, add the following to launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "EmulatorPkg Launch",
      "type": "cppvsdbg",
      "request": "launch",
      "program": "${workspaceFolder}/<path_to_build>/Build/EmulatorX64/DEBUG_<tool_chain>/X64/WinHost",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}/<path_to_build>/Build/EmulatorX64/DEBUG_<tool_chain>/X64/",
      "environment": [],
      "console": false,
    }
  ]
}

Make modifications to the above template as nessesary and build EmulatorPkg.
Now, just add breakpoints directly in Visual Studio Code the way you would with
any other software project. When you start the debugger, it will halt at the
breakpoint automatically without any extra configuration required.

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
2025-01-22 00:27:46 +00:00