From: Paul Brook <paul@codesourcery.com>
To: "Eduard - Gabriel Munteanu" <eduard.munteanu@linux360.ro>
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 16:08:03 +0100 [thread overview]
Message-ID: <201006211608.04005.paul@codesourcery.com> (raw)
In-Reply-To: <20100621143237.GA10604@localhost>
> 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).
A bus-device-function number is inherently PCI specific.
> 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.
The actual code to handle address remapping can be bus agnostic. The code to
create the mappings is inherently bus specific. i.e. the generic code needs to
ask the bus bridge "how do I translate this access onto your parent bus".
For example, consider a PCI bridge (Device A) with an IOMMU. On that PCI bus
resides a PCI-ISA bridge (Device B) that also has an IOMMU. Device C is a bus-
master ISA device[1].
Accesses from device C cause the memory mapping code to walk down the bus
structure. First the ISA IOMMU translates that into an access from device B.
Then the PCI IOMMU translates this into a system bus access from device A.
The code to determine each of these mappings is inherently bus specific. That
code trivially knows how to access bus-specific information from its devices.
However the framework used to chain these mappings and perform the actual
transfer should be bus agnostic.
While the IOMMU actually resides in the host bridge, it probably makes most
sense to associate it with the bus itself. When the host device creates the
bus it can also create the IOMMU. This should handle both explicit (PCI) and
implicit (SBUS) slave-side bus interfaces.
Paul
[1] I don't think ISA supports bus-master devices, but ignore that for now.
prev parent reply other threads:[~2010-06-21 15:08 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
2010-06-21 15:08 ` Paul Brook [this message]
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=201006211608.04005.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=eduard.munteanu@linux360.ro \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--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