qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about virtio DMA operations


From: Arnabjyoti Kalita
Subject: Re: Questions about virtio DMA operations
Date: Wed, 1 Sep 2021 11:32:10 +0530

Thank you Peter. This makes it very clear.

Best Regards,
Arnabjyoti Kalita

On Tue, Aug 31, 2021 at 3:32 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Tue, 31 Aug 2021 at 05:48, Arnabjyoti Kalita
> <akalita@cs.stonybrook.edu> wrote:
> >
> > Dear Peter,
> >
> > I had a few additional questions with regards to dma_memory_map(). So,
> > let's say I record the buffer that has been written/read from the
> > disk.
> >
> > iov[num_sg].iov_base = dma_memory_map(vdev->dma_as, pa, &len, s_write ?
> >                      DMA_DIRECTION_FROM_DEVICE :
> >                      DMA_DIRECTION_TO_DEVICE);
> >
> > addr[num_sg] = pa;
> > iov[num_sg].iov_len = len;
> >
> > Is it correct to say that the host virtual address(in the case above,
> > iov[num_sg].iov_base) that dma_memory_map gives will contain the
> > actual buffer that has been read/written from/to the device?
>
> It contains a pointer which corresponds to the guest memory.
> If this is a read-from-guest-memory, then the contents will
> be whatever the guest just asked us to do IO from. (Whether
> we actually end up pushing that to the block device depends on
> a bunch of other stuff, I expect.)
>
> If this is a write-to-guest-memory, then at the point where
> dma_memory_map() has just been called, then the contents are
> whatever random junk is currently at that memory. The virtio
> device model will at some point arrange for the block layer
> to do IO into that host address.
>
> > And when dma_memory_unmap() happens, the contents of the buffer that
> > is pointed to by the host virtual address, will be finally written to
> > the guest physical memory which is pointed to by "pa" in the code
> > above?
>
> If the DMA is to real guest RAM, then the IO will update the
> guest memory immediately as the block layer writes to it,
> because the iov_base pointer is really to the actual host memory
> that is backing that guest RAM. It's only if the DMA is to something
> that's a device model (not RAM) that the write is delayed until
> the unmap call.
>
> -- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]