qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark Williamson <mark.williamson@cl.cam.ac.uk>
To: Paul Brook <paul@codesourcery.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] PCI access virtualization
Date: Fri, 6 Jan 2006 01:54:44 +0000	[thread overview]
Message-ID: <200601060154.45653.mark.williamson@cl.cam.ac.uk> (raw)
In-Reply-To: <200601051810.54954.paul@codesourcery.com>

> > Could maybe have the (inevitable) kernel portion of the code grab the
> > interrupt, and not ack it until userspace does an ioctl on a special file
> > (or something like that?).  There are patches floating around for
> > userspace IRQ handling, so I guess that could work.
>
> This still requires cooperation from both sides (ie. both the host and
> guest drivers).

True.

> IIUC PCI cards don't really have "DMA engines" as such. The PCI bridge just
> maps PCI address space onto physical memory. A Busmaster PCI device can
> then make arbitrary acceses whenever it wants. I expect the default mapping
> is a 1:1 mapping of the first 4G of physical ram.

I was under the impression that the on-card bus-mastering engines were often 
one of a few standard designs -  this was suggested to me by someone more 
knowledgeable than myself but must admit I don't have any hard evidence that 
it's the case ;-)

A "half way" solution would, I guess, be to code up a partial emulator for the 
device, emulating key operations (by translating them and reissuing to the 
device) whilst allowing other operations to pass directly through.

> > How about something like this?:
> > I'd imagine you could get away with a special header file with different
> > macro defines (as for Xen, above), just in the driver in question, and a
> > special "translation device / service" available to the QEmu virtual
> > machine - could be as simple as "write the guest physical address to an
> > IO port, returns the real physical address on next read".  The
> > virt_to_bus (etc) macros would use the translation service to perform the
> > appropriate translation at runtime.
>
> That's exactly the sort of thing I meant. Ideally you'd just implement it
> as a different type of PCI bridge, and everything would just work. I don't
> know if linux supports such heterogeneous configurations though.

I think that wouldn't be sufficient due to the way Linux behaves - virtual to 
physical address conversion will be done within the guest driver and then 
issued directly to the hardware, so a bridge driver won't be able to fix up 
the DMA addressing correctly.

I guess with some header file hacks it'd be possible to make the conversion 
macros themselves switchable, so that (in principle) any driver could be 
loaded in "native" or "QEmu passthrough" mode by specifiying an optional 
load-time argument - that would be cool.  Making it automatically switch 
would be a bit tricky though... maybe the macros could be made to switch on 
the basis of the module PCI ID table :-D *evil grin*

Cheers,
Mark

  parent reply	other threads:[~2006-01-06  2:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-05 10:14 [Qemu-devel] PCI access virtualization Michael Renzmann
2006-01-05 14:25 ` Paul Brook
2006-01-05 17:40   ` Mark Williamson
2006-01-05 18:10     ` Paul Brook
2006-01-05 21:13       ` Jim C. Brown
2006-01-06  1:54       ` Mark Williamson [this message]
2006-01-06 13:27         ` Paul Brook
2006-01-06 14:23           ` Mark Williamson
2006-01-05 16:25 ` Mark Williamson

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=200601060154.45653.mark.williamson@cl.cam.ac.uk \
    --to=mark.williamson@cl.cam.ac.uk \
    --cc=paul@codesourcery.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).