summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioScsiDxe
Commit message (Collapse)AuthorAgeFilesLines
* OvmfPkg/Virtio: Fix few typosAntoine Coeur2020-02-101-1/+1
| | | | | | | | | | | | | Fix few typos in comments and documentation. Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Antoine Coeur <coeur@gmx.fr> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com> Message-Id: <20200207010831.9046-59-philmd@redhat.com>
* OvmfPkg: Replace BSD License with BSD+Patent LicenseMichael D Kinney2019-04-093-21/+3
| | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=1373 Replace BSD 2-Clause License with BSD+Patent License. This change is based on the following emails: https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html RFCs with detailed process for the license change: V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg:Fix VS2012 build failureDandan Bi2018-03-281-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Initialize local variable to suppress warning C4701/C4703: potentially uninitialized local variable/pointer variable. 1.In VirtualMemory.c: Read of "PageMapLevel4Entry" in SetMemoryEncDe() is only reached when "PageMapLevel4Entry" is got correctly. 2.In VirtioBlk.c: Reads (dereferences) of "BufferMapping" and "BufferDeviceAddress" in SynchronousRequest() are only reached if "BufferSize > 0" *and* we map the data buffer successfully. 3.In VirtioScsi.c: Reads (dereferences) of "InDataMapping" and "InDataDeviceAddress", in VirtioScsiPassThru() are only reached if "Packet->InTransferLength > 0" on input, *and* we map the input buffer successfully. The similar reason for "OutDataMapping" and "OutDataDeviceAddress". Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg/VirtioScsiDxe: list "VirtioScsi.h" in the INF fileLaszlo Ersek2018-03-131-0/+1
| | | | | | | | | | | | | | Among other things, the header file defines macros and types that are private to the driver and are used by the sole C file of the driver. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Suggested-by: Michael Kinney <michael.d.kinney@intel.com> Ref: http://mid.mail-archive.com/E92EE9817A31E24EB0585FDF735412F56327F7D3@ORSMSX113.amr.corp.intel.com Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices()Laszlo Ersek2017-09-081-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | In one of the following patches, we'll change OvmfPkg/IoMmuDxe so that it unmaps all existent bus master operations (CommonBuffer, Read, Write) at ExitBootServices(), strictly after the individual device drivers abort pending DMA on the devices they manage, in their own ExitBootServices() notification functions. In preparation, remove the explicit VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer() call from VirtioScsiExitBoot(), originally added in commit fc2168feb248 ("OvmfPkg/VirtioScsiDxe: map VRING using VirtioRingMap()", 2017-08-31). Add a DEBUG message so we can observe the ordering between VirtioScsiExitBoot() and the upcoming cleanup of mappings in OvmfPkg/IoMmuDxe. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Brijesh Singh <brijesh.singh@amd.com> Tested-by: Brijesh Singh <brijesh.singh@amd.com>
* OvmfPkg/VirtioScsiDxe: negotiate VIRTIO_F_IOMMU_PLATFORMBrijesh Singh2017-08-311-2/+3
| | | | | | | | | | | | | | | | | | VirtioScsiDxe driver has been updated to use IOMMU-like member functions from VIRTIO_DEVICE_PROTOCOL to translate the system physical address to device address. We do not need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present hence treat it in parallel with VIRTIO_F_VERSION_1. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg/VirtioScsiDxe: map virtio-scsi request and response buffersBrijesh Singh2017-08-311-16/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When device is behind the IOMMU, driver is require to pass the device address of virtio request, response and any memory referenced by those request/response to the bus master. The patch uses IOMMU-like member functions from VIRTIO_DEVICE_PROTOCOL to map request and response buffers system physical address to the device address. - If the buffer need to be accessed by both the processor and a bus master then map with BusMasterCommonBuffer. - If the buffer need to be accessed for a write operation by a bus master then map with BusMasterWrite. However, after a BusMasterWrite Unmap() failure, error reporting via EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET would be very complex, therefore we map such buffers too with BusMasterCommonBuffer. - If the buffer need to be accessed for a read operation by a bus master then map with BusMasterRead. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> [lersek@redhat.com: restore lost sentence/paragraph in commit message] [lersek@redhat.com: reindent/reflow "InDataBuffer" comment block] [lersek@redhat.com: cast arg, not result, of EFI_SIZE_TO_PAGES() to UINTN] Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg/VirtioScsiDxe: add helper to create a fake host adapter errorBrijesh Singh2017-08-311-7/+33
| | | | | | | | | | | | | | | | | | | | | When virtio request fails we return EFI_DEVICE_ERROR, as per the spec EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() member function is required to implement elaborated error reporting. The patch refactors out entire block of the code that creates the host adapter error into a separate helper function (ReportHostAdapterError). Suggested-by: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> [lersek@redhat.com: fix style & typo in ReportHostAdapterError() comment] Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg/VirtioScsiDxe: map VRING using VirtioRingMap()Brijesh Singh2017-08-312-10/+38
| | | | | | | | | | | | | | | | When device is behind the IOMMU then driver need to pass the device address when programing the bus master. The patch uses VirtioRingMap() to map the VRING system physical address to device address. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg/Virtio: take RingBaseShift in SetQueueAddress()Brijesh Singh2017-08-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | For the case when an IOMMU is used for translating system physical addresses to DMA bus master addresses, the transport-independent virtio device drivers will be required to map their VRING areas to bus addresses with VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() calls. - MMIO and legacy virtio transport do not support IOMMU to translate the addresses hence RingBaseShift will always be set to zero. - modern virtio transport supports IOMMU to translate the address, in next patch we will update the Virtio10Dxe to use RingBaseShift offset. Suggested-by: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> [lersek@redhat.com: remove commit msg paragraph with VirtioLib reference] [lersek@redhat.com: fix typo in VIRTIO_SET_QUEUE_ADDRESS comment block] Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg/VirtioLib: take VirtIo instance in VirtioRingInit/VirtioRingUninitBrijesh Singh2017-08-251-3/+4
| | | | | | | | | | | | | | Passing the VirtIo protocol instance will allow the vring to use VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages () to allocate vring buffer. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg: Fix typing errors in header filesThomas Huth2016-09-131-1/+1
| | | | | | | | | Correct some typos in the header files of the OvmfPkg (which have been discovered with the codespell utility). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* OvmfPkg: VirtioScsiDxe: adapt feature negotiation to virtio-1.0Laszlo Ersek2016-04-061-7/+20
| | | | | | | | | | | | | | | | | | Relative to virtio-0.9.5, virtio-1.0 reverses the order of queue discovery and feature negotiation. In virtio-1.0, feature negotiation has to complete first, and the device can also reject a self-inconsistent feature request through the new VSTAT_FEATURES_OK status bit. (For example if the driver requests a higher level feature but clears a prerequisite feature.) Furthermore, we retain the VIRTIO_F_VERSION_1 feature bit if the VIRTIO_DEVICE_PROTOCOL provider has high enough revision. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* OvmfPkg: VIRTIO_DEVICE_PROTOCOL: pass VRING object to SetQueueAddress()Laszlo Ersek2016-04-061-2/+1
| | | | | | | | | | | | | | | | In virtio-1.0, it is not enough to pass the base address of the virtio queue to the hypervisor (as a frame number); instead it will want the addresses of the descriptor table, the available ring, and the used ring separately. Pass the VRING object to the SetQueueAddress() member function; this will enable a virtio-1.0 implementation. Convert the current producers and consumers to this prototype. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* OvmfPkg: VIRTIO_DEVICE_PROTOCOL: widen the Features bitmap to 64 bitsLaszlo Ersek2016-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The virtio-1.0 spec widens the Features bitmap to 64 bits. Modify the declarations of the GetDeviceFeatures() and SetGuestFeatures() protocol member functions accordingly. Normally, a protocol cannot be changed in incompatible ways if the GUID stays the same; however, we've always been extremely clear that VIRTIO_DEVICE_PROTOCOL is internal to edk2. See for example the top of "OvmfPkg/Include/Protocol/VirtioDevice.h". In this patch, all producers and consumers of the GetDeviceFeatures() and SetGuestFeatures() protocol members are updated. The drivers that currently produce these members are "legacy" drivers (in virtio-1.0 terminology), and they cannot (and will not) handle feature bits above BIT31. Therefore their conversion is only for compatibility with the modified protocol interface. The consumers will be responsible for checking the VIRTIO_DEVICE_PROTOCOL.Revision field, and for not passing feature bits that these backends cannot handle. The VirtioMmioGetDeviceFeatures() implementation stores the result of an MmioRead32() call with normal assignment, so it needs no change beyond adapting its prototype. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* OvmfPkg: VirtioFlush(): return the number of bytes written by the hostLaszlo Ersek2016-02-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VirtioLib provides an API for simple, synchronous (request/response-style) virtio communication. The guest driver builds one descriptor chain, link for link, with VirtioPrepare() and VirtioAppendDesc(), then submits the chain, and awaits the processing, with VirtioFlush(). The descriptor chain is always built at the beginning of the descriptor area, with the head descriptor having descriptor index 0. In order to submit the descriptor chain to the host, the guest always pushes a new "available element" to the Available Ring, in genuine queue-like fashion, with the new element referencing the head descriptor (which always has index 0, see above). In turn, after processing, the host always pushes a new "used element" to the Used Ring, in genuine queue-like fashion, with the new element referencing the head descriptor of the chain that was just processed. The same element also reports the number of bytes that the host wrote, consecutively across the host-writeable buffers that were linked by the descriptors. (See "OvmfPkg/VirtioNetDxe/TechNotes.txt" for a diagram about the descriptor area and the rings.) Because at most one descriptor chain can be in flight with VirtioLib at any time, - the Available Ring and the Used Ring proceed in lock-step, - and the head descriptor that the new "available" and "used" elements can ever reference has index 0. Based on the above, we can modify VirtioFlush() to return the number of bytes written by the host across the descriptor chain. The virtio-block and virtio-scsi drivers don't care (they have other ways to parse the data produced by the host), while the virtio-net driver doesn't use VirtioFlush() at all (it employs VirtioLib only to set up its rings). However, the virtio entropy device, to be covered in the upcoming patches, reports the amount of randomness produced by the host only through this quantity. Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* OvmfPkg: VirtioScsiDxe: reset device at ExitBootServices()Laszlo Ersek2015-10-162-2/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | (1) VirtioLib allocates the virtio ring in EfiBootServicesData memory. (This is intentional.) Code that executes after ExitBootServices() is permitted to reuse such memory. (2) The hypervisor is allowed to look at, and act upon, a live virtio ring at any time, even without explicit virtio kicks from the guest. Should boot loader code or kernel code, running between ExitBootServices() and the kernel's own virtio drivers resetting the device, overwrite the pages that used to contain the virtio ring before ExitBootServices(), QEMU could theoretically interpret that unrelated data as garbage ring contents, and abort the guest. Although we have seen no such reports, better be prudent and reset the device in an ExitBootServices() event handler. Among other things, this causes QEMU to forget about the device's virtio ring. Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18623 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg: VirtioScsiDxe: drop 64-bit shift in PopulateRequest() (VS2010)Scott Duplichan2014-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | "Lun" has type UINT64 in this function. The result of the expression (UINT8) ((Lun >> 8) | 0x40) depends only on bits [15:8] of "Lun", therefore we can cast "Lun" to UINT32 before shifting it. This eliminates an intrinsic when building with VS2010 for Ia32 / NOOPT. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Scott Duplichan <scott@notabs.org> [lersek@redhat.com: added commit message] Signed-off-by: Laszlo Ersek <lersek@redhat.com> Build-tested-by: Scott Duplichan <scott@notabs.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16386 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg: Fix VS2005 build warningsJordan Justen2014-09-251-2/+2
| | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16171 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg: Virtio drivers: fix incorrect casts in init functionsLaszlo Ersek2013-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The recent patch OvmfPkg: Make the VirtIo devices use the new VIRTIO_DEVICE_PROTOCOL was fixed up at commit time, in order to silence warnings issued by the Visual Studio compiler. Differences between the posted and committed patch: > diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c > -index 17b9f71..96a0d9f 100644 > +index 17b9f71..f09b0d1 100644 > --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c > +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c > @@ -23,7 +23,6 @@ > @@ -994,7 +998,7 @@ > + // step 4c -- Report GPFN (guest-physical frame number) of queue. > + // > + Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, > -+ (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT); > ++ (UINT32)(UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT); > + if (EFI_ERROR (Status)) { > + goto ReleaseQueue; > + } > @@ -1495,7 +1499,7 @@ > goto Exit; > } > diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/SnpInitialize.c > -index 6cee014..8dcf9da 100644 > +index 6cee014..4203fbd 100644 > --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c > +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c > @@ -57,14 +57,15 @@ VirtioNetInitRing ( > @@ -1539,7 +1543,7 @@ > - Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueAddress, > - (UINTN) Ring->Base >> EFI_PAGE_SHIFT); > + Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, > -+ (UINTN) Ring->Base >> EFI_PAGE_SHIFT); > ++ (UINT32)(UINTN) Ring->Base >> EFI_PAGE_SHIFT); > if (EFI_ERROR (Status)) { > - VirtioRingUninit (Ring); > + goto ReleaseQueue; > @@ -1721,7 +1725,7 @@ > Exit: > gBS->RestoreTPL (OldTpl); > diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c > -index b836fb3..bcec676 100644 > +index b836fb3..2223c9c 100644 > --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c > +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c > @@ -38,7 +38,6 @@ > @@ -1908,7 +1912,7 @@ > + // step 4c -- Report GPFN (guest-physical frame number) of queue. > + // > + Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, > -+ (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT); > ++ (UINT32)(UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT); > if (EFI_ERROR (Status)) { > goto ReleaseQueue; > } These casts are incorrect -- they throw away address bits >=32 before shifting, which can break the drivers in guests with more than 4GB RAM. The bug is clearly an artifact of the edk2 coding style, which requires cast expressions to be written as (type) expression rather than the usual (type)expression The latter correctly reflects that casts have one of the strongest bindings in C. The former actively obscures that fact. Cf. (type) expr1 >> expr2 vs. (type)expr1 >> expr2 Make sure we shift before we truncate. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14970 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg/Virtio: Removed VirtioReadDevice() / VirtIoWriteDevice() functionsOlivier Martin2013-12-111-12/+12
| | | | | | | | | | | | These functions did not provide much more than the new protocol functions VIRTIO_DEVICE_PROTOCOL.ReadDevice() / VIRTIO_DEVICE_PROTOCOL.WriteDevice(). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14968 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg: Make the VirtIo devices use the new VIRTIO_DEVICE_PROTOCOLOlivier Martin2013-12-113-121/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change replaces the accesses to the PCI bus from the Block, Scsi and Net drivers by the use of the new VIRTIO_DEVICE_PROTOCOL protocol that abstracts the transport layer. It means these drivers can be used on PCI and MMIO transport layer. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> v5: - VirtioFlush(): update comment block in VirtioLib.[hc]; error code is propagated from VirtIo->SetQueueNotify(). - VirtioBlkInit(): jump to Failed label if SetPageSize() fails - VirtioBlkInit(): fixup comment, and add error handling, near SetQueueNum() call - VirtioBlkDriverBindingStart(): remove redundant (always false) check for a subsystem device ID different from VIRTIO_SUBSYSTEM_BLOCK_DEVICE; VirtioBlkDriverBindingSupported() handles it already - VirtioNetGetFeatures(): update stale comment block - VirtioNetGetFeatures(): retrieve MAC address byte for byte (open-coded loop) - VirtioNetDriverBindingStart(): remove redundant (always false) check for a subsystem device ID different from VIRTIO_SUBSYSTEM_NETWORK_CARD; VirtioNetDriverBindingSupported() handles it already - VirtioNetInitRing(): call SetQueueNum() and SetQueueAlign() for proper MMIO operation - VirtioNetInitialize(): fix destination error label for when SetPageSize() fails - VirtioScsi.c: fix comment block of VIRTIO_CFG_WRITE()/VIRTIO_CFG_READ() - VirtioScsiInit(): fix destination error label for when SetPageSize() fails - VirtioScsiInit(): call SetQueueNum() and SetQueueAlign() for proper MMIO operation Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14966 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg: Removed magic values for the Virtio Sub-System ID in the PCI device ↵Olivier Martin2013-09-301-1/+1
| | | | | | | | | | | | drivers Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14742 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg VirtioScsiDxe: Fix build with VS2010jljusten2012-10-231-13/+2
| | | | | | | | | | | | | | Structures should not be directly assigned in EDK II code, since this leads to different behaviours on various compilers. Instead, use ZeroMem to zero out the structures. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13878 6f19259b-4bc3-4df7-8a09-765794883524
* OvmfPkg: introduce virtio-scsi driverjljusten2012-10-183-0/+1531
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> [jordan.l.justen@intel.com: fix build for VS2012] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13867 6f19259b-4bc3-4df7-8a09-765794883524