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 <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>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/VirtioGpuDxe/VirtioGpu.h | 8 ++++----
OvmfPkg/VirtioGpuDxe/Commands.c | 10 +++++-----
OvmfPkg/VirtioGpuDxe/Gop.c | 8 ++++----
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
index 193e932e1430..cf2a63accd72 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
diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c
index bdedea1df6a7..c1951a807e98 100644
--- a/OvmfPkg/VirtioGpuDxe/Commands.c
+++ b/OvmfPkg/VirtioGpuDxe/Commands.c
@@ -496,29 +496,29 @@ 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;
if (ResourceId == 0) {
return EFI_INVALID_PARAMETER;
}
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;
return VirtioGpuSendCommand (
VgpuDev,
VirtioGpuCmdResourceAttachBacking,
FALSE, // Fence
&Request.Header,
sizeof Request
);
}
diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 3438bd03224e..b3c5dae74d0e 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -229,176 +229,176 @@ EFIAPI
GopSetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber
)
{
VGPU_GOP *VgpuGop;
UINT32 NewResourceId;
UINTN NewNumberOfBytes;
UINTN NewNumberOfPages;
VOID *NewBackingStore;
EFI_STATUS Status;
EFI_STATUS Status2;
if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
return EFI_UNSUPPORTED;
}
VgpuGop = VGPU_GOP_FROM_GOP (This);
//
// Distinguish the first (internal) call from the other (protocol consumer)
// calls.
//
if (VgpuGop->ResourceId == 0) {
//
// Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other
// (nonzero) constant fields.
//
// No direct framebuffer access is supported, only Blt() is.
//
VgpuGop->Gop.Mode = &VgpuGop->GopMode;
VgpuGop->GopMode.MaxMode = (UINT32)(ARRAY_SIZE (mGopResolutions));
VgpuGop->GopMode.Info = &VgpuGop->GopModeInfo;
VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly;
//
// This is the first time we create a host side resource.
//
NewResourceId = 1;
} else {
//
// We already have an active host side resource. Create the new one without
// interfering with the current one, so that we can cleanly bail out on
// error, without disturbing the current graphics mode.
//
// The formula below will alternate between IDs 1 and 2.
//
NewResourceId = 3 - VgpuGop->ResourceId;
}
//
// Create the 2D host resource.
//
Status = VirtioGpuResourceCreate2d (
VgpuGop->ParentBus, // VgpuDev
NewResourceId, // ResourceId
VirtioGpuFormatB8G8R8X8Unorm, // Format
mGopResolutions[ModeNumber].Width, // Width
mGopResolutions[ModeNumber].Height // Height
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Allocate guest backing store.
//
NewNumberOfBytes = mGopResolutions[ModeNumber].Width *
mGopResolutions[ModeNumber].Height * sizeof (UINT32);
NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes);
NewBackingStore = AllocatePages (NewNumberOfPages);
if (NewBackingStore == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto DestroyHostResource;
}
//
// Fill visible part of backing store with black.
//
ZeroMem (NewBackingStore, NewNumberOfBytes);
//
// 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;
}
//
// Point head (scanout) #0 to the host resource.
//
Status = VirtioGpuSetScanout (
VgpuGop->ParentBus, // VgpuDev
0, // X
0, // Y
mGopResolutions[ModeNumber].Width, // Width
mGopResolutions[ModeNumber].Height, // Height
0, // ScanoutId
NewResourceId // ResourceId
);
if (EFI_ERROR (Status)) {
goto DetachBackingStore;
}
//
// If this is not the first (i.e., internal) call, then we have to (a) flush
// the new resource to head (scanout) #0, after having flipped the latter to
// the former above, plus (b) release the old resources.
//
if (VgpuGop->ResourceId != 0) {
Status = VirtioGpuResourceFlush (
VgpuGop->ParentBus, // VgpuDev
0, // X
0, // Y
mGopResolutions[ModeNumber].Width, // Width
mGopResolutions[ModeNumber].Height, // Height
NewResourceId // ResourceId
);
if (EFI_ERROR (Status)) {
//
// Flip head (scanout) #0 back to the current resource. If this fails, we
// cannot continue, as this error occurs on the error path and is
// therefore non-recoverable.
//
Status2 = VirtioGpuSetScanout (
VgpuGop->ParentBus, // VgpuDev
0, // X
0, // Y
mGopResolutions[This->Mode->Mode].Width, // Width
mGopResolutions[This->Mode->Mode].Height, // Height
0, // ScanoutId
VgpuGop->ResourceId // ResourceId
);
ASSERT_EFI_ERROR (Status2);
if (EFI_ERROR (Status2)) {
CpuDeadLoop ();
}
goto DetachBackingStore;
}
//
// Flush successful; release the old resources (without disabling head
// (scanout) #0).
//
ReleaseGopResources (VgpuGop, FALSE /* DisableHead */);
}
//
// This is either the first (internal) call when we have no old resources
// yet, or we've changed the mode successfully and released the old
// resources.
//
ASSERT (VgpuGop->ResourceId == 0);
ASSERT (VgpuGop->BackingStore == NULL);
VgpuGop->ResourceId = NewResourceId;
VgpuGop->BackingStore = NewBackingStore;
VgpuGop->NumberOfPages = NewNumberOfPages;
//
// Populate Mode and ModeInfo (mutable fields only).
//
VgpuGop->GopMode.Mode = ModeNumber;
VgpuGop->GopModeInfo.HorizontalResolution =
mGopResolutions[ModeNumber].Width;
VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height;
VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width;
return EFI_SUCCESS;
--
2.14.1.3.gb7cf6e02401b
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.