summaryrefslogtreecommitdiffstats
path: root/ArmVirtPkg
diff options
context:
space:
mode:
authorSami Mujawar <sami.mujawar@arm.com>2023-05-12 09:54:34 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-05-29 15:14:00 +0000
commit8e934ab9562a33191af21ce3babf1ad37a3cdc34 (patch)
tree81bda3ff9aa78fc971bbd905fda1565bad58f0a0 /ArmVirtPkg
parent84d0b21d18db479236b6f8143eaa2e874e4efa99 (diff)
downloadedk2-8e934ab9562a33191af21ce3babf1ad37a3cdc34.tar.gz
edk2-8e934ab9562a33191af21ce3babf1ad37a3cdc34.tar.bz2
edk2-8e934ab9562a33191af21ce3babf1ad37a3cdc34.zip
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>
Diffstat (limited to 'ArmVirtPkg')
-rw-r--r--ArmVirtPkg/ArmVirtKvmTool.dsc5
-rw-r--r--ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c13
-rw-r--r--ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf4
3 files changed, 19 insertions, 3 deletions
diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc
index 25920ab4ae..4541d03d23 100644
--- a/ArmVirtPkg/ArmVirtKvmTool.dsc
+++ b/ArmVirtPkg/ArmVirtKvmTool.dsc
@@ -311,7 +311,10 @@
#
# Platform Driver
#
- ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
+ ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf {
+ <LibraryClasses>
+ NULL|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf
+ }
OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf
EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf
diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c
index 3f5027fac4..bf6fc1f1f0 100644
--- a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c
+++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c
@@ -4,7 +4,7 @@
- It decides if the firmware should expose ACPI or Device Tree-based
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
@@ -75,6 +75,17 @@ KvmtoolPlatformDxeEntryPoint (
{
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);
ASSERT_EFI_ERROR (Status);
diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
index c5bf798c3b..b0583d5205 100644
--- a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
+++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
@@ -3,7 +3,7 @@
# - It decides if the firmware should expose ACPI or Device Tree-based
# 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
#
@@ -33,10 +33,12 @@
UefiDriverEntryPoint
[Guids]
+ gEdkiiNvVarStoreFormattedGuid ## SOMETIMES_PRODUCES ## PROTOCOL
gEdkiiPlatformHasAcpiGuid ## SOMETIMES_PRODUCES ## PROTOCOL
gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL
[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi
[Depex]