All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Molton <ian.molton@collabora.co.uk>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Address translation - virt->phys->ram
Date: Mon, 22 Feb 2010 16:46:27 +0000	[thread overview]
Message-ID: <4B82B4E3.2040805@collabora.co.uk> (raw)
In-Reply-To: <4B829645.5020904@codemonkey.ws>

Anthony Liguori wrote:

> cpu_physical_memory_map().
> 
> But this function has some subtle characteristics.  It may return a
> bounce buffer if you attempt to map MMIO memory.  There is a limited
> pool of bounce buffers available so it may return NULL in the event that
> it cannot allocate a bounce buffer.
> 
> It may also return a partial result if you're attempting to map a region
> that straddles multiple memory slots.

Thanks. I had found this, but was unsure as to wether it was quite what
I wanted. (also is it possible to tell when it has (eg.) allocated a
bounce buffer?)

Basically, I need to get buffer(s) from guest userspace into the hosts
address space. The buffers are virtually contiguous but likely
physically discontiguous. They are allocated with malloc() and theres
nothing I can do about that.

The obvious but slow solution would be to copy all the buffers into nice
virtio-based scatter/gather buffers and feed them to the host that way,
however its not fast enough.

Right now I have a little driver I have written that allows a buffer to
be mmap()ed by the guest userspace, and this is pushed to the host via
virtio s/g io when the guest calls fsync(). This buffer contains the
data that must be passed to the host, however this data may often
contain pointers to (that is, userspace virtual addresses of) buffers of
unknown sizes which the host also needs to access. These buffers are
what I need to read from the guests RAM.

The buffers will likely remain active across multiple different calls to
the host so their pages will need to be available. As the calls always
happen when that specific process is active, I'd guess the worst we need
to do is generate a page fault to unswap the page(s). Can that be caused
by qemu (under kvm)?

It seems that cpu_physical_memory_map() deals with physically contiguous
areas of guest address space. I need to get a host-side mapping of a
*virtually* contiguous (possibly physically discontiguous) set of guest
pages. If this can be done, it'd mean direct transfer of data from guest
application to host shared library, which would be a major win.

-Ian

  reply	other threads:[~2010-02-22 16:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-22 13:59 [Qemu-devel] Address translation - virt->phys->ram Ian Molton
2010-02-22 14:35 ` Anthony Liguori
2010-02-22 16:46   ` Ian Molton [this message]
2010-02-22 16:52     ` Anthony Liguori
2010-02-22 17:47       ` Ian Molton
2010-02-22 18:56         ` Alexander Graf
2010-02-23 15:46           ` Ian Molton
2010-02-23 15:54             ` Alexander Graf
2010-02-23 16:21         ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B82B4E3.2040805@collabora.co.uk \
    --to=ian.molton@collabora.co.uk \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.