From nobody Tue Feb 10 02:50:02 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+88605+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+88605+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649406221; cv=none; d=zohomail.com; s=zohoarc; b=fQ/eXzRXIWslApGOVR4P1r0SfMx4tVr+JMDldHMfF7+gG2dMduUAikrh+KND0Jqx30lOC5JejjE+CnULup7ykNwozaA0zmBdBe7HmtNDxc/iwGypTpnuq/RNuRHrXmJrUSIKRAwdBiHHHT3oi5N/84jRgEfqVXLNI6yY3xUBD5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649406221; 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=X8Jid9aiTqe3Y56eQedUHtSrAA+J8HttXy+8+wpZh6s=; b=QuKoJQYVGUd/ZRXMyiIDiykkgicq1G7dnsh7Gk1wYgMnguRoS2qzJ6SMkNPjOCrB1nA15aBp/2ytHmrSnr43ooJOiw53xxq/WYXL0IYHi0j3zOoFweEohztjIyfO3Yb7lbN9s0UeznMKE1TInsfDnxrq6A1ypRGEJiOSOlKVKTc= 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+88605+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 1649406221823377.8766601437162; Fri, 8 Apr 2022 01:23:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZSb3YY1788612x1NkPLHPk0v; Fri, 08 Apr 2022 01:23:41 -0700 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.web09.3456.1649406220834124899 for ; Fri, 08 Apr 2022 01:23:41 -0700 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-PkLYiU0DMue_6DmhPYTbNg-1; Fri, 08 Apr 2022 04:23:35 -0400 X-MC-Unique: PkLYiU0DMue_6DmhPYTbNg-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 857BD1C08DB5; Fri, 8 Apr 2022 08:23:35 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2ACC7401475; Fri, 8 Apr 2022 08:23:35 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C84421800619; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 1/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuSendCommandWithReply Date: Fri, 8 Apr 2022 10:23:28 +0200 Message-Id: <20220408082333.3023758-2-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: N5cjqtgmtYOnzQ1KnllE932Tx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649406221; bh=py8m1g5aoEmsMc7BmyAW0+X22ductKlJvCs5Zd2b7dg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=pLDqPGS8U7/rSgNMQO1k+O5BQ7G1PYOMf8L5UtZBIvcB3qUG7xsRr8OGnknJqLgD+Mf Sx8a0emh6AcRYP9AYT+HAL3bf9c9kAIGqD5ndY09tgjjw0WM4vYf+t4iBrkzXdf0/L1+5 GR+eodpDSfAjVK0hfX54D+o4PTb+5Lx+Seo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649406222665100003 Content-Type: text/plain; charset="utf-8"; x-default="true" 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.35.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 (#88605): https://edk2.groups.io/g/devel/message/88605 Mute This Topic: https://groups.io/mt/90331438/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-