TianoCore EDK2 master
|
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/QemuLoader.h>
#include <IndustryStandard/UefiTcgPlatform.h>
#include <Library/AcpiPlatformLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OrderedCollectionLib.h>
#include <Library/QemuFwCfgLib.h>
#include <Library/QemuFwCfgS3Lib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/TpmMeasurementLib.h>
Go to the source code of this file.
Data Structures | |
struct | BLOB |
Macros | |
#define | INSTALLED_TABLES_MAX 128 |
OVMF ACPI support using QEMU's fw-cfg interface
Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
Copyright (C) 2012-2014, Red Hat, Inc.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file QemuFwCfgAcpi.c.
#define INSTALLED_TABLES_MAX 128 |
Definition at line 835 of file QemuFwCfgAcpi.c.
STATIC INTN EFIAPI AsciiStringCompare | ( | IN CONST VOID * | AsciiString1, |
IN CONST VOID * | AsciiString2 | ||
) |
Comparator function for two ASCII strings. Can be used as both Key and UserStruct comparator.
This function exists solely so we can avoid casting &AsciiStrCmp to ORDERED_COLLECTION_USER_COMPARE and ORDERED_COLLECTION_KEY_COMPARE.
[in] | AsciiString1 | Pointer to the first ASCII string. |
[in] | AsciiString2 | Pointer to the second ASCII string. |
Definition at line 145 of file QemuFwCfgAcpi.c.
Comparator function for two user structures.
[in] | UserStruct1 | Pointer to the first user structure. |
[in] | UserStruct2 | Pointer to the second user structure. |
<0 | If UserStruct1 compares less than UserStruct2. |
0 | If UserStruct1 compares equal to UserStruct2. |
>0 | If UserStruct1 compares greater than UserStruct2. |
Definition at line 84 of file QemuFwCfgAcpi.c.
Compare a standalone key against a user structure containing an embedded key.
[in] | StandaloneKey | Pointer to the bare key. |
[in] | UserStruct | Pointer to the user structure with the embedded key. |
<0 | If StandaloneKey compares less than UserStruct's key. |
0 | If StandaloneKey compares equal to UserStruct's key. |
>0 | If StandaloneKey compares greater than UserStruct's key. |
Definition at line 57 of file QemuFwCfgAcpi.c.
STATIC EFI_STATUS CollectAllocationsRestrictedTo32Bit | ( | OUT ORDERED_COLLECTION ** | AllocationsRestrictedTo32Bit, |
IN CONST QEMU_LOADER_ENTRY * | LoaderStart, | ||
IN CONST QEMU_LOADER_ENTRY * | LoaderEnd | ||
) |
Iterate over the linker/loader script, and collect the names of the fw_cfg blobs that are referenced by QEMU_LOADER_ADD_POINTER.PointeeFile fields, such that QEMU_LOADER_ADD_POINTER.PointerSize is less than 8. This means that the pointee blob's address will have to be patched into a narrower-than-8 byte pointer field, hence the pointee blob must not be allocated from 64-bit address space.
[out] | AllocationsRestrictedTo32Bit | The ORDERED_COLLECTION structure linking (not copying / owning) such QEMU_LOADER_ADD_POINTER.PointeeFile fields that name the blobs restricted from 64-bit allocation. |
[in] | LoaderStart | Points to the first entry in the linker/loader script. |
[in] | LoaderEnd | Points one past the last entry in the linker/loader script. |
EFI_SUCCESS | AllocationsRestrictedTo32Bit has been populated. |
EFI_OUT_OF_RESOURCES | Memory allocation failed. |
EFI_PROTOCOL_ERROR | Invalid linker/loader script contents. |
Definition at line 211 of file QemuFwCfgAcpi.c.
EFI_STATUS EFIAPI InstallQemuFwCfgTables | ( | IN EFI_ACPI_TABLE_PROTOCOL * | AcpiProtocol | ) |
Download, process, and install ACPI table data from the QEMU loader interface.
[in] | AcpiProtocol | The ACPI table protocol used to install tables. |
EFI_UNSUPPORTED | Firmware configuration is unavailable, or QEMU loader command with unsupported parameters has been found. |
EFI_NOT_FOUND | The host doesn't export the required fw_cfg files. |
EFI_OUT_OF_RESOURCES | Memory allocation failed, or more than INSTALLED_TABLES_MAX tables found. |
EFI_PROTOCOL_ERROR | Found invalid fw_cfg contents. |
Definition at line 1099 of file QemuFwCfgAcpi.c.
Comparator function for two opaque pointers, ordering on (unsigned) pointer value itself. Can be used as both Key and UserStruct comparator.
[in] | Pointer1 | First pointer. |
[in] | Pointer2 | Second pointer. |
<0 | If Pointer1 compares less than Pointer2. |
0 | If Pointer1 compares equal to Pointer2. |
>0 | If Pointer1 compares greater than Pointer2. |
Definition at line 113 of file QemuFwCfgAcpi.c.
STATIC EFI_STATUS EFIAPI Process2ndPassCmdAddPointer | ( | IN CONST QEMU_LOADER_ADD_POINTER * | AddPointer, |
IN CONST ORDERED_COLLECTION * | Tracker, | ||
IN EFI_ACPI_TABLE_PROTOCOL * | AcpiProtocol, | ||
IN OUT UINTN | InstalledKey[INSTALLED_TABLES_MAX], | ||
IN OUT INT32 * | NumInstalled, | ||
IN OUT ORDERED_COLLECTION * | SeenPointers | ||
) |
Process a QEMU_LOADER_ADD_POINTER command in order to see if its target byte array is an ACPI table, and if so, install it.
This function assumes that the entire QEMU linker/loader command file has been processed successfully in a prior first pass.
[in] | AddPointer | The QEMU_LOADER_ADD_POINTER command to process. |
[in] | Tracker | The ORDERED_COLLECTION tracking the BLOB user structures. |
[in] | AcpiProtocol | The ACPI table protocol used to install tables. |
[in,out] | InstalledKey | On input, an array of INSTALLED_TABLES_MAX UINTN elements, allocated by the caller. On output, the function will have stored (appended) the AcpiProtocol-internal key of the ACPI table that the function has installed, if the AddPointer command identified an ACPI table that is different from RSDT and XSDT. |
[in,out] | NumInstalled | On input, the number of entries already used in InstalledKey; it must be in [0, INSTALLED_TABLES_MAX] inclusive. On output, the parameter is incremented if the AddPointer command identified an ACPI table that is different from RSDT and XSDT. |
[in,out] | SeenPointers | The ORDERED_COLLECTION tracking the absolute target addresses that have been pointed-to by QEMU_LOADER_ADD_POINTER commands thus far. If a target address is encountered for the first time, and it identifies an ACPI table that is different from RDST and XSDT, the table is installed. If a target address is seen for the second or later times, it is skipped without taking any action. |
EFI_INVALID_PARAMETER | NumInstalled was outside the allowed range on input. |
EFI_OUT_OF_RESOURCES | The AddPointer command identified an ACPI table different from RSDT and XSDT, but there was no more room in InstalledKey. |
EFI_SUCCESS | AddPointer has been processed. Either its absolute target address has been encountered before, or an ACPI table different from RSDT and XSDT has been installed (reflected by InstalledKey and NumInstalled), or RSDT or XSDT has been identified but not installed, or the fw_cfg blob pointed-into by AddPointer has been marked as hosting something else than just direct ACPI table contents. |
Definition at line 899 of file QemuFwCfgAcpi.c.
STATIC EFI_STATUS EFIAPI ProcessCmdAddChecksum | ( | IN CONST QEMU_LOADER_ADD_CHECKSUM * | AddChecksum, |
IN CONST ORDERED_COLLECTION * | Tracker | ||
) |
Process a QEMU_LOADER_ADD_CHECKSUM command.
[in] | AddChecksum | The QEMU_LOADER_ADD_CHECKSUM command to process. |
[in] | Tracker | The ORDERED_COLLECTION tracking the BLOB user structures created thus far. |
EFI_PROTOCOL_ERROR | Malformed fw_cfg file name has been found in AddChecksum, or the AddChecksum command references a file unknown to Tracker, or the range to checksum is invalid. |
EFI_SUCCESS | The requested range has been checksummed. |
Definition at line 578 of file QemuFwCfgAcpi.c.
STATIC EFI_STATUS EFIAPI ProcessCmdAddPointer | ( | IN CONST QEMU_LOADER_ADD_POINTER * | AddPointer, |
IN CONST ORDERED_COLLECTION * | Tracker | ||
) |
Process a QEMU_LOADER_ADD_POINTER command.
[in] | AddPointer | The QEMU_LOADER_ADD_POINTER command to process. |
[in] | Tracker | The ORDERED_COLLECTION tracking the BLOB user structures created thus far. |
EFI_PROTOCOL_ERROR | Malformed fw_cfg file name(s) have been found in AddPointer, or the AddPointer command references a file unknown to Tracker, or the pointer to relocate has invalid location, size, or value, or the relocated pointer value is not representable in the given pointer size. |
EFI_SUCCESS | The pointer field inside the pointer blob has been relocated. |
Definition at line 466 of file QemuFwCfgAcpi.c.
STATIC EFI_STATUS EFIAPI ProcessCmdAllocate | ( | IN CONST QEMU_LOADER_ALLOCATE * | Allocate, |
IN OUT ORDERED_COLLECTION * | Tracker, | ||
IN ORDERED_COLLECTION * | AllocationsRestrictedTo32Bit | ||
) |
Process a QEMU_LOADER_ALLOCATE command.
[in] | Allocate | The QEMU_LOADER_ALLOCATE command to process. |
[in,out] | Tracker | The ORDERED_COLLECTION tracking the BLOB user structures created thus far. |
[in] | AllocationsRestrictedTo32Bit | The ORDERED_COLLECTION populated by the function CollectAllocationsRestrictedTo32Bit, naming the fw_cfg blobs that must not be allocated from 64-bit address space. |
EFI_SUCCESS | An area of whole AcpiNVS pages has been allocated for the blob contents, and the contents have been saved. A BLOB object (user structure) has been allocated from pool memory, referencing the blob contents. The BLOB user structure has been linked into Tracker. |
EFI_PROTOCOL_ERROR | Malformed fw_cfg file name has been found in Allocate, or the Allocate command references a file that is already known by Tracker. |
EFI_UNSUPPORTED | Unsupported alignment request has been found in Allocate. |
EFI_OUT_OF_RESOURCES | Pool allocation failed. |
Definition at line 318 of file QemuFwCfgAcpi.c.
STATIC EFI_STATUS ProcessCmdWritePointer | ( | IN CONST QEMU_LOADER_WRITE_POINTER * | WritePointer, |
IN CONST ORDERED_COLLECTION * | Tracker, | ||
IN OUT S3_CONTEXT *S3Context | OPTIONAL | ||
) |
Process a QEMU_LOADER_WRITE_POINTER command.
[in] | WritePointer | The QEMU_LOADER_WRITE_POINTER command to process. |
[in] | Tracker | The ORDERED_COLLECTION tracking the BLOB user structures created thus far. |
[in,out] | S3Context | The S3_CONTEXT object capturing the fw_cfg actions of successfully processed QEMU_LOADER_WRITE_POINTER commands, to be replayed at S3 resume. S3Context may be NULL if S3 is disabled. |
EFI_PROTOCOL_ERROR | Malformed fw_cfg file name(s) have been found in WritePointer. Or, the WritePointer command references a file unknown to Tracker or the fw_cfg directory. Or, the pointer object to rewrite has invalid location, size, or initial relative value. Or, the pointer value to store does not fit in the given pointer size. |
EFI_SUCCESS | The pointer object inside the writeable fw_cfg file has been written. If S3Context is not NULL, then WritePointer has been condensed into S3Context. |
Definition at line 666 of file QemuFwCfgAcpi.c.
STATIC VOID ReleaseAllocationsRestrictedTo32Bit | ( | IN ORDERED_COLLECTION * | AllocationsRestrictedTo32Bit | ) |
Release the ORDERED_COLLECTION structure populated by CollectAllocationsRestrictedTo32Bit() (below).
This function may be called by CollectAllocationsRestrictedTo32Bit() itself, on the error path.
[in] | AllocationsRestrictedTo32Bit | The ORDERED_COLLECTION structure to release. |
Definition at line 165 of file QemuFwCfgAcpi.c.
STATIC VOID UndoCmdWritePointer | ( | IN CONST QEMU_LOADER_WRITE_POINTER * | WritePointer | ) |
Undo a QEMU_LOADER_WRITE_POINTER command.
This function revokes (zeroes out) a guest memory reference communicated to QEMU earlier. The caller is responsible for invoking this function only on such QEMU_LOADER_WRITE_POINTER commands that have been successfully processed by ProcessCmdWritePointer().
[in] | WritePointer | The QEMU_LOADER_WRITE_POINTER command to undo. |
Definition at line 800 of file QemuFwCfgAcpi.c.