Commit Graph

2834 Commits

Author SHA1 Message Date
Laszlo Ersek
43d696a366 OvmfPkg/CpuHotplugSmm: hook up MSR_IA32_FEATURE_CONTROL with platform info
Map the feature control MSR config from the OVMF platform info HOB to
FIRST_SMI_HANDLER_CONTEXT.

(Note that CpuHotplugSmm already consumes -- indirectly -- the
"MdePkg/Library/DxeHobLib/DxeHobLib.inf" library instance, according to
the build report; therefore adding an explicit HobLib class dependency
shouldn't *generally* increase this SMM driver's exposure. The consumed
lib instances are the same before and after this patch, at least in
"OvmfPkgIa32X64.dsc".)

Fixes: https://github.com/tianocore/edk2/issues/11188
Signed-off-by: Laszlo Ersek <laszlo.ersek@posteo.net>
2025-07-23 12:10:11 +02:00
Laszlo Ersek
0e814e829e OvmfPkg/CpuHotplugSmm: set MSR_IA32_FEATURE_CONTROL in first SMI handler
Introduce new fields to FIRST_SMI_HANDLER_CONTEXT:

- a UINT8 (effectively: boolean) value that controls whether the first SMI
  handler of the hot-added CPU is supposed to set
  MSR_IA32_FEATURE_CONTROL,

- and for when that is the case, two UINT32 values, for passing the
  desired EDX:EAX (64-bit) MSR value.

MSR_IA32_FEATURE_CONTROL might as well be settable in the post-SMM pen
("PostSmmPen.nasm"); however, I find the first SMI handler better for this
purpose:

- we already have a nice context structure we can extend,

- in SMM, we have tighter control than after SMM (see the comments near
  the top of "PostSmmPen.nasm").

MSR_IA32_FEATURE_CONTROL is orthogonal to the SMRAM State Save Map, and
WRMSR is permitted in the real mode-like initial environment of SMM, so
functionally speaking, this should be fine.

For now, the feature is disabled.

Signed-off-by: Laszlo Ersek <laszlo.ersek@posteo.net>
2025-07-23 12:10:11 +02:00
Laszlo Ersek
f92ba13a66 OvmfPkg/CpuHotplugSmm: add whitespace
In a subsequent patch, we'll introduce fields with long names to
"FIRST_SMI_HANDLER_CONTEXT". Make room for those field names in
"FirstSmiHandler.nasm".

"git show -b" produces no patch output for this commit.

Signed-off-by: Laszlo Ersek <laszlo.ersek@posteo.net>
2025-07-23 12:10:11 +02:00
Laszlo Ersek
c37e2d38d6 OvmfPkg/PlatformPei: record "etc/msr_feature_control" presence explicitly
A zero "FeatureControlValue" currently means "no feature control, or
feature control with zero value". Distinguish both cases by explicitly
recording the presence of the "etc/msr_feature_control" fw_cfg file. This
will be helpful later in this series, when we won't want to touch fw_cfg
again, but still know if "etc/msr_feature_control" was read OK.

Signed-off-by: Laszlo Ersek <laszlo.ersek@posteo.net>
2025-07-23 12:10:11 +02:00
Tuan Phan
04fe3f50d6 OvmfPkg/RiscVVirt: Adopt New CpuExceptionHandlerLib
Utilize the updated CpuExceptionHandlerLib, which now includes
RISC-V support.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-07-23 04:51:54 +00:00
Tuan Phan
3a06b5dac9 OvmfPkg/RiscVVirt/PlatformSecLib: Clear s0 (fp) at entry point
Scrub s0 (fp) to prevent stack tracing from extending beyond the Sec code.

Signed-off-by: Andrei Warkentin <andrei.warkentin@intel.com>
2025-07-23 04:51:54 +00:00
Dionna Glaze
9c38295325 OvmfPkg: Clarify Is800155Event
The Event3 memory comparison is technically correct since the
definitions of the struct types are the same. The extended
bodies of the events are different. The Event2 size guard
for the Event3 comparison should be split to use the Event3
in its sizeof for better clarity.

The large single condition makes the function difficult to
understand, so the combined logic is split into different
conditional statements.

Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
2025-07-21 05:07:41 +00:00
Ivan A. Melnikov
4cb3e8d467 OvmfPkg/LoongArchVirt: Add SATA support
SATA CD-ROMS are still conventionally used in many
virtual environments, so it's nice to support them
out of the box.

