From 5409c6abc8d8b8a7196fee1d4455845aacef23bd Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Sat, 26 Aug 2017 19:54:49 +0200 Subject: [PATCH] OvmfPkg/VirtioGpuDxe: take EFI_PHYSICAL_ADDRESS in ResourceAttachBacking() The RESOURCE_ATTACH_BACKING virtio GPU command assigns guest-side backing pages to a host-side resource that was created earlier with the RESOURCE_CREATE_2D command. We compose the RESOURCE_ATTACH_BACKING command in the VirtioGpuResourceAttachBacking() function. Currently this function takes the parameter IN VOID *FirstBackingPage This is only appropriate as long as we pass a (guest-phys) system memory address to the device. In preparation for a mapped bus master device address, change the above parameter to IN EFI_PHYSICAL_ADDRESS BackingStoreDeviceAddress In order to keep the current call site functional, move the (VOID*) to (UINTN) conversion out of the function, to the call site. The "Request.Entry.Addr" field already has type UINT64. This patch is similar to commit 4b725858de68 ("OvmfPkg/VirtioLib: change the parameter of VirtioAppendDesc() to UINT64", 2017-08-23). Cc: Ard Biesheuvel Cc: Brijesh Singh Cc: Jordan Justen Cc: Tom Lendacky Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek Tested-by: Brijesh Singh --- OvmfPkg/VirtioGpuDxe/Commands.c | 10 +++++----- OvmfPkg/VirtioGpuDxe/Gop.c | 8 ++++---- OvmfPkg/VirtioGpuDxe/VirtioGpu.h | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c index bdedea1df6..c1951a807e 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -496,10 +496,10 @@ VirtioGpuResourceUnref ( EFI_STATUS VirtioGpuResourceAttachBacking ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId, - IN VOID *FirstBackingPage, - IN UINTN NumberOfPages + IN OUT VGPU_DEV *VgpuDev, + IN UINT32 ResourceId, + IN EFI_PHYSICAL_ADDRESS BackingStoreDeviceAddress, + IN UINTN NumberOfPages ) { volatile VIRTIO_GPU_RESOURCE_ATTACH_BACKING Request; @@ -510,7 +510,7 @@ VirtioGpuResourceAttachBacking ( Request.ResourceId = ResourceId; Request.NrEntries = 1; - Request.Entry.Addr = (UINTN)FirstBackingPage; + Request.Entry.Addr = BackingStoreDeviceAddress; Request.Entry.Length = (UINT32)EFI_PAGES_TO_SIZE (NumberOfPages); Request.Entry.Padding = 0; diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c index 3438bd0322..b3c5dae74d 100644 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ b/OvmfPkg/VirtioGpuDxe/Gop.c @@ -313,10 +313,10 @@ GopSetMode ( // Attach backing store to the host resource. // Status = VirtioGpuResourceAttachBacking ( - VgpuGop->ParentBus, // VgpuDev - NewResourceId, // ResourceId - NewBackingStore, // FirstBackingPage - NewNumberOfPages // NumberOfPages + VgpuGop->ParentBus, // VgpuDev + NewResourceId, // ResourceId + (UINTN)NewBackingStore, // BackingStoreDeviceAddress + NewNumberOfPages // NumberOfPages ); if (EFI_ERROR (Status)) { goto FreeBackingStore; diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h index 193e932e14..cf2a63accd 100644 --- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h +++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h @@ -252,10 +252,10 @@ VirtioGpuResourceUnref ( EFI_STATUS VirtioGpuResourceAttachBacking ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId, - IN VOID *FirstBackingPage, - IN UINTN NumberOfPages + IN OUT VGPU_DEV *VgpuDev, + IN UINT32 ResourceId, + IN EFI_PHYSICAL_ADDRESS BackingStoreDeviceAddress, + IN UINTN NumberOfPages ); EFI_STATUS -- 2.39.2