There's one trivial omission in this patch, wrt. the previous review comments:
On 08/23/17 14:22, Brijesh Singh wrote: > Add functions to map the ring buffer with BusMasterCommonBuffer so that (1) s/functions/a function/ I'll fix it up before I push the initial subsequence. Reviewed-by: Laszlo Ersek <ler...@redhat.com> Thanks! Laszlo > ring can be accessed by both guest and hypervisor. > > Cc: Ard Biesheuvel <ard.biesheu...@linaro.org> > Cc: Jordan Justen <jordan.l.jus...@intel.com> > Cc: Tom Lendacky <thomas.lenda...@amd.com> > Cc: Laszlo Ersek <ler...@redhat.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> > --- > OvmfPkg/Include/Library/VirtioLib.h | 26 +++++++++++ > OvmfPkg/Library/VirtioLib/VirtioLib.c | 45 ++++++++++++++++++++ > 2 files changed, 71 insertions(+) > > diff --git a/OvmfPkg/Include/Library/VirtioLib.h > b/OvmfPkg/Include/Library/VirtioLib.h > index 40c51a2b3305..3d9314b3acaf 100644 > --- a/OvmfPkg/Include/Library/VirtioLib.h > +++ b/OvmfPkg/Include/Library/VirtioLib.h > @@ -62,6 +62,32 @@ VirtioRingInit ( > > /** > > + Map the ring buffer so that it can be accessed equally by both guest > + and hypervisor. > + > + @param[in] VirtIo The virtio device instance. > + > + @param[in] Ring The virtio ring to map. > + > + @param[out] RingBaseShift A resulting translation offset, to be > + passed to VirtIo->SetQueueAddress(). > + > + @param[out] Mapping A resulting token to pass to > + VirtIo->UnmapSharedBuffer(). > + > + @return Status code from VirtIo->MapSharedBuffer() > +**/ > +EFI_STATUS > +EFIAPI > +VirtioRingMap ( > + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, > + IN VRING *Ring, > + OUT UINT64 *RingBaseShift, > + OUT VOID **Mapping > + ); > + > +/** > + > Tear down the internal resources of a configured virtio ring. > > The caller is responsible to stop the host from using this ring before > diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c > b/OvmfPkg/Library/VirtioLib/VirtioLib.c > index 8bc5b9aea4fc..535635ac0ba8 100644 > --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c > +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c > @@ -505,3 +505,48 @@ Failed: > VirtIo->UnmapSharedBuffer (VirtIo, MapInfo); > return EFI_OUT_OF_RESOURCES; > } > + > +/** > + > + Map the ring buffer so that it can be accessed equally by both guest > + and hypervisor. > + > + @param[in] VirtIo The virtio device instance. > + > + @param[in] Ring The virtio ring to map. > + > + @param[out] RingBaseShift A resulting translation offset, to be > + passed to VirtIo->SetQueueAddress(). > + > + @param[out] Mapping A resulting token to pass to > + VirtIo->UnmapSharedBuffer(). > + > + @return Status code from VirtIo->MapSharedBuffer() > +**/ > +EFI_STATUS > +EFIAPI > +VirtioRingMap ( > + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, > + IN VRING *Ring, > + OUT UINT64 *RingBaseShift, > + OUT VOID **Mapping > + ) > +{ > + EFI_STATUS Status; > + EFI_PHYSICAL_ADDRESS DeviceAddress; > + > + Status = VirtioMapAllBytesInSharedBuffer ( > + VirtIo, > + VirtioOperationBusMasterCommonBuffer, > + Ring->Base, > + EFI_PAGES_TO_SIZE (Ring->NumPages), > + &DeviceAddress, > + Mapping > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + *RingBaseShift = DeviceAddress - (UINT64)(UINTN)Ring->Base; > + return EFI_SUCCESS; > +} > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel