Reporting Issues
Bug 386 - no PEI phase variable driver in OVMF platform
Summary: no PEI phase variable driver in OVMF platform
Status: RESOLVED FIXED
Alias: None
Product: EDK2
Classification: Unclassified
Component: Code (show other bugs)
Version: Current
Hardware: All All
: Normal normal
Assignee: Laszlo Ersek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-17 00:19 UTC by Rocky
Modified: 2020-05-08 07:47 UTC (History)
2 users (show)

See Also:
EDK II Code First industry standard specifications: ---
Branch URL:
Release(s) the issue is observed: EDK II Master
The OS the target platform is running: ---
Package: OvmfPkg
Release(s) the issues must be fixed: EDK II Master
Tianocore documents:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rocky 2017-02-17 00:19:08 UTC
I find there is no variable driver in ovmf, can we add this driver in ovmf?
Comment 1 Rocky 2017-02-17 00:38:17 UTC
Just clarification, no Variable driver found in PEI phase.
Comment 2 Laszlo Ersek 2017-02-17 07:58:19 UTC
It is correct, OVMF does not pull in the read-only variable driver PEIM.

What do you need it for?

Currently, OVMF has no need to read any variables in the PEI phase. If you have an OVMF feature or enhancement in mind, for upstream OvmfPkg/, that requires r/o variable access in the PEI phase, we can consider pulling in the PEIM.

Otherwise, without an actual use case / client in the PEI phase, I don't think it should be pulled in.

For example, if you have a PEIM that needs read access to variables, but you don't want to upstream that PEIM to upstream OvmfPkg/OvmfPkg*.dsc, then I think the variable PEIM should also be pulled in only in your local test environment.

Thanks.
Comment 3 Rocky 2017-02-21 00:21:19 UTC
I plan to use OvmfPkg do some PEI test. the test cases will read Variable Pei. Thanks!
Comment 4 Laszlo Ersek 2017-02-21 03:53:05 UTC
Thanks for confirming. In this case, as I proposed above, given that the dependent PEIMs will not be upstreamed, for the long term, to OvmfPkg in edk2, please pull in VariablePei too in your local test environment (where you add the PEIMs meant to be tested to the DSC / FDF files anyway).

Thus, I'm closing this as INVALID -- without a direct / long term client for VariablePei, we should avoid fattening OVMF. The FV / FD space is quite scarce. I hope this is alright with you. Thanks!
Comment 5 Laszlo Ersek 2017-03-14 17:32:45 UTC
I'm reopening this bug, because we have found an upstreamable use case for the variable PEIM -- UEFI memmap defragmentation.
Comment 6 Laszlo Ersek 2017-03-14 19:33:37 UTC
This is being addressed as part of the following series:

Subject: [PATCH 00/14] OvmfPkg: add the Variable PEIM, defragment the UEFI memmap
Message-Id: <20170314233246.17864-1-lersek@redhat.com>
URL: https://lists.01.org/pipermail/edk2-devel/2017-March/008525.html
Comment 7 Laszlo Ersek 2017-05-05 13:08:59 UTC
Postponing this for now.
Comment 8 Laszlo Ersek 2017-07-14 12:40:16 UTC
See also
https://lists.01.org/pipermail/edk2-devel/2017-March/009049.html
Comment 9 Laszlo Ersek 2017-11-30 11:33:26 UTC
v2:
[edk2] [PATCH v2 0/8] OvmfPkg: add the Variable PEIM,
                      defragment the UEFI memmap
https://lists.01.org/pipermail/edk2-devel/2017-November/018305.html
http://mid.mail-archive.com/20171130163029.19743-1-lersek@redhat.com
Comment 10 Laszlo Ersek 2017-12-01 06:56:31 UTC
I'd like to close this as WONTFIX, but given that it blocks bug 594, I'm only moving it back to CONFIRMED.
Comment 11 Laszlo Ersek 2018-09-12 16:00:59 UTC
Bug 594, which used to depend on this one, got ultimately solved without a dependency on PEI phase variable access. Many thanks to Marc-André Lureau and Stefan Berger again for that work.

With bug 594 solved, and S4 support being practically irrelevant, there's no need to keep this BZ open. I'll be privately carrying the patches that I posted earlier.
Comment 12 Laszlo Ersek 2019-08-23 08:37:47 UTC
Reopening, with a dependency on bug 2122. With OvmfPkg/OvmfPkg*.dsc officially lacking Xen support (in favor of OvmfPkg/OvmfXen.dsc), the patches posted earlier for this BZ should not affect Xen in any observable way, and should no longer be rejeced.

