edk2/MdeModulePkg/Universal/Variable/RuntimeDxe
Ard Biesheuvel 808ee1b53d MdeModulePkg/Variable: Avoid double VA conversion of FVB protocol
For historical reasons, VariableRuntimeDxe performs virtual address
conversion on the FVB protocol member pointers of the protocol instance
that backs the EFI variable store. However, the driver that produces the
actual instance should be doing this, as it is the owner and provides
the actual implementation of those methods.

Unfortunately, we cannot simply remove this: existing FVB drivers may
rely on the Variable driver performing the conversion on their behalf.
So the Variable driver should convert the pointers only when the FVB
producer has not already done so.

The SetVirtualAddressMap event can be delivered in arbitrary order, so
we cannot rely on whether this driver converts its pointers before or
after the FVB protocol owner receives the event.

Fix this by recording the converted addresses in a shadow FVB protocol
rather than converting the live pointers directly. On the first runtime
variable access, check whether the FVB producer has performed its own
conversion; if not, swap in the shadow copy's converted pointers.

Without this fix, platforms where the FVB producer performs its own
SetVirtualAddressMap conversion (e.g., OP-TEE StandaloneMm-backed
EepromFvb on NXP LX2160A) suffer double pointer conversion, causing
runtime variable access to crash.

Signed-off-by: Ard Biesheuvel <ardb+tianocore@kernel.org>
Tested-by: Liz Fong-Jones <lizf@honeycomb.io>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
2026-06-01 06:05:19 +00:00
..
RuntimeDxeUnitTest MdeModulePkg: HOST_APPLICATION IA32/X64 only 2023-04-10 05:59:02 +00:00
Measurement.c MdeModulePkg/Variable: Add TCG SPDM device measurement update 2024-04-30 02:21:13 +00:00
PrivilegePolymorphic.h MdeModulePkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Reclaim.c MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
SpeculationBarrierDxe.c MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
SpeculationBarrierSmm.c MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
TcgMorLockDxe.c MdeModulePkg: Update code to be more C11 compliant by using __func__ 2023-04-10 14:19:57 +00:00
TcgMorLockSmm.c MdeModulePkg/VariableStandaloneMm: Fix TCG MOR secure feature issue 2024-08-30 13:18:08 +00:00
VarCheck.c MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
Variable.c MdeModulePkg: Variable cumulative codeql issues. 2025-08-07 07:57:31 +00:00
Variable.h MdeModulePkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
VariableDxe.c MdeModulePkg/Variable: Avoid double VA conversion of FVB protocol 2026-06-01 06:05:19 +00:00
VariableExLib.c MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
VariableLockRequestToLock.c MdeModulePkg: Update code to be more C11 compliant by using __func__ 2023-04-10 14:19:57 +00:00
VariableNonVolatile.c MdeModulePkg/Variable: Consume Variable Flash Info 2022-05-19 06:11:20 +00:00
VariableNonVolatile.h MdeModulePkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
VariableParsing.c MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
VariableParsing.h MdeModulePkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
VariablePolicySmmDxe.c MdeModulePkg: fix various typos 2025-11-21 21:49:59 +00:00
VariableRuntimeCache.c MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
VariableRuntimeCache.h MdeModulePkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
VariableRuntimeDxe.inf MdeModulePkg/VariableRuntimeDxe: Fix VariablePolicyProtocol PRODUCES 2024-09-11 01:35:18 +00:00
VariableRuntimeDxe.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableRuntimeDxeExtra.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableSmm.c MdeModulePkg/VariableSmm: Fix NonPrimary Buffer check issue 2024-07-07 08:40:03 +00:00
VariableSmm.inf MdeModulePkg/Variable: Consume Variable Flash Info 2022-05-19 06:11:20 +00:00
VariableSmm.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableSmmExtra.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableSmmRuntimeDxe.c MdeModulePkg: VariableSmmRuntimeDxe: Fix MM communicate v3 buffer sizing 2026-03-25 17:47:59 +00:00
VariableSmmRuntimeDxe.inf MdeModulePkg: VariableSmmRuntimeDxe: Use MM communicate v3 2025-06-26 21:43:56 +00:00
VariableSmmRuntimeDxe.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableSmmRuntimeDxeExtra.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableStandaloneMm.c MdeModulePkg/VariableStandaloneMm: Notify variable write ready in MM 2024-09-02 12:43:49 +08:00
VariableStandaloneMm.inf MdeModulePkg: Remove ARM32 Support 2025-09-25 22:04:10 +00:00
VariableTraditionalMm.c MdeModulePkg/VariableStandaloneMm: Fix TCG MOR secure feature issue 2024-08-30 13:18:08 +00:00