qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC] Getting specific device from qdev structs


From: Eduard - Gabriel Munteanu
Subject: Re: [Qemu-devel] [RFC] Getting specific device from qdev structs
Date: Mon, 21 Jun 2010 17:32:37 +0300
User-agent: Mutt/1.5.20 (2009-06-14)

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




reply via email to

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