From nobody Fri Dec 27 02:23:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503926691374847.8384166587117; Mon, 28 Aug 2017 06:24:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5DFA62095DCAB; Mon, 28 Aug 2017 06:22:09 -0700 (PDT) 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) 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) X-Original-To: edk2-devel@lists.01.org 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 From: Laszlo Ersek To: edk2-devel-01 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: [edk2] [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: , Cc: Jordan Justen , Tom Lendacky , Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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/Virtio= Gpu.h index 193e932e1430..cf2a63accd72 100644 --- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h +++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h @@ -252,10 +252,10 @@ VirtioGpuResourceUnref ( =20 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 ); =20 EFI_STATUS diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Command= s.c index bdedea1df6a7..c1951a807e98 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -496,29 +496,29 @@ VirtioGpuResourceUnref ( =20 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; =20 if (ResourceId =3D=3D 0) { return EFI_INVALID_PARAMETER; } =20 Request.ResourceId =3D ResourceId; Request.NrEntries =3D 1; - Request.Entry.Addr =3D (UINTN)FirstBackingPage; + Request.Entry.Addr =3D BackingStoreDeviceAddress; Request.Entry.Length =3D (UINT32)EFI_PAGES_TO_SIZE (NumberOfPages); Request.Entry.Padding =3D 0; =20 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; =20 if (ModeNumber >=3D ARRAY_SIZE (mGopResolutions)) { return EFI_UNSUPPORTED; } =20 VgpuGop =3D VGPU_GOP_FROM_GOP (This); =20 // // Distinguish the first (internal) call from the other (protocol consum= er) // calls. // if (VgpuGop->ResourceId =3D=3D 0) { // // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the oth= er // (nonzero) constant fields. // // No direct framebuffer access is supported, only Blt() is. // VgpuGop->Gop.Mode =3D &VgpuGop->GopMode; =20 VgpuGop->GopMode.MaxMode =3D (UINT32)(ARRAY_SIZE (mGopResoluti= ons)); VgpuGop->GopMode.Info =3D &VgpuGop->GopModeInfo; VgpuGop->GopMode.SizeOfInfo =3D sizeof VgpuGop->GopModeInfo; =20 VgpuGop->GopModeInfo.PixelFormat =3D PixelBltOnly; =20 // // This is the first time we create a host side resource. // NewResourceId =3D 1; } else { // // We already have an active host side resource. Create the new one wi= thout // 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 =3D 3 - VgpuGop->ResourceId; } =20 // // Create the 2D host resource. // Status =3D VirtioGpuResourceCreate2d ( VgpuGop->ParentBus, // VgpuDev NewResourceId, // ResourceId VirtioGpuFormatB8G8R8X8Unorm, // Format mGopResolutions[ModeNumber].Width, // Width mGopResolutions[ModeNumber].Height // Height ); if (EFI_ERROR (Status)) { return Status; } =20 // // Allocate guest backing store. // NewNumberOfBytes =3D mGopResolutions[ModeNumber].Width * mGopResolutions[ModeNumber].Height * sizeof (UINT32); NewNumberOfPages =3D EFI_SIZE_TO_PAGES (NewNumberOfBytes); NewBackingStore =3D AllocatePages (NewNumberOfPages); if (NewBackingStore =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; goto DestroyHostResource; } // // Fill visible part of backing store with black. // ZeroMem (NewBackingStore, NewNumberOfBytes); =20 // // Attach backing store to the host resource. // Status =3D 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; } =20 // // Point head (scanout) #0 to the host resource. // Status =3D 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; } =20 // // If this is not the first (i.e., internal) call, then we have to (a) f= lush // the new resource to head (scanout) #0, after having flipped the latte= r to // the former above, plus (b) release the old resources. // if (VgpuGop->ResourceId !=3D 0) { Status =3D 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 fail= s, we // cannot continue, as this error occurs on the error path and is // therefore non-recoverable. // Status2 =3D 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; } =20 // // Flush successful; release the old resources (without disabling head // (scanout) #0). // ReleaseGopResources (VgpuGop, FALSE /* DisableHead */); } =20 // // 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 =3D=3D 0); ASSERT (VgpuGop->BackingStore =3D=3D NULL); =20 VgpuGop->ResourceId =3D NewResourceId; VgpuGop->BackingStore =3D NewBackingStore; VgpuGop->NumberOfPages =3D NewNumberOfPages; =20 // // Populate Mode and ModeInfo (mutable fields only). // VgpuGop->GopMode.Mode =3D ModeNumber; VgpuGop->GopModeInfo.HorizontalResolution =3D mGopResolutions[ModeNumber].W= idth; VgpuGop->GopModeInfo.VerticalResolution =3D mGopResolutions[ModeNumber].= Height; VgpuGop->GopModeInfo.PixelsPerScanLine =3D mGopResolutions[ModeNumber].W= idth; return EFI_SUCCESS; --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel