OvmfPkg/IoMmuDxe: rename DeviceAddress to PlainTextAddress in MAP_INFO

In this particular IOMMU driver, "DeviceAddress" is just as accessible to
the CPU as "HostAddress", the difference is that the area pointed-to by
the former is plain-text and accessible to the hypervisor. Rename
"DeviceAddress" to "PlainTextAddress" in MAP_INFO.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
This commit is contained in:
Laszlo Ersek 2017-08-02 11:26:42 +02:00
parent 812568fb87
commit dc194ce36d

View File

@ -25,7 +25,7 @@ typedef struct {
UINTN NumberOfBytes; UINTN NumberOfBytes;
UINTN NumberOfPages; UINTN NumberOfPages;
EFI_PHYSICAL_ADDRESS HostAddress; EFI_PHYSICAL_ADDRESS HostAddress;
EFI_PHYSICAL_ADDRESS DeviceAddress; EFI_PHYSICAL_ADDRESS PlainTextAddress;
} MAP_INFO; } MAP_INFO;
#define NO_MAPPING (VOID *) (UINTN) -1 #define NO_MAPPING (VOID *) (UINTN) -1
@ -145,7 +145,7 @@ IoMmuMap (
MapInfo->NumberOfBytes = *NumberOfBytes; MapInfo->NumberOfBytes = *NumberOfBytes;
MapInfo->NumberOfPages = EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes); MapInfo->NumberOfPages = EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes);
MapInfo->HostAddress = PhysicalAddress; MapInfo->HostAddress = PhysicalAddress;
MapInfo->DeviceAddress = DmaMemoryTop; MapInfo->PlainTextAddress = DmaMemoryTop;
// //
// Allocate a buffer to map the transfer to. // Allocate a buffer to map the transfer to.
@ -154,7 +154,7 @@ IoMmuMap (
AllocateType, AllocateType,
EfiBootServicesData, EfiBootServicesData,
MapInfo->NumberOfPages, MapInfo->NumberOfPages,
&MapInfo->DeviceAddress &MapInfo->PlainTextAddress
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (MapInfo); FreePool (MapInfo);
@ -167,7 +167,7 @@ IoMmuMap (
// //
Status = MemEncryptSevClearPageEncMask ( Status = MemEncryptSevClearPageEncMask (
0, 0,
MapInfo->DeviceAddress, MapInfo->PlainTextAddress,
MapInfo->NumberOfPages, MapInfo->NumberOfPages,
TRUE TRUE
); );
@ -181,7 +181,7 @@ IoMmuMap (
if (Operation == EdkiiIoMmuOperationBusMasterRead || if (Operation == EdkiiIoMmuOperationBusMasterRead ||
Operation == EdkiiIoMmuOperationBusMasterRead64) { Operation == EdkiiIoMmuOperationBusMasterRead64) {
CopyMem ( CopyMem (
(VOID *) (UINTN) MapInfo->DeviceAddress, (VOID *) (UINTN) MapInfo->PlainTextAddress,
(VOID *) (UINTN) MapInfo->HostAddress, (VOID *) (UINTN) MapInfo->HostAddress,
MapInfo->NumberOfBytes MapInfo->NumberOfBytes
); );
@ -190,7 +190,7 @@ IoMmuMap (
// //
// The DeviceAddress is the address of the maped buffer below 4GB // The DeviceAddress is the address of the maped buffer below 4GB
// //
*DeviceAddress = MapInfo->DeviceAddress; *DeviceAddress = MapInfo->PlainTextAddress;
// //
// Return a pointer to the MAP_INFO structure in Mapping // Return a pointer to the MAP_INFO structure in Mapping
@ -199,9 +199,9 @@ IoMmuMap (
DEBUG (( DEBUG ((
DEBUG_VERBOSE, DEBUG_VERBOSE,
"%a Device 0x%Lx Host 0x%Lx Pages 0x%Lx Bytes 0x%Lx\n", "%a PlainText 0x%Lx Host 0x%Lx Pages 0x%Lx Bytes 0x%Lx\n",
__FUNCTION__, __FUNCTION__,
MapInfo->DeviceAddress, MapInfo->PlainTextAddress,
MapInfo->HostAddress, MapInfo->HostAddress,
MapInfo->NumberOfPages, MapInfo->NumberOfPages,
MapInfo->NumberOfBytes MapInfo->NumberOfBytes
@ -256,16 +256,16 @@ IoMmuUnmap (
MapInfo->Operation == EdkiiIoMmuOperationBusMasterWrite64) { MapInfo->Operation == EdkiiIoMmuOperationBusMasterWrite64) {
CopyMem ( CopyMem (
(VOID *) (UINTN) MapInfo->HostAddress, (VOID *) (UINTN) MapInfo->HostAddress,
(VOID *) (UINTN) MapInfo->DeviceAddress, (VOID *) (UINTN) MapInfo->PlainTextAddress,
MapInfo->NumberOfBytes MapInfo->NumberOfBytes
); );
} }
DEBUG (( DEBUG ((
DEBUG_VERBOSE, DEBUG_VERBOSE,
"%a Device 0x%Lx Host 0x%Lx Pages 0x%Lx Bytes 0x%Lx\n", "%a PlainText 0x%Lx Host 0x%Lx Pages 0x%Lx Bytes 0x%Lx\n",
__FUNCTION__, __FUNCTION__,
MapInfo->DeviceAddress, MapInfo->PlainTextAddress,
MapInfo->HostAddress, MapInfo->HostAddress,
MapInfo->NumberOfPages, MapInfo->NumberOfPages,
MapInfo->NumberOfBytes MapInfo->NumberOfBytes
@ -275,7 +275,7 @@ IoMmuUnmap (
// //
Status = MemEncryptSevSetPageEncMask ( Status = MemEncryptSevSetPageEncMask (
0, 0,
MapInfo->DeviceAddress, MapInfo->PlainTextAddress,
MapInfo->NumberOfPages, MapInfo->NumberOfPages,
TRUE TRUE
); );
@ -284,7 +284,7 @@ IoMmuUnmap (
// //
// Free the mapped buffer and the MAP_INFO structure. // Free the mapped buffer and the MAP_INFO structure.
// //
gBS->FreePages (MapInfo->DeviceAddress, MapInfo->NumberOfPages); gBS->FreePages (MapInfo->PlainTextAddress, MapInfo->NumberOfPages);
FreePool (Mapping); FreePool (Mapping);
return EFI_SUCCESS; return EFI_SUCCESS;
} }