OvmfPkg: Introduce Tcg2PhysicalPresencePlatformLib

Put the PPI configuration retriveal into an own library.
That will allow to reuse the code in the UefipayloadPkg, where the
firmware provides the ACPI tables, like QEMU does on OvmfPkg.

However one major difference is that the PPI interface in UefiPayloadPkg
is not backed by a MMIO device, but resides in DRAM and is shared with ACPI code.

Add an additional parameter to provide the location of the PPI and
test if the memory region has the correct attributes.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
This commit is contained in:
Patrick Rudolph
2020-09-21 11:54:25 +02:00
committed by Tim Crawford
parent 25af751320
commit bdb15bf9ba
8 changed files with 143 additions and 42 deletions

View File

@@ -0,0 +1,56 @@
/** @file
Returns the platform specific configuration for the QEMU PPI.
Caution: This module requires additional review when modified.
This driver will have external input - variable.
This external input must be validated carefully to avoid security issue.
Copyright (C) 2018, Red Hat, Inc.
Copyright (c) 2018, IBM Corporation. All rights reserved.<BR>
Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiDxe.h>
#include <IndustryStandard/QemuTpm.h>
#include <Library/QemuFwCfgLib.h>
#include <Library/Tcg2PhysicalPresencePlatformLib.h>
/**
Reads QEMU PPI config from fw_cfg.
@param[out] The Config structure to read to.
@param[out] The PPIinMMIO is True when the PPI is in MMIO memory space
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_PROTOCOL_ERROR Invalid fw_cfg entry size.
**/
EFI_STATUS
TpmPPIPlatformReadConfig (
OUT QEMU_FWCFG_TPM_CONFIG *Config,
OUT BOOLEAN *PPIinMMIO
)
{
EFI_STATUS Status;
FIRMWARE_CONFIG_ITEM FwCfgItem;
UINTN FwCfgSize;
Status = QemuFwCfgFindFile ("etc/tpm/config", &FwCfgItem, &FwCfgSize);
if (EFI_ERROR (Status)) {
return Status;
}
if (FwCfgSize != sizeof (*Config)) {
return EFI_PROTOCOL_ERROR;
}
QemuFwCfgSelectItem (FwCfgItem);
QemuFwCfgReadBytes (sizeof (*Config), Config);
*PPIinMMIO = TRUE;
return EFI_SUCCESS;
}

View File

@@ -0,0 +1,36 @@
## @file
# Returns the platform specific configuration for the QEMU PPI.
#
# Caution: This module requires additional review when modified.
# This driver will have external input - variable.
# This external input must be validated carefully to avoid security issue.
#
# Copyright (C) 2018, Red Hat, Inc.
# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = Tcg2PhysicalPresencePlatformLibQemu
FILE_GUID = 9336E7F0-6CA1-4E6D-A0E9-DFE5F077AA02
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = Tcg2PhysicalPresencePlatformLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#
[Sources]
DxeTcg2PhysicalPresencePlatformLib.c
[Packages]
OvmfPkg/OvmfPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
QemuFwCfgLib