http://mid.mail-archive.com/46ef6b76-568e-75e8-fe72-c09dfe584158@redhat.com
https://edk2.groups.io/g/devel/message/46210
Comment 13 Laszlo Ersek 2020-02-27 13:24:11 UTC
Keeping this open because pre-requisite bug 2122 is not blocked due to
lack of capacity, but due to its planned schedule (bug 2122 should be
fixed around Aug 2020, per bug 2122 comment 0).

Also, dropping the dependency on bug 1086, because that bug has been
moved to edk2-platforms.

A reminder shall be here that OVMF will have to sanity-check the
MemoryTypeInformation UEFI variable in the PEI phase, as 3rd party UEFI
executables can write that variable, and bogus values maay prevent the
platform from booting:

CoreInitializeMemoryServices() [MdeModulePkg/Core/Dxe/Gcd/Gcd.c] @
edfe16a6d9f8:

>|   2264    //
>|   2265    // Assert if a resource descriptor HOB for the memory region described by the PHIT was not found
>|   2266    //
>|   2267    ASSERT (Found);
>| ...
>|   2339    //
>|   2340    // If no memory regions are found that are big enough to initialize the DXE core, then ASSERT().
>|   2341    //
>|   2342    ASSERT (Length >= MinimalMemorySizeNeeded);
Comment 14 Laszlo Ersek 2020-02-27 15:30:57 UTC
(I've moved bug 1086 back to the DXE Core, and reinstated the dependency.)
Comment 15 Laszlo Ersek 2020-03-10 10:13:26 UTC
I'm dropping bug 1086 from the dependency list. Bug 1086 is a DoS for the firmware, if the OS tampers with the Memory Type Information variable. But such a DoS is not hard to recover from, in a virtual machine. (Delete / re-initialize the varstore on the host side.)

Furthermore, the symptom described in bug 1086 is possible to trigger even without OS involvement. If the guest RAM size is sharply reduced between two cold boots, and the last cold boot used huge amounts of some memory type, the firmware might not boot anyway (regardless of OS involvement).

I'm planning to submit a new version of this patch set, but this time, limited to SMM. This feature has security impact for SMM, per:

  A Tour Beyond BIOS
  Secure SMM Communication in the EFI Developer Kit II

Memory Type Information is discussed (recommended) at length in the paper, plus the "Call for action" section in the end includes it in the summary:

> Call for action
> 1) A platform should check its own SMM communication buffer.
> 2) The DXE agent should allocate a fixed communication buffer or use the
EDKII_PI_SMM_COMMUNICATION_REGION_TABLE.
> 3) The SMI handler should call SmmIsBufferOutsideSmmValid() to validate the
communication buffer.
> 4) A platform should enable Memory Type Information table.
> 5) A platform should report the WSMT table to indicate the capability.
Comment 16 Laszlo Ersek 2020-03-10 10:16:38 UTC
Also dropping bug 2122 from the dependency list. -D SMM_REQUIRE already requires QEMU/Q35 (it doesn't boot on Xen), and this BZ is now relevant specifically for SMM.

In the past, Jordan has tried to detect pflash dynamically in the PEI phase, but in the PEI phase, OVMF is not in SMM, and so QEMU denies access to the pflash.

Thus this feature needs to depend on static (build time) configuration.
Comment 17 Laszlo Ersek 2020-03-10 18:29:03 UTC
Posted:

* [edk2-devel] [PATCH 0/5]
  OvmfPkg: improve SMM comms security with adaptive MemoryTypeInformation

http://mid.mail-archive.com/20200310222739.26717-1-lersek@redhat.com
https://edk2.groups.io/g/devel/message/55726
Comment 18 Laszlo Ersek 2020-03-12 17:16:38 UTC
(In reply to Laszlo Ersek from comment #17)
> Posted:
> 
> * [edk2-devel] [PATCH 0/5]
>   OvmfPkg: improve SMM comms security with adaptive MemoryTypeInformation
> 
> http://mid.mail-archive.com/20200310222739.26717-1-lersek@redhat.com
> https://edk2.groups.io/g/devel/message/55726

Merged as commit range 7d325f93e190..d42fdd6f8384, via <https://github.com/tianocore/edk2/pull/442>.