Tested with QEMU 9.2.3 with the following controller
and drive:

  qemu-system-loongarch64 -M virt [...]  \
    -device ahci,id=ahci0,multifunction=on,bus=pcie.0,addr=0x7 \
    -drive if=none,id=drive-sata2,media=cdrom,format=raw,aio=threads,file=/path/to/bootable.iso \
    -device ide-cd,bus=ahci0.2,drive=drive-sata2,id=sata2,bootindex=102

Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
2025-07-16 11:32:11 +00:00
Gerd Hoffmann
29477c2045 OvmfPkg/AmdSvsmLib: add AmdSvsmQueryProtocol
AmdSvsmQueryProtocol() is a helper function for QUERY_PROTOCOL
calls of the core svsm protocol.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-16 00:09:22 +00:00
Tuan Phan
ac20e4398a OvmfPkg/RiscVVirt: Add PEI phase booting support
Introduce a switch to select between PEI and PEI less booting modes.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-07-15 05:45:15 +00:00
Tuan Phan
003c888714 OvmfPkg/RiscVVirt: Add PlatformPeim module
Introduce PEIM module to support platform initialization during the
PEI phase.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-07-15 05:45:15 +00:00
Tuan Phan
07552c31ad OvmfPkg/RiscVVirt: PrePiHobListPointerLib: Use scratch register directly
With firmware context APIs removed, store HobList pointer directly in the
scratch register for Peiless booting.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-07-15 05:45:15 +00:00
Tuan Phan
977b68aa1e OvmfPkg/RiscVVirt: Add PlatformSecLib library
Create PlatformSecLib library to support both PEIless and PEI booting
modes.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-07-15 05:45:15 +00:00
Tuan Phan
f53f943b59 OvmfPkg/RiscVVirt: Unlink BaseRiscVFpuLib
BaseRiscVFpuLib is deprecated.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-07-15 05:45:15 +00:00
Michael Kubacki
965a754f19 Revert "OvmfPkg: Pass command-line args to PR Eval"
A change was made to the following pytool releases to prevent a
platform from needing to include additional logic to consider
command-line build variable parameters for PR evaluation.

- edk2-pytool-library v0.23.4
- edk2-pytool-extensions v0.29.11

Commit 33e58db was added as a workaround, but that is no longer
needed after these pytool updates, so revert it.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-07-09 18:09:59 +00:00
Akshay Behl
6cb0553387 OvmfPkg/RiscVVirt: Remove unnecessary PCD
Signed-off-by: Akshay Behl <cap2k4@rivosinc.com>

Co-authored-by: Dhaval Sharma <dhaval@rivosinc.com>
2025-07-08 18:35:46 +00:00
GuoMinJ
282d6962e4 OvmfPkg: Remove UGA support
The Universal Graphics Adapter (UGA) is a graphic abstraction.
The UGA I/O and Draw protocols are deprecated since UEFI 2.0 was
introduced. Cf. the UEFI spec v2.9:
"Appendix L - EFI 1.10 Protocol Changes and Deprecation List"
section L.2 "Deprecated Protocols"

Remove the UGA support.

Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-08 15:42:03 +00:00
Gerd Hoffmann
5090c39a59 OvmfPkg/PlatformDxe: register log buffer as efi config table
If a memory debug log buffer is present, register the buffer location as
config table so the OS can find and show it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-08 09:04:59 +00:00
Luigi Leonardi
fb55173551 OvmfPkg/PlatformDebugLibIoPort: Add check for MemDebugLogWrite
This check is present for every call to `MemDebugLogWrite` but it is
missing here. This may cause an unwanted write to the
buffer, when the buffer's address is not null and MemDebug is disabled.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2025-07-08 06:04:46 +00:00
Michael Kubacki
33e58db9e2 OvmfPkg: Pass command-line args to PR Eval
Allow PR eval to operate with the same input variable values as the
build command would.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-07-08 14:50:33 +10:00
Oliver Smith-Denny
83b30736bf OvmfPkg: Don't Allocate Page 0
OvmfPkg has copied the MdeModulePkg DxeIpl behavior to
create a memory allocation HOB for page 0. That is being changed
(see that commit for details), so also remove it here.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-07-08 03:45:09 +00:00
Gerd Hoffmann
ef1d2fb8d6 OvmfPkg: add qemu vars documentation
Add documentation for the qemu uefi variable store.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-08 01:48:36 +00:00
Gerd Hoffmann
f4f14b8d7e OvmfPkg/VirtMmCommunicationDxe: better usage hint
Print per-arch help lines with qemu usage information.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-08 01:48:36 +00:00
Gerd Hoffmann
2e236ea148 OvmfPkg/RiscVVirt: enable qemu uefi variable store support
Add QEMU_PV_VARS build option, when enables the firmware build will
support (and require) the qemu uefi variable store.

