[RFC] Add Platform Runtime Mechanism (PRM) to edk2

Michael Kubacki

This RFC proposes adding a new package called "PrmPkg" to edk2/master. This package contains common functionality to support a new firmware solution called Platform Runtime Mechanism (PRM).

PRM has been developed in edk2-staging/PlatformRuntimeMechanism.

We believe it is beneficial to make this source code more widely available due to:
1. PRM specification adoption
2. Feature completeness
3. Overall validation coverage
4. Interest from the community and future collaboration

This RFC does not restate the purpose and technical details of PRM as those are covered in detail in the PRM Specification and within documentation on edk2-staging/PlatformRuntimeMechanism.

1. PRM specification adoption

Intel and Microsoft have worked together to standardize PRM in the ACPI Specification and the PRM Specification hosted on uefi.org.

* ACPI 6.4 Specification: https://uefi.org/node/4149

* PRM Specification: https://uefi.org/sites/default/files/resources/Platform%20Runtime%20Mechanism%20-%20with%20legal%20notice.pdf

2. Feature completeness

PrmPkg implements the full firmware functionality described in the PRM Specification and there are no significant changes to functionality planned at this time.

3. Overall validation coverage

PrmPkg has been integrated and tested on client and server systems in addition to virtual platforms (OvmfPkg/QEMU).

Platform integration is simple and a demonstration of this integration for OvmfPkg is available in the following branch: https://github.com/makubacki/edk2/tree/ovmf_prmpkg_integration

The code has been built with:
* MSFT VS2015, VS2017, and VS2019
* GCC5 (see https://bugzilla.tianocore.org/show_bug.cgi?id=3802)
* iASL compiler (20200528 - https://acpica.org/node/181)

The Linux kernel currently includes the following PRM support:
* _OSC PRM bit - allows FW to know determine the OS is PRM-capable and can redirect _DSM method from alternate triggers (such as SMI) to PRM.
* PRM invocation via _DSM, includes PRM module and handler parsing from ACPI PRMT table, and also the PRM operation region handler for runtime PRM service invocation.
* An OS configuration for PRM enabling, PRM support can be disabled during OS image build.

Upstream Linux does not currently support the following:
* Ability for the OS driver to call a PRM handler directly, it has to be via ACPI _DSM.
* Run time update PRM module and handler via PE/COFF PRM image.

This commit provides additional context of the changes in Linux: https://github.com/torvalds/linux/commit/cefc7ca46235f01d5233e3abd4b79452af01d9e9

Windows 11 (https://www.microsoft.com/software-download/windows11) and Windows Server 2022 (https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) include the PRM functionality noted above in addition to PRM direct call and PRM runtime updates.

PRM has been tested on IA32, X64, and AARCH64 targets.

4. Interest from the community and future collaboration

PRM has been presented at several industry conferences:

* OSFC 2020 - "PRM: SMM Goes on a Diet"

* OCP Summit 2019 - "Case Study Alternatives for SMM Usage in Intel Platforms"

In addition, Microsoft plans to publish the Windows PRM driver interface and a WDF sample driver that uses the interface to the Windows Driver Samples GitHub repository (https://github.com/microsoft/Windows-driver-samples).

We have received interest from various vendors in adopting and contributing to PRM. We believe a PrmPkg in edk2 can increase accessibility to PRM and ease collaboration that will help evolve the feature.

PrmPkg contains the common functionality needed to enable PRM on any system. It does not contain platform-specific code such as PRM modules (and by extension PRM handlers). Other than sample modules, PrmPkg will only contain code needed to provide PRM feature functionality as defined in the PRM Specification.

For further information on PrmPkg, please see the code tree at:

In particular:
* Readme.md: https://github.com/tianocore/edk2-staging/blob/PlatformRuntimeMechanism/Readme.md

* Samples/Readme.md: https://github.com/tianocore/edk2-staging/blob/PlatformRuntimeMechanism/PrmPkg/Samples/Readme.md

* Docs/PrmHandlerWritersGuide.md: https://github.com/tianocore/edk2-staging/blob/PlatformRuntimeMechanism/Docs/PrmHandlerWritersGuide.md

The proposed maintainers of PrmPkg are:
* Michael Kubacki <michael.kubacki@microsoft.com>
* Benjamin You <benjamin.you@intel.com>

Next Steps
1. The code will remain in edk2-staging/PlatformRuntimeMechanism for the foreseeable future due to external dependencies currently on that code. No further updates will be made to the code in edk2-staging and consumers will be encouraged to move to the package in edk2.

2. The documentation will be updated to reflect movement to the edk2 repository and to ensure content is up-to-date.

3. The changes will be condensed into a patch series that maintains important history and passes edk2 patch and CI checks.