ArmVirtPkg: Dispatch variable service if variable emulation is enabled

The VariableRuntimeDxe links with NvVarStoreFormattedLib which is
required to establish the dependency on OvmfPkg\VirtNorFlashDxe.
The VirtNorFlashDxe installs the gEdkiiNvVarStoreFormattedGuid to
indicate it has finished initialising the flash variable storage
and that the variable service can be dispatched.

However, the kvmtool guest firmware dynamically detects if CFI
flash is absent and sets PcdEmuVariableNvModeEnable to TRUE
indicating emulated runtime variable must be used. Therefore,
in this scenario install the gEdkiiNvVarStoreFormattedGuid so
that the variable service can be dispatched.

Also link the NorFlashKvmtoolLib as a NULL library so that
it can discover if the CFI flash is absent and setup the PCD
PcdEmuVariableNvModeEnable. This is required in case the
NorFlashDxe is not yet dispatched.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Sami Mujawar 2023-05-12 09:54:34 +01:00 committed by mergify[bot]
parent 84d0b21d18
commit 8e934ab956
3 changed files with 19 additions and 3 deletions

View File

@ -311,7 +311,10 @@
# #
# Platform Driver # Platform Driver
# #
ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf {
<LibraryClasses>
NULL|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf
}
OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf
EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf

View File

@ -4,7 +4,7 @@
- It decides if the firmware should expose ACPI or Device Tree-based - It decides if the firmware should expose ACPI or Device Tree-based
hardware description to the operating system. hardware description to the operating system.
Copyright (c) 2018 - 2020, ARM Limited. All rights reserved. Copyright (c) 2018 - 2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@ -75,6 +75,17 @@ KvmtoolPlatformDxeEntryPoint (
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (PcdGetBool (PcdEmuVariableNvModeEnable)) {
// The driver implementing the variable service can now be dispatched.
Status = gBS->InstallProtocolInterface (
&gImageHandle,
&gEdkiiNvVarStoreFormattedGuid,
EFI_NATIVE_INTERFACE,
NULL
);
ASSERT_EFI_ERROR (Status);
}
Status = PlatformHasAcpiDt (ImageHandle); Status = PlatformHasAcpiDt (ImageHandle);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);

View File

@ -3,7 +3,7 @@
# - It decides if the firmware should expose ACPI or Device Tree-based # - It decides if the firmware should expose ACPI or Device Tree-based
# hardware description to the operating system. # hardware description to the operating system.
# #
# Copyright (c) 2018 - 2020, ARM Limited. All rights reserved. # Copyright (c) 2018 - 2023, Arm Limited. All rights reserved.
# #
# SPDX-License-Identifier: BSD-2-Clause-Patent # SPDX-License-Identifier: BSD-2-Clause-Patent
# #
@ -33,10 +33,12 @@
UefiDriverEntryPoint UefiDriverEntryPoint
[Guids] [Guids]
gEdkiiNvVarStoreFormattedGuid ## SOMETIMES_PRODUCES ## PROTOCOL
gEdkiiPlatformHasAcpiGuid ## SOMETIMES_PRODUCES ## PROTOCOL gEdkiiPlatformHasAcpiGuid ## SOMETIMES_PRODUCES ## PROTOCOL
gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL
[Pcd] [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi
[Depex] [Depex]