This also enables proper (as-in: actually being secure) secure boot
support.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-08 01:48:36 +00:00
Gerd Hoffmann
2dfaf135f1 OvmfPkg/VirtMmCommunicationDxe: enable riscv64
Add RISCV64 support.  Configuration is identical to AARCH64.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-08 01:48:36 +00:00
Gerd Hoffmann
765d5e1c54 OvmfPkg/VirtMmCommunicationDxe: limit to 64-bit archs
32-bit architecture (ia32 + arm) are not supported.  Update inf file
accordingly.  Add a VALID_ARCHITECTURES line.  Drop ARM configuration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-08 01:48:36 +00:00
Gerd Hoffmann
0b0d6e42f4 OvmfPkg: add runtime switch for sdcard support
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Gerd Hoffmann
a3c6636d1e OvmfPkg: add sdcard support
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Gerd Hoffmann
3798da443e OvmfPkg: switch IntelTdx to OptHw include files.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Gerd Hoffmann
57b9a6235c OvmfPkg: switch AmdSev to OptHw include files.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Gerd Hoffmann
391e350cec OvmfPkg: switch CloudHw to OptHw include files.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Gerd Hoffmann
fceccd3eda OvmfPkg: switch OvmfPkgIa32 to OptHw include files.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Gerd Hoffmann
55b48c85a8 OvmfPkg: switch OvmfPkgIa32X64 to OptHw include files.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Gerd Hoffmann
faf600ccc7 OvmfPkg: move scsi drivers to new OptHw include files
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-07-04 13:44:21 +00:00
Abdul Lateef Attar
727ba13d3e OvmfPkg: Correct spelling errors and typos
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
2025-07-04 09:41:47 +08:00
Tuan Phan
5925977a4e OvmfPkg/RiscVVirt: Add support for Capsule Firmware Upgrade
This patch introduces support for firmware upgrades using the
FMP capsule update mechanism.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-06-25 04:23:40 +00:00
Tuan Phan
6fff3da225 OvmfPkg/VirtNorFlash: Move low level NOR flash functions into library
This patch refactors low level NOR flash functions into a dedicated library
to enable reuse, particularly for supporting the firmware upgrade feature.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-06-25 04:23:40 +00:00
Tuan Phan
e64983d53d OvmfPkg/VirtNorFlash: Refactor TPL handling outside NOR flash functions
To facilitate moving the NOR flash functions into a separate library,
TPL handling is now delegated to the caller.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-06-25 04:23:40 +00:00
Ceping Sun
92c714f8b7 OvmfPkg/TdxDxe: Support 5-level paging for ResetVector
Since OVMF already supports 5-level paging, the ResetVector
needs to handle the case.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2025-06-20 10:23:42 +08:00
Ceping Sun
406f42cb74 OvmfPkg: Add the ResetVector in TDX MailBox
Base on ACPI 6.6 Multiprocessor Wakeup Structure, TDVF needs to provide
a physical address of the ResetVector to OS. And it should allow the
Multiprocessor Wakeup Mailbox to be reset in order to be used once again
with a given AP.

Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
2025-06-20 10:23:42 +08:00
Ceping Sun
41aaecbf59 OvmfPkg: Add the Test command in TDX MailBox
Base on  ACPI 6.6 MultiProcessor Wakeup Mailbox Structure,
the new "Test" command is added.

Also the "Sleep" command is not used in TDX Mailbox, it should be removed.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2025-06-20 10:23:42 +08:00
Ceping Sun
8d22d1c288 OvmfPkg/WorkArea.h: Add MAILBOX_GDT
Add the GDT table to swicth paging mode when the OS jumps
to the ResetVector in Mailbox.

Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
2025-06-20 10:23:42 +08:00
Kun Qin
e4e29690f1 OvmfPkg: README: Add documentation for Standalone MM on OVMF
This update introduces a new section in the README file, detailing the
design considerations of the recently onboarded Standalone MM platform in
OVMF.

The section is intended for future reference and should be revised
accordingly if updates to the Standalone MM framework render these
limitations obsolete.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00
Kun Qin
b25c1aa090 OvmfPkg: PlatformCI: Ovmf x64 platform with Standalone MM
This change expands the CI pipeline build to a new platform type with
Standalone MM support to ensure the incoming change works with Standalone
MM environment on x64 platforms.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00
Kun Qin
e8fe2e83f1 OvmfPkg: OvmfPkgX64: Platform changes for Standalone MM support
This change adds a build flag in the platform DSC file to support
standalone MM build on OVMF platform.

The new standalone MM platform will not support S3 boot and thus no SMM
lock box related components are included.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00
Kun Qin
00ee4b57f8 OvmfPkg: MmPlatformHobProducerLibOvmf: Ovmf specific HOB creators for Stmm
This change introduces a platform specific HOB producor library to meet
the expectation of Standalone MM core.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00
Kun Qin
187761e05d OvmfPkg: MemEncryptSevLib: Add Null instance
This change introduces a Null instance of MemEncryptSevLib to enable
platforms that do not have confidential compute support.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00
Kun Qin
4ea31ba020 OvmfPkg: QemuFlashFvbServices: Introduce Standalone MM instance
This update introduces the implementation of QemuFlashFvbServices to
support operation with Standalone MM backed platforms.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00
Kun Qin
aedcb46e6f OvmfPkg: QemuFlashFvbServicesRuntimeDxe: Abstract out SMM/DXE functions
This update refactors QemuFlashFvbServicesRuntimeDxe to abstract out
direct calls to SMM and DXE specific functions.

Specifically, dynamic PCD usage and gBS references have been moved to SMM
specific files.

The constructor functionality has been relocated to a common
implementation and is invoked from their respective entry points.

These changes lay the groundwork for supporting a Standalone MM-based
solution in the future.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00
Kun Qin
cf4534c9da OvmfPkg: SmmControl2Dxe: Avoid double initialization
This change adds a build time PCD to prevent the SmmControl2Dxe driver
from re-initialization the MM related registers.

This register is to be used when MmControlPei is already executed in PEI
phase and completed setting up the MM control registers.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-06-19 06:17:18 +00:00