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 EA7992095DCBD for ; Mon, 28 Aug 2017 06:22:12 -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 E613C7F405; Mon, 28 Aug 2017 13:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E613C7F405 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 8EC4660A9B; Mon, 28 Aug 2017 13:24:50 +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:36 +0200 Message-Id: <20170828132436.15933-7-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.25]); Mon, 28 Aug 2017 13:24:52 +0000 (UTC) Subject: [PATCH 6/6] OvmfPkg/VirtioGpuDxe: negotiate VIRTIO_F_IOMMU_PLATFORM 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:13 -0000 VirtioGpuDxe is now IOMMU-clean; it translates system memory addresses to bus master device addresses. Negotiate VIRTIO_F_IOMMU_PLATFORM in parallel with VIRTIO_F_VERSION_1. (Note: the VirtIo GPU device, and this driver, are virtio-1.0 only (a.k.a. "modern-only").) 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/Commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c index db5bdbca4bee..6e70b1c33f65 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -39,131 +39,131 @@ EFI_STATUS VirtioGpuInit ( IN OUT VGPU_DEV *VgpuDev ) { UINT8 NextDevStat; EFI_STATUS Status; UINT64 Features; UINT16 QueueSize; UINT64 RingBaseShift; // // Execute virtio-v1.0-cs04, 3.1.1 Driver Requirements: Device // Initialization. // // 1. Reset the device. // NextDevStat = 0; Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { goto Failed; } // // 2. Set the ACKNOWLEDGE status bit [...] // NextDevStat |= VSTAT_ACK; Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { goto Failed; } // // 3. Set the DRIVER status bit [...] // NextDevStat |= VSTAT_DRIVER; Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { goto Failed; } // // 4. Read device feature bits... // Status = VgpuDev->VirtIo->GetDeviceFeatures (VgpuDev->VirtIo, &Features); if (EFI_ERROR (Status)) { goto Failed; } if ((Features & VIRTIO_F_VERSION_1) == 0) { Status = EFI_UNSUPPORTED; goto Failed; } // // We only want the most basic 2D features. // - Features &= VIRTIO_F_VERSION_1; + Features &= VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM; // // ... and write the subset of feature bits understood by the [...] driver to // the device. [...] // 5. Set the FEATURES_OK status bit. // 6. Re-read device status to ensure the FEATURES_OK bit is still set [...] // Status = Virtio10WriteFeatures (VgpuDev->VirtIo, Features, &NextDevStat); if (EFI_ERROR (Status)) { goto Failed; } // // 7. Perform device-specific setup, including discovery of virtqueues for // the device [...] // Status = VgpuDev->VirtIo->SetQueueSel (VgpuDev->VirtIo, VIRTIO_GPU_CONTROL_QUEUE); if (EFI_ERROR (Status)) { goto Failed; } Status = VgpuDev->VirtIo->GetQueueNumMax (VgpuDev->VirtIo, &QueueSize); if (EFI_ERROR (Status)) { goto Failed; } // // We implement each VirtIo GPU command that we use with two descriptors: // request, response. // if (QueueSize < 2) { Status = EFI_UNSUPPORTED; goto Failed; } // // [...] population of virtqueues [...] // Status = VirtioRingInit (VgpuDev->VirtIo, QueueSize, &VgpuDev->Ring); if (EFI_ERROR (Status)) { goto Failed; } // // If anything fails from here on, we have to release the ring. // Status = VirtioRingMap ( VgpuDev->VirtIo, &VgpuDev->Ring, &RingBaseShift, &VgpuDev->RingMap ); if (EFI_ERROR (Status)) { goto ReleaseQueue; } // // If anything fails from here on, we have to unmap the ring. // Status = VgpuDev->VirtIo->SetQueueAddress ( VgpuDev->VirtIo, &VgpuDev->Ring, RingBaseShift ); if (EFI_ERROR (Status)) { goto UnmapQueue; } // // 8. Set the DRIVER_OK status bit. // NextDevStat |= VSTAT_DRIVER_OK; Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { goto UnmapQueue; } return EFI_SUCCESS; -- 2.14.1.3.gb7cf6e02401b