summaryrefslogtreecommitdiff
path: root/OvmfPkg
AgeCommit message (Collapse)AuthorFilesLines
2024-12-17OvmfPkg: document runtime config optionsGerd Hoffmann1-0/+191
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-13OvmfPkg: Add minimum Python version for CI badgeMichael Kubacki1-1/+2
The Python version used for build and CI should always be at least the minimum version supported by edk2-pytool-extensions. A badge is added that keeps this information dynamically up-to-date based on the minimum version specified in edk2-pytool-extensions pyproject.toml file. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-12-13OvmfPkg/TdxDxe: Clear GPR Mask for RBXCeping Sun1-1/+1
Refer to intel-tdx-module-api spec section 5.5.21, GPR mask (TDVMCALL_EXPOSE_REGS_MASK) is a bitmap that controls which part of the guest TD GPR and XMM state is passed as-is to the VMM and back. - A bit value of 0 indicates that the corresponding register is saved by the Intel TDX module and not passed as-is to Host VMM. - A bit value of 1 indicates that the corresponding register is passed as-is to the host VMM. Currently, RBX is used as the mailbox address in ApRunLoop.nasm, the corresponding bit value of RBX in MASK(Bit 3) is set as 1 which means the value is passed to Host VMM as-is and it can be changed by Host VMM. So the bitmask shall be set as 0 to avoid this situation. Reference: [TDX-API]: intel-tdx-module-abi-spec https://cdrdv2.intel.com/v1/dl/getContent/733579 Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Hunter Adrian <adrian.hunter@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-12OvmfPkg: Remove macro MAX_LOONGARCH_EXCEPTIONChao Li1-6/+0
Since the UEFI 2.11 has been released, the macro MAX_LOONGARCH_EXCEPTION has been added in MdePkg, so it is deleted in LoongArchVirt/Sec/LoongArch64/Start.S Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Chao Li <lichao@loongson.cn>
2024-12-10Update CI to VS2022Oliver Smith-Denny2-4/+4
This PR updates the CI pipelines to use VS2022 instead of VS2019 as that is the latest supported VS toolchain on edk2. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2024-12-10OvmfPkg: Update PlatformPei.inf with TdxHelperLibCeping Sun7-24/+18
Since TdxHelperLib was defined in LibraryClasses for OvmfPkgX64.dsc, the extra definitions is removed. And for other dsc, add the Null-TdxHelperLib to remove the extra definitions. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-10OvmfPkg: Update OvmfPkgX64.dsc to support TdTcg2PeiCeping Sun2-0/+11
Add TdTcg2Pei in OvmfPkgX64.dsc in early PEI phase to support CC measurement. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-10OvmfPkg: Update OvmfTpmLibs.dsc.inc to add PeiTpmMeasurementLib.infCeping Sun1-0/+10
Because PeiTpmMeasurementLib supports both TCG measurement and CC measurement, it shall be controled by TPM2_ENABLE and CC_MEASUREMENT_EANBLE. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-10OvmfPkg/TdTcg2Pei: Add TdTcg2Pei to install gEdkiiCcPpiCeping Sun2-0/+246
TdTcg2Pei is added to install the gEdkiiCcPpi for a TD-Guest. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-10OvmfPkg/TdTcg2Dxe: Update with TdxHelperLibCeping Sun4-63/+18
Since TdxHelperLib has the API(TdxHelperMapPcrToMrIndex) to map PCR to MR index, the duplicate codes are removed. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-10OvmfPkg/TdxHelperLib: Refactor for new APIsCeping Sun9-55/+447
Add below APIs to support the implementation for CC measurement. - TdxHelperMapPcrToMrIndex - TdxHelperHashAndExtendToRtmr - TdxHelperBuildTdxMeasurementGuidHob Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-10OvmfPkgX64: Add BaseCryptLib definition in PEIMCeping Sun1-0/+1
Since the TdxHelperLib is used for measurement in PEI phase, it required TDVF to add the library. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-12-06OvmfPkg: disable iscsi by defaultGerd Hoffmann1-0/+1
While IScsiDxe certainly is a useful feature it is rarely used, and it slows down firmware boot quite a bit. So disable it by default and only load it in case this is explicitly requested via fw_cfg. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-06OvmfPkg: add PcdEntryPointOverrideDefaultValueGerd Hoffmann3-1/+19
UefiDriverEntryPointFwCfgOverrideLib will use PcdEntryPointOverrideDefaultValue to decide what to do in case the fw_cfg file specified via PcdEntryPointOverrideFwCfgVarName is not present. Default is "yes". This allows to disable drivers by default and only enable them when requested via fw_cfg. Also log a message with the config option applied and whenever the default value or a fw_cfg option was used. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-06OvmfPkg: add fw_cfg option for usb storageGerd Hoffmann1-1/+6
Use UefiDriverEntryPointFwCfgOverrideLib for UsbMassStorageDxe so the driver can be enabled/disabled via fw_cfg option. usage: qemu -fw_cfg name=opt/org.tianocore/UsbStorageSupport,string={yes,no} Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-06OvmfPkg: add fw_cfg option for iscsi supportGerd Hoffmann1-0/+9
Use UefiDriverEntryPointFwCfgOverrideLib for IScsiDxe so the driver can be enabled/disabled via fw_cfg option. usage: qemu -fw_cfg name=opt/org.tianocore/ISCSISupport,string={yes,no} Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-06OvmfPkg: add fw_cfg option for virtio-net supportGerd Hoffmann1-1/+6
Use UefiDriverEntryPointFwCfgOverrideLib for VirtioNetDxe so the driver can be enabled/disabled via fw_cfg option. usage: qemu -fw_cfg name=opt/org.tianocore/VirtioNetSupport,string={yes,no} Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-06OvmfPkg: move USB drivers to new UsbComponents.dsc.incGerd Hoffmann4-33/+15
Allows to update USB driver configuration without touching all *.dsc files. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-06OvmfPkg: move VirtioNet to NetworkComponents.dsc.incGerd Hoffmann6-10/+3
Allows to update VirtioNet driver configuration without touching all *.dsc files. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-06OvmfPkg: PXE boot option build flagAlexander Gryanko8-4/+17
The second step is to add an option to the OvmfPkg module to disable PXE booting using the NETWORK_PXE_BOOT_ENABLE flag. The patch is divided into 3 parts. At the current stage the flag is not functional. Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2024-12-04OvmfPkg/QemuFwCfgDxeLib: use PcdConfidentialComputingGuestAttrGerd Hoffmann2-4/+9
Check PcdConfidentialComputingGuestAttr instead of calling MemEncryptSevIsEnabled() and MemEncryptTdxIsEnabled() to figure whenever SEV or TDX is enabled. This allows to remove the MemEncryptSevLib + MemEncryptTdxLib dependencies. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-12-03OvmfPkg: Update links to Intel & MS ACPI compilers in READMERebecca Cran1-3/+5
Intel's ACPICA download is no longer on acpica.org, but that site redirects to pages on intel.com. Update the link to acpica.org to the new ACPICA download page. Microsoft's acpi.info no longer exists, so update the link to point to Microsoft's ACPI compiler information page. While here, update the nasm link from http to https. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2024-11-27OvmfPkg/Library/HardwareInfoLib: Fix memory allocation for a root bridgeAlexander Gryanko1-0/+6
Currently, PciHostBridgeUtilityGetRootBridgesHostProvided allocates memory for aperture structures without clearing memory. This causes garbage in the Translation field, but the Base and Limit fields have the correct values because they are copied from the HOST_BRIDGE_INFO fields in the HardwareInfoPciHostBridgeHostBridgeHostBridgeGetApertures function. RootBridge: PciRoot(0x0) Support/Attr: 70069 / 70069 DmaAbove4G: No NoExtConfSpace: No AllocAttr: 3 (CombineMemPMem Mem64Decode) Bus: 0 - 80 Translation=0 Io: 6000 - FFFF Translation=5E9EB018 Mem: 80000000 - DFFFFFFF Translation=0 MemAbove4G: 600000000000 - 7FFFFFFFFFFF Translation=0 PMem: FFFFFFFFFFFFFFFF - 0 Translation=0 PMemAbove4G: FFFFFFFFFFFFFFFF - 0 Translation=0 Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2024-11-27OvmfPkg/QemuVideoDxe: Clean up Non-Used PCDsMarc Chen1-2/+0
Clean up PcdOvmfHostBridgePciDevId and PcdNullPointerDetectionPropertyMask from QemuVideoDxe.inf Signed-off-by: Marc Chen <marc.chen@microsoft.com>
2024-11-27OvmfPkg: Rerun dispatcher after initializing virtio-rngOliver Steffen1-0/+2
Since the pixiefail CVE fix the network stack requires a hardware random number generator. This can currently be a modern CPU supporting the RDRAND instruction or a virtio-rng device. The latter is initialized during the BDS phase. To ensure all depending (network) modules are also started, we need to run the dispatcher once more after the device was initialized. Without this, network boot is not available under certain hardware configurations. Fixes: 4c4ceb2ceb ("NetworkPkg: SECURITY PATCH CVE-2023-45237") Analysed-by: Stefano Garzarella <sgarzare@redhat.com> Suggested-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Oliver Steffen <osteffen@redhat.com>
2024-11-25OvmfPkg/PlatformInitLib: enable x2apic mode if neededGerd Hoffmann2-0/+7
Enable x2apic mode in case the number of possible CPUs (including hotplug-able CPus which are not (yet) online) is larger than 255. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-11-23OvmfPkg/EmuVariableFvbRuntimeDxe: Issue NV vars initializitation messageTom Lendacky1-0/+2
Add a debug message that indicates when the NV variables are being initialized through the template structure. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
2024-11-23OvmfPkg/PlatformInitLib: Retry NV vars FV check as sharedTom Lendacky2-2/+31
When OVMF is built with SECURE_BOOT_ENABLE, the variable store will be populated and validated in PlatformValidateNvVarStore(). When an SEV or an SEV-ES guest is running, this may be encrypted or unencrypted depending on how the guest was started. If the guest was started with the combined code and variable contents (OVMF.fd), then the variable store will be encrypted. If the guest was started with the separate code and variables contents (OVMF_CODE.fd and OVMF_VARS.fd), then the variable store will be unencrypted. When PlatformValidateNvVarStore() is first invoked, the variable store area is initially mapped encrypted, which may or may not pass the variable validation step depending how the guest was launched. To accomodate this, retry the validation step on failure after remapping the variable store area as unencrypted. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
2024-11-23OvmfPkg/PlatformPei: Move NV vars init to after SEV-SNP memory acceptanceTom Lendacky1-4/+10
When OVMF is built with the SECURE_BOOT_ENABLE set to true, reserving and initializing the emulated variable store happens before memory has been accepted under SEV-SNP. This results in a #VC exception for accessing memory that hasn't been validated (error code 0x404). The #VC handler treats this error code as a fatal error, causing the OVMF boot to fail. Move the call to ReserveEmuVariableNvStore() to after memory has been accepted by AmdSevInitialize(). Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
2024-11-23OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Do not use flash with SEV-SNPTom Lendacky1-0/+8
SEV-SNP does not support the use of the Qemu flash device as SEV-SNP guests are started using the Qemu -bios option instead of the Qemu -drive if=pflash option. Perform runtime detection of SEV-SNP and exit early from the Qemu flash device initialization, indicating the Qemu flash device is not present. SEV-SNP guests will use the emulated variable support. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
2024-11-13MdePkg: MdeLibs.dsc.inc: Apply StackCheckLibNull to All Module TypesOliver Smith-Denny11-25/+0
Now that the ResetVectors are USER_DEFINED modules, they will not be linked against StackCheckLibNull, which were the only modules causing issues. So, we can now remove the kludge we had before and the requirement for every DSC to include StackCheckLibNull for SEC modules and just apply StackCheckLibNull globally. This also changes every DSC to drop the SEC definition of StackCheckLibNull. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-11-13OvmfPkg: Make ResetVector USER_DEFINEDOliver Smith-Denny12-12/+12
Following the change in UefiCpuPkg, this moves OvmfPkg's ResetVectors to USER_DEFINED modules to prevent any NULL libraries from being linked against them, allowing for expected behavior from the ResetVector and for simpler implementation of NULL libraries applied globally. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-11-11OvmfPkg: mark fixed network PCDsAleksandr Goncharov8-8/+8
Rename `NetworkPcds` to `NetworkFixedPcds` to avoid confusion with dynamic PCDs Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Jianyong Wu <jianyong.wu@arm.com> Cc: Anatol Belski <anbelski@linux.microsoft.com> Cc: Sunil V L <sunilvl@ventanamicro.com> Cc: Andrei Warkentin <andrei.warkentin@intel.com> Cc: Chao Li <lichao@loongson.cn> Cc: Bibo Mao <maobibo@loongson.cn> Cc: Xianglai Li <lixianglai@loongson.cn> Signed-off-by: Aleksandr Goncharov <chat@joursoir.net>
2024-11-11OvmfPkg: use NetworkDynamicPcds include fileAleksandr Goncharov7-39/+7
Start using the include file in the OvmfPkg package to manage dynamic network-related PCDs. This change removes the manual addition of `PcdIPv4PXESupport` and `PcdIPv6PXESupport` from the DSC file, relying instead on the centralized include file introduced in NetworkPkg. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Jianyong Wu <jianyong.wu@arm.com> Cc: Anatol Belski <anbelski@linux.microsoft.com> Cc: Sunil V L <sunilvl@ventanamicro.com> Cc: Andrei Warkentin <andrei.warkentin@intel.com> Cc: Chao Li <lichao@loongson.cn> Cc: Bibo Mao <maobibo@loongson.cn> Cc: Xianglai Li <lixianglai@loongson.cn> Signed-off-by: Aleksandr Goncharov <chat@joursoir.net>
2024-10-12OvmfPkg/Library: Impl SmmCpuPlatformHookBeforeMmiHandler funcJiaxin Wu1-1/+19
This patch is to add SmmCpuPlatformHookBeforeMmiHandler func for OVMF. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
2024-10-04OvmfPkg: RiscV64: build BaseRiscVFpuLibHeinrich Schuchardt1-0/+1
Enable building the BaseRiscVFpuLib library for OvmfPkg to * Enable the FPU and set it to state 'dirty'. * Clear the fcsr CSR. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-09-13OvmfPkg/CpuHotplugSmm: delay SMM exitGerd Hoffmann1-0/+5
Let APs wait until the BSP has completed the register updates to remove the CPU. This makes sure all APs stay in SMM mode until the CPU hot-unplug operation is complete, which in turn makes sure the ACPI lock is released only after the CPU hot-unplug operation is complete. Some background: The CPU hotplug SMI is triggered from an ACPI function which is protected by an ACPI lock. The ACPI function is in the ACPI tables generated by qemu. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-09-13OvmfPkg: Use TdInfo instead of fw_cfg to get cpu count in TDVFCeping Sun3-2/+16
Currently TDVF gets cpu count information via fw_cfg, but this information can also be retrieved by calling of TdCall.TdInfo. And TdCall is responded by tdx-module which is trust. So, from the security perspective we shall use TdCall.Tdinfo instead of fw_cfg. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-09-13OvmfPkg/RiscVVirtQemu: Remove non-needed !include lineMike Beaton1-1/+0
RiscVVirt.dsc.inc includes NetworkPkg/NetworkLibs.dsc.inc. However RiscVVirt.dsc.inc is only ever included by RiscVVirtQemu.dsc, which has already included NetworkPkg/Network.dsc.inc, a general include file which brings in all the required includes for Network features at once, including NetworkPkg/NetworkLibs.dsc.inc. Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2024-09-13OvmfPkg: Add StackCheckLibNullOliver Smith-Denny11-7/+25
Remove the old stack check lib now that MdeLibs.inc includes the new one. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-12OvmfPkg: Fix unable to build OVMF with -D NETWORK_ENABLE=0Mike Beaton7-0/+14
https://bugzilla.tianocore.org/show_bug.cgi?id=4829 7f17a15 (2024/02/22) "OvmfPkg: Shell*.inc: allow building without network support" breaks building OVMF with `-D NETWORK_ENABLE=0`. Before this commit we could build OVMF e.g. with the following command in the OvmfPkg directory: ./build.sh -D NETWORK_ENABLE=0 After the commit the same command fails early with: /home/user/OpenSource/edk2/OvmfPkg/OvmfPkgX64.dsc(15): error F001: Pcd (gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections) defined in DSC is not declared in DEC files referenced in INF files in FDF. Arch: ['X64'] The problem applies in Intel OvmfPkg platforms. Additionally, it applies in various other OvmfPkg platforms, but is masked buy another issue; namely that these platforms incorrectly still include some network packages when most are disabled. (A fix for that issue has previously been made, in OvmfPkg Intel platforms only, by d933ec1 followed by 7f17a15 .) This commit conditionally removes the undefined Pcd references in all OvmfPkg platforms which are now affected by this issue, and in all those which would be affected as and when the other issue mentioned above is fixed. Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2024-09-12OvmfPkg/LoongArchVirt: Modify loongarch uefi firmware sizeXianglai Li1-11/+1
After the loongarch flash block size is changed from 128K to 256K, qemu requires that the UEFI firmware size be aligned with the flash block size(256K). Otherwise, the firmware cannot be loaded, Use the following code to resolve the old firmware loading problem: mv QEMU_EFI.fd QEMU_EFI.fd-bak cat QEMU_EFI.fd-bak /dev/zero | head -c 16m > ./QEMU_EFI.fd mv QEMU_VARS.fd QEMU_VARS.fd-bak cat QEMU_VARS.fd-bak /dev/zero | head -c 16m > ./QEMU_VARS.fd For the new firmware, we refer to other architecture UEFI and set the UEFI firmware size to align with the flash block size(256K). So for this patch, we set the UEFI firmware size to 256K alignment. Cc: Bibo Mao <maobibo@loongson.cn> Cc: Chao Li <lichao@loongson.cn> Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
2024-09-09OvmfPkg/QemuFwCfgS3Lib: Disable S3 detection in TDVFCeping Sun1-0/+5
Refer to the section 2.1 of tdx-virtual-firmware-design-guide spec, APCI S3 is not supported in TDVF. Therefore, TDVF should not read the S3 status via fw_cfg and always set it as unsupported. spec: https://cdrdv2.intel.com/v1/dl/getContent/733585 Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-09-03OvmfPkg/PlatformPei: Build gCcEventEntryHobGuid at FirstCeping Sun4-4/+13
Since the PEI Hob service is ready after PEIM loaded, TDVF should build the Hob for TdHob and Cfv event at first. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-09-03OvmfPkg: Use TdHob instead of e820tables to get memory info in TDVFCeping Sun1-0/+34
Currently, TDVF gets LowMemory and FistNonAddress from the e820tables via fw_cfg, while TD-Hob can also provide the memory info of LowMemory and FistNonAddress. In current stage e820tables are not measured but TD-Hob is measured in early phase by TDVF. So, from the security perspective we'd better use the information from TD-Hob instead of e820tables. Cc: Erdem Aktas <erdemaktas@google.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Min Xu <min.m.xu@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
2024-08-31OvmfPkg: Move kernel hashes section to endDionna Glaze1-5/+6
When launching a SEV-SNP VM, the ROM is not all that must be measured. The OvmfSevMetadata sections describe ranges of memory that must be measured with different types than PAGE_TYPE_NORMAL, except one. The SevSnpKernelHashes page is also PAGE_TYPE_NORMAL, but is populated by the VMM from configuration data that is separate from the OVMF build itself. To more compactly provide reference values for the measurement of the firmware separately from the kernel hashes, it's advantageous to measure as much known information as possible first. Whereas VMMs are permitted to measure these sections in any order they prefer, the normative order of how they appear in the .fd is easiest to follow. This change is semantics-preserving. Measurement calculation tools that do not follow the normative ordering would need updating to accommodate, but I don't know of any. The accounting for EC2 moving the CPUID page to the end of measurement would be unchanged. This change is to improve performance of a proposed launch update event log to separate responsibility for initially measured data before VM launch, application/vnd.amd.sevsnp.launch-updates+cbor: https://github.com/deeglaze/draft-deeglaze-amd-sev-snp-corim-profile Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
2024-08-30OvmfPkg/PlatformInitLib: allow switching to 4-level pagingGerd Hoffmann3-0/+185
There are a number of mostly older guests such as RHEL-7 which do not support 5-level paging. This patch adds support for switching from 5-level paging mode back to 4-level paging mode. This is done in PEI, after inspecting the address space needed (installed memory and reservations configured via fw_cfg). By default small guests (which need less than 1 TB) will use 4-level paging mode. There is a fw_cfg override though, so it is possible to force the one or the other this way: qemu-system-x86_64 -fw_cfg name=opt/org.tianocode/PagingLevel,string=5 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2024-08-30OvmfPkg: Using the new name of LoongArch CSR 0x20 registerChao Li1-1/+1
Since the LoongArch SPEC has adjusted the CSR 0x20 register name and the MdePkg also added the new name, so enable it in OvmfPkg. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Chao Li <lichao@loongson.cn>
2024-08-30OvmfPkg/OvmfXen: Introduce Xen's ResetSystemLib, to use xen hypercallAnthony PERARD5-5/+234
When booting OvmfXen, the ACPI interface for shutdown/reset might not be available, instead use the hypercall interface. While it's probably possible to use the hypercall in all cases, we keep using the same interface while it still possible. That is ACPI on HVM guest, and fallback to hypercall on PVH guest. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
2024-08-30OvmfPkg/XenHypercallLib: Add SchedOp hypercallAnthony PERARD4-1/+73
Add a new function to allow to make an hypercall to shutdown the machine. This import "sched.h" public header from Xen Project's repo. Some changes have been made to be closer to EDK2's coding style. Add the entire OvmfPkg/Include/IndustryStandard/Xen/ directory to LicenseCheck ignore. All the existing header files, as well as the new sched.h, are MIT licensed. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>