From nobody Mon Feb 9 19:52:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86360+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86360+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643873176; cv=none; d=zohomail.com; s=zohoarc; b=VAQsNacVRz3mE6mbzkKRKujKtJVypkiTioSQ8ZH3xaIYU2vveVX6rXRG3eFvvgeExroms+EhEAWP6yNv8fnBR0MvohFaSCeOyzxfROzNkhYNQjkOYIP90x2dbrbjMv5BaSVcW6BP29nGx3UBBDduOCr4RxUS/+4q0J9lMyw0bw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643873176; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=0nXPCPvqlBwTb95lhDW05TSnDx8ylBYg5mypsna+SGQ=; b=TwIdH2iiuL3rthfh4kltCpKuRKleTXFJpLiSqcJc7uf3RVmLfN7hecKzft3kHrYOCapGX8T3Ngsj/RY7IWqCEFPm9I9L956gonplRnAWyfXWWSSrsw/cyTmXb8VuWLgUaUon/qSuc0sdJgVPtjkPhBOAgB/iTjaOWoFvdhcGvGc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86360+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1643873176382719.3467591817725; Wed, 2 Feb 2022 23:26:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id CSMbYY1788612xhH4dXUxcXa; Wed, 02 Feb 2022 23:26:15 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.6400.1643873174921330262 for ; Wed, 02 Feb 2022 23:26:15 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-351-1EQvxlFfMYizqydwpYv1Qw-1; Thu, 03 Feb 2022 02:26:08 -0500 X-MC-Unique: 1EQvxlFfMYizqydwpYv1Qw-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24A111060D71 for ; Thu, 3 Feb 2022 07:26:03 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B08775DBB3; Thu, 3 Feb 2022 07:26:02 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A153118003A1; Thu, 3 Feb 2022 08:26:00 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Pawel Polawski , Gerd Hoffmann Subject: [edk2-devel] [PATCH 1/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuSendCommandWithReply Date: Thu, 3 Feb 2022 08:25:55 +0100 Message-Id: <20220203072600.1646396-2-kraxel@redhat.com> In-Reply-To: <20220203072600.1646396-1-kraxel@redhat.com> References: <20220203072600.1646396-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: URdmNWXcX2od3aYXNepfDcBtx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643873175; bh=jSxFFtKfynI5oD4N5hiRBEH3hni6ZFq59Yy6i/L8PEk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=stOoAsixRImeEa0b12KYuQvQ9oxi3czFEwd/hXzLrjrFhfjKnTB3hZ2JC59k33K7u65 Jl++7xbMtnvQPKWHWFx+7Tbg8lQHEd5Zf6IQrFFVveNSOhXCjQYjA6m3a2TzfDF9GuOnI O5IZdmdpYOa7/PDLqMPGa6c9WRa0lRqyOu8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643873178513100015 Content-Type: text/plain; charset="utf-8" Extend VirtioGpuSendCommand() to support commands which return data, rename the function to VirtioGpuSendCommandWithReply() to indicate that. Add a new VirtioGpuSendCommand() function which is just a thin wrapper around VirtioGpuSendCommandWithReply() so existing code continues to work without changes. Signed-off-by: Gerd Hoffmann --- OvmfPkg/VirtioGpuDxe/Commands.c | 75 +++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Command= s.c index 873a71656700..b9a3ea923021 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -393,6 +393,14 @@ VirtioGpuExitBoot ( @param[in] RequestSize Size of the entire caller-allocated request obje= ct, including the leading VIRTIO_GPU_CONTROL_HEADER. =20 + @param[in] ResponseType The type of the response (VirtioGpuResp*). + + @param[in,out] Response Pointer to the caller-allocated response object.= The + request must start with VIRTIO_GPU_CONTROL_HEADE= R. + + @param[in] ResponseSize Size of the entire caller-allocated response obj= ect, + including the leading VIRTIO_GPU_CONTROL_HEADER. + @retval EFI_SUCCESS Operation successful. =20 @retval EFI_DEVICE_ERROR The host rejected the request. The host e= rror @@ -404,22 +412,24 @@ VirtioGpuExitBoot ( **/ STATIC EFI_STATUS -VirtioGpuSendCommand ( +VirtioGpuSendCommandWithReply ( IN OUT VGPU_DEV *VgpuDev, IN VIRTIO_GPU_CONTROL_TYPE RequestType, IN BOOLEAN Fence, IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Header, - IN UINTN RequestSize + IN UINTN RequestSize, + IN VIRTIO_GPU_CONTROL_TYPE ResponseType, + IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Response, + IN UINTN ResponseSize ) { - DESC_INDICES Indices; - volatile VIRTIO_GPU_CONTROL_HEADER Response; - EFI_STATUS Status; - UINT32 ResponseSize; - EFI_PHYSICAL_ADDRESS RequestDeviceAddress; - VOID *RequestMap; - EFI_PHYSICAL_ADDRESS ResponseDeviceAddress; - VOID *ResponseMap; + DESC_INDICES Indices; + EFI_STATUS Status; + UINT32 ResponseSizeRet; + EFI_PHYSICAL_ADDRESS RequestDeviceAddress; + VOID *RequestMap; + EFI_PHYSICAL_ADDRESS ResponseDeviceAddress; + VOID *ResponseMap; =20 // // Initialize Header. @@ -457,8 +467,8 @@ VirtioGpuSendCommand ( Status =3D VirtioMapAllBytesInSharedBuffer ( VgpuDev->VirtIo, VirtioOperationBusMasterWrite, - (VOID *)&Response, - sizeof Response, + (VOID *)Response, + ResponseSize, &ResponseDeviceAddress, &ResponseMap ); @@ -480,7 +490,7 @@ VirtioGpuSendCommand ( VirtioAppendDesc ( &VgpuDev->Ring, ResponseDeviceAddress, - (UINT32)sizeof Response, + (UINT32)ResponseSize, VRING_DESC_F_WRITE, &Indices ); @@ -493,7 +503,7 @@ VirtioGpuSendCommand ( VIRTIO_GPU_CONTROL_QUEUE, &VgpuDev->Ring, &Indices, - &ResponseSize + &ResponseSizeRet ); if (EFI_ERROR (Status)) { goto UnmapResponse; @@ -502,7 +512,7 @@ VirtioGpuSendCommand ( // // Verify response size. // - if (ResponseSize !=3D sizeof Response) { + if (ResponseSize !=3D ResponseSizeRet) { DEBUG (( DEBUG_ERROR, "%a: malformed response to Request=3D0x%x\n", @@ -531,16 +541,17 @@ VirtioGpuSendCommand ( // // Parse the response. // - if (Response.Type =3D=3D VirtioGpuRespOkNodata) { + if (Response->Type =3D=3D (UINT32)ResponseType) { return EFI_SUCCESS; } =20 DEBUG (( DEBUG_ERROR, - "%a: Request=3D0x%x Response=3D0x%x\n", + "%a: Request=3D0x%x Response=3D0x%x (expected 0x%x)\n", __FUNCTION__, (UINT32)RequestType, - Response.Type + Response->Type, + ResponseType )); return EFI_DEVICE_ERROR; =20 @@ -553,6 +564,34 @@ VirtioGpuSendCommand ( return Status; } =20 +/** + Simplified version of VirtioGpuSendCommandWithReply() for commands + which do not send back any data. +**/ +STATIC +EFI_STATUS +VirtioGpuSendCommand ( + IN OUT VGPU_DEV *VgpuDev, + IN VIRTIO_GPU_CONTROL_TYPE RequestType, + IN BOOLEAN Fence, + IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Header, + IN UINTN RequestSize + ) +{ + volatile VIRTIO_GPU_CONTROL_HEADER Response; + + return VirtioGpuSendCommandWithReply ( + VgpuDev, + RequestType, + Fence, + Header, + RequestSize, + VirtioGpuRespOkNodata, + &Response, + sizeof (Response) + ); +} + /** The following functions send requests to the VirtIo GPU device model, aw= ait the answer from the host, and return a status. They share the following --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86360): https://edk2.groups.io/g/devel/message/86360 Mute This Topic: https://groups.io/mt/88878648/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-