From: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
To: Paul Brook <paul@codesourcery.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, joro@8bytes.org
Subject: Re: [Qemu-devel] [RFC] Getting specific device from qdev structs
Date: Mon, 21 Jun 2010 17:32:37 +0300 [thread overview]
Message-ID: <20100621143237.GA10604@localhost> (raw)
In-Reply-To: <201006211507.13975.paul@codesourcery.com>
On Mon, Jun 21, 2010 at 03:07:13PM +0100, Paul Brook wrote:
> > So I've been looking for a way to obtain things like a PCIDevice from a
> > more generic structure (say from hw/qdev.h),
>
> If you're having to figure out what kind of a device you have then I think
> you're already doing something else wrong. I'd expect the bits of code that
> needs to identify devices to be inherently bus specific.
>
> If you've got some sort of on-cpu IOMMU which is asking "did this come from an
> ISA device, or a PCI device?", then I suspect you've got your abstraction
> layers wrong. This should already have been handled by the pci/isa to cpu
> bridge.
>
> Paul
Hi,
Thanks for your reply. This isn't about a specific IOMMU. Let me
describe the situation better:
1. I'm implementing the AMD IOMMU, which is a PCI IOMMU (not in the CPU).
2. Devices need address translation and checking through this IOMMU.
3. But in the future there might be other IOMMU implementations,
possibly for other bus types.
Yes, I could (and have already done to test my code) modify device code
to ask the AMD IOMMU for translation. But we have stuff like AIO, which
isn't really bus-specific and would result in spagetti code if I add
PCI-specific stuff, then somebody else does the same for other buses and
so on. Moreover, even for PCI, it isn't really straightforward to obtain
the bus-device-function number required to do translation from AIO code
(e.g. I needed to add the devfn or a pointer to the actual PCIDevice to
BMDMAState to get it working for PIIX).
So I considered providing a generic IOMMU translation/checking API that
could be used by all devices and all IOMMUs. Generally getting the
{PCI,ISA,Whatever}Device should be enough, I think.
If the IOMMU can't handle that specific bus, that's no problem, we can
have generic code do identity mapping without any access checking. If
somebody comes along and wants to implement another IOMMU emulation, all
he needs is to provide implementations for those functions.
Eduard
next prev parent reply other threads:[~2010-06-21 14:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-21 13:48 [RFC] Getting specific device from qdev structs Eduard - Gabriel Munteanu
2010-06-21 14:07 ` [Qemu-devel] " Paul Brook
2010-06-21 14:32 ` Eduard - Gabriel Munteanu [this message]
2010-06-21 15:08 ` Paul Brook
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=20100621143237.GA10604@localhost \
--to=eduard.munteanu@linux360.ro \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--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