From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9B2E421DF809B for ; Mon, 28 Aug 2017 06:22:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93B14883B0; Mon, 28 Aug 2017 13:24:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 93B14883B0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-67.phx2.redhat.com [10.3.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37EFD60A9B; Mon, 28 Aug 2017 13:24:45 +0000 (UTC) From: Laszlo Ersek To: edk2-devel-01 Cc: Ard Biesheuvel , Brijesh Singh , Jordan Justen , Tom Lendacky Date: Mon, 28 Aug 2017 15:24:33 +0200 Message-Id: <20170828132436.15933-4-lersek@redhat.com> In-Reply-To: <20170828132436.15933-1-lersek@redhat.com> References: <20170828132436.15933-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 28 Aug 2017 13:24:46 +0000 (UTC) Subject: [PATCH 3/6] OvmfPkg/VirtioGpuDxe: take EFI_PHYSICAL_ADDRESS in ResourceAttachBacking() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Aug 2017 13:22:07 -0000 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 --